Commit graph

51,933 commits

Message SHA1
Modify VPN unit tests to include SDK sandbox UIDs.
VPN configurations in T should automatically include the corresponding
SDK sandbox UID of an application.

The existing tests used a UID range outside the regular application
range, which means the new sandbox UIDs wouldn't be tested. Modified the
UIDs to run in the regular UID range of [10000, 19999]. Changed the
tests to include the SDK sandbox UID where necessary.

Also, changed the entire class to only run on T+, since that is the only
place where the SDK sandbox UIDs will be added. Since VPN code is not
mainline updatable, having coverage on earlier releases doesn't really
help anyway.

Finally, fixed up testNetworkBlockedStatusAlwaysOnVpn() in
ConnectivityServiceTest to include the sandbox UIDs as well.

Bug: 225317905
Test: atest VpnTest
Test: atest ConnectivityServiceTest

Change-Id: I83009344c270e520ac8ad1558c067cf7e46b1d2e

Martijn Coenen   commited 2022-05-12 08:07:29 +00:00
021d8b08c1
Merge "Address leftover comments"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-05-12 06:06:40 +00:00
68936325f0
Address leftover comments
This is a follow-up commit from aosp/2076483. Mainly to update:
1. Update the hex string to human understandable code instead of
   byte code.
2. Use IgnoreUpTo() to do the SDK check
3. Avoid relying on the code being tested

Bug: 192078259
Test: atest FrameworksNetTests
Change-Id: I8973d248a1d30fdcb597677dbf051e146041f905

Chiachang   commited 2022-05-12 02:50:22 +00:00
a023f88193
Merge "Fallback should be evaluated for each preference"
Sooraj Sasindran   authored and   Gerrit Code Review   commited 2022-05-11 21:05:18 +00:00
5ea6f517a6
Merge "Register service on the specified network"
Paul Hu   authored and   Gerrit Code Review   commited 2022-05-11 05:57:04 +00:00
018cf3fb46
Fallback should be evaluated for each preference
1) alowFallback flag was incorrectly not reset while setting profile
   preference. Corrected it.

2) Threw exception if default preference and enterprise preference are
set together

3) renamed clearUser to withoutUser

Bug: 231670730
Test: ConnectivityServiceTest

Change-Id: Iaf49237bdc791c7e1dd884d069eff64e74757477

Sooraj Sasindran   commited 2022-05-10 22:11:55 -07:00
b0e283c900
Merge changes I5eaeb415,I236f1550
* changes:
  Check carrier privilege for CBS network requests synchronously
  Allow 3p apps to request restricted networks

Paul Hu   authored and   Gerrit Code Review   commited 2022-05-10 14:38:30 +00:00
7d180e679a
Check carrier privilege for CBS network requests synchronously
Normally if an app calls requestNetwork with capabilities that it
does not have permission to request, it gets a SecurityException,
except if it requests NET_CAPABILITY_CBS, in which case the request
will not throw but the app will get an onUnavailable callback.

Make this codepath throw as well. This simplifies the code and makes
the app-visible behaviour more consistent (and consistent with what
happens in S and below). The reason the code was written this way is because the carrier privilege app should receive a callback if it
loses permission. But onUnavailable is also not the best callback to
send, since it is used very rarely and also releases the app's
request. It seems better to leave the request registered and send
onLost.

Test: atest FrameworksNetTests
Bug: 194332512
Change-Id: I5eaeb415a6654851246e38599a996fbd9366fde0

junyulai   authored and   Paul Hu   commited 2022-05-10 10:26:54 +00:00
96bd9fe4de
Allow 3p apps to request restricted networks
Since 3p apps are allowed to use restricted networks in S, they
should be allowed to request a restricted network reasonably.
Otherwise, the functionalities of 3p apps will break if they rely
on restricted networks. Thus, CS needs to allow 3p apps to
request restricted networks if 3p apps are in the allowed list.

Bug: 230509118
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I236f1550095ee2be29adbc3b28d3ac2561a8b072

Paul Hu   commited 2022-05-10 18:10:19 +08:00
8fc2a55a16
Merge "Add MainlineTestModuleController to CtsNetTestCases"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-10 03:32:52 +00:00
28fc2c6da4
Merge "Set ServiceConnectivityResources as target_sdk 33"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-10 02:08:51 +00:00
ae32800315
Merge "Change NetworkInterfaceState to hold NetworkProvider instance"
Patrick Rohr   authored and   Gerrit Code Review   commited 2022-05-09 21:38:12 +00:00
fdc424a614
Merge "Limit usage requests dump count"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-09 15:01:27 +00:00
85a25e11ab
Merge "Migrate compareMajorMinorVersion to common libs"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-09 13:20:52 +00:00
33f1e8a8cb
Set ServiceConnectivityResources as target_sdk 33
The target SDK was mirroring the build SDK, which is 30.

The APK contains no code so this should have no impact.

Bug: 229174084
Change-Id: Ie7651f0f0974ea060b5b6e7bea556cbea0f68466
Test: aapt dump badging ServiceConnectivityResources.apk

Remi NGUYEN VAN   commited 2022-05-09 09:59:11 +00:00
c255a444fc
Merge "Do not remove profile network preference for different uids"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2022-05-09 09:40:52 +00:00
42791188b2
Limit usage requests dump count
Test: manual
Bug: 229103088
Change-Id: Id913b34a3b48b10c66eb399b28ee8702e300f568

Junyu Lai   commited 2022-05-09 17:34:37 +08:00
b889d4705a
Merge "Add more tests for setProfileNetworkPreferences"
Sooraj Sasindran   authored and   Gerrit Code Review   commited 2022-05-09 09:12:48 +00:00
a457b6fdf1
Merge "Improve count of openSession callers in dumpsys"
Aaron Huang   authored and   Gerrit Code Review   commited 2022-05-09 06:32:57 +00:00
a888685a4a
Merge "Remove NetworkIdentitySet usage in CTS"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-09 04:13:27 +00:00
65b3529be5
Improve count of openSession callers in dumpsys
Currently, it's only uid=count in dumpsys, however, the call may also
come from system but there is no such information in dumpsys. If the
call came from system, it's hard to know who is the caller. So, this
patch makes pid, uid and package as a key to record the count of the
caller.

The output will look like,
Top openSession callers:
  {pid=1787,uid=1000,package=android}=26
  {pid=2931,uid=1000,package=com.android.settings}=4

Test: adb shell dumpsys netstats and check the output
Bug: 228081549
Change-Id: Id2dfdd4480aa5b1ece51e46de6efe30a46629811

Aaron Huang   commited 2022-05-09 10:35:55 +08:00
b87b5e5d0a
Merge "Improve logging for NetworkStatsObservers"
Junyu Lai   authored and   Gerrit Code Review   commited 2022-05-07 02:11:07 +00:00
ef1fdc95dd
Merge "Avoid unregistering the same receiver more than once."
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-07 00:07:22 +00:00
e5a9ad96c5
Avoid unregistering the same receiver more than once.
Bug: 231496005
Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Change-Id: Iba17daa70f14bdee1d1a7d32cb9dc64623ba1d24
Merged-In: Iba17daa70f14bdee1d1a7d32cb9dc64623ba1d24

Sudheer Shanka   commited 2022-05-06 22:53:39 +00:00
d1e236eb05
Merge "Support QosCallback with UDP socket. UnitTest"
Sewook Seo   authored and   Gerrit Code Review   commited 2022-05-06 20:47:05 +00:00
baabe211be
Merge "Support QosCallback for UDP socket : validate"
Sewook Seo   authored and   Gerrit Code Review   commited 2022-05-06 20:46:46 +00:00
bffaff76e0
Merge "Support QosCallback for UDP socket -Filter"
Sewook Seo   authored and   Gerrit Code Review   commited 2022-05-06 20:46:26 +00:00
047423fd34
Merge "enable btf = true for block/clatd/dscp_policy/netd bpf programs"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-05-06 15:32:33 +00:00
fc62930a9a
Do not remove profile network preference for different uids
Multiple enterprise slice can be setup within single user profile based
on different uids. So do not remove profile network preference with same
user profile but with different uids

Bug: 229644102
Test: manual system test and ConnectivityServciceTest
Change-Id: I897b643e01240958fff575de9e15182069efc698

Sooraj Sasindran   commited 2022-05-06 00:58:33 -07:00
9cc129f37d
Add more tests for setProfileNetworkPreferences
1. Test that adding a new preference replaces the existing preference.
2. Test that if we pass in two simultaneous preferences for the same user.
   (e.g., two different groups of apps), the second overrides the first.

Bug: 229644102
Test: ConnectivityServciceTest
Change-Id: I819247711f8457b12792585216ff47be31457ae8

Sooraj Sasindran   commited 2022-05-06 00:58:28 -07:00
95e02c5d5a
Merge "ClatCoordinator: replace BpfMap with IBpfMap"
Nucca Chen   authored and   Gerrit Code Review   commited 2022-05-06 05:37:58 +00:00
93c35bdd78
Merge changes I8b48655d,I8ff4e371
* changes:
  Rename of InternalNetworkManagementException
  InternalNetworkManagementExceptionTest unit tests

James Mattis   authored and   Gerrit Code Review   commited 2022-05-05 20:05:35 +00:00
105c5f0b1a
Merge "[LSC] Add LOCAL_LICENSE_KINDS to packages/modules/Connectivity"
Bob Badour   authored and   Gerrit Code Review   commited 2022-05-05 18:05:31 +00:00
ff4e6c2442
ClatCoordinator: replace BpfMap with IBpfMap
Test: atest ClatCoordinatorTest
Change-Id: I3d046d4f195be6bbedc15df08114fafb2b77c2d3

Hungming Chen   commited 2022-05-05 23:48:37 +08:00
12c625bbf8
Merge "funky workaround to make things load on 4.14 bpf verifier"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-05-05 14:47:19 +00:00
3cb5894011
[LSC] Add LOCAL_LICENSE_KINDS to packages/modules/Connectivity
Added SPDX-license-identifier-Apache-2.0 to:
  tests/cts/hostside/app3/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all
Change-Id: I0f594c539640b9815040bf5082677592574b022d

Bob Badour   commited 2022-05-05 07:11:29 -07:00
2a50c246cd
Merge "Open and close clat bpf map while clat is starting and stoping"
Nucca Chen   authored and   Gerrit Code Review   commited 2022-05-05 12:53:25 +00:00
e01d2733bc
Open and close clat bpf map while clat is starting and stoping
BpfMap class supports AutoCloseable interface which closes
file descriptor only in try-exit. BpfMap class doesn't close
fds while the object is released.

Change the timing of opening and closing bpf map file descriptors
to clat is starting and stoping.

Moreover, the reason that manual close BPF map file descriptors is
as follows. Just don't rely on that GC releasing to close the file
descriptors even if class BpfMap supports close file descriptor in
finalize(). If the interfaces are added and removed quickly, too
many unclosed file descriptors may cause unexpected problems.

Bug: 230880517
Test: manual test
Steps:
1. Connect to IPv6 only wifi (GoogleGuest) and mobile data
2. Check that map fds are appeared:
   /proc/$(system_server_pid)/fd/$(bpf_map_fd)

$ adb shell ps | grep system_server
system        1929   825 20311224 730060 do_epoll_wait      0 S system_server

$ adb shell ls -all proc/1929/fd | grep bpf-map
.. system system 64 2022-05-05 13:36:42 .. 331 -> anon_inode:bpf-map
.. system system 64 2022-05-05 13:36:42 .. 348 -> anon_inode:bpf-map

3. Check the clat maps are added.
$ adb shell dumpsys connectivity
NetworkAgentInfo{network{105}  handle{454377263117}  ni{WIFI ..
Nat464Xlat:
..
  Forwarding rules:
    BPF ingress map: iif nat64Prefix v6Addr -> v4Addr oif
      47 /64:ff9b::/96 /2a00:79e1:abc:6f02:f182:6c29:ab56:9961 -> /192.0.0.4 62
    BPF egress map: iif v4Addr -> v6Addr nat64Prefix oif
      62 /192.0.0.4 -> /2a00:79e1:abc:6f02:f182:6c29:ab56:9961 /64:ff9b::/96 47 ether
NetworkAgentInfo{network{106}  handle{458672230413}  ni{MOBILE[LTE] ..
    Nat464Xlat:
      <not start>

4. Disconnect from wifi

5. Check that map fds are disappeared:
   /proc/$(system_server_pid)/fd/$(bpf_map_fd)

$ adb shell ls -all proc/1929/fd | grep bpf-map
(fd 331 and 348 were not found)

Change-Id: I60c0301bf00beae5cf5ab3535c6a3da68a2a4a9b

Hungming Chen   commited 2022-05-05 18:53:37 +08:00
c03323c8ef
funky workaround to make things load on 4.14 bpf verifier
Mostly this is cut-and-paste of bottom half of do_forward4
function into a seperate function to force the compiler to
emit two differently optimized versions of the code based on
whether is_tcp is true or false.

Bug: 230359047
Test: TreeHugger, manually on flame
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9e3e195ba601daaac2e0c9a70fad170a8fb4d921

Maciej Żenczykowski   commited 2022-05-05 09:46:33 +00:00
f72c8aa5c3
Ignore UDP offload test on kernel which is older than 4.14
Kernel version which is older than 4.14 doesn't support UDP offload
absolutely. Kernel version which is between 4.14 and 5.8 support UDP
offload probably. Simply set kernel 4.14 to be threshold first and
monitor on what devices tests fail for improving the offload support
checking.

Also fix a minor bug which UDP tethering without offload is not tested
on R.

Bug: 230359047
Test: atest EthernetTetheringTest
Change-Id: Ieb181d1b5ed67b922e18ce77a9c96208b2984d10

Hungming Chen   authored and   Nucca Chen   commited 2022-05-05 09:35:00 +00:00
08c48a3dff
Support QosCallback with UDP socket. UnitTest
Adding unit tests to QosSocketFilterTest

Bug: 203146631
Test: atest & verified on LTE test equipment
Change-Id: I0cd82dde0067d754dfab01ed0406370d7debb937

sewookseo   authored and   Sewook Seo   commited 2022-05-05 08:45:00 +00:00
04ced836b8
Support QosCallback for UDP socket : validate
Do validate() before sending QosCallback to App.
If validate fails, notify error to App & tear down QosCallback internally.

Bug: 203146631
Test: atest & verified on LTE test equipment
Change-Id: I05e28b10b816381a191272c85b3b178204d835d7

sewookseo   authored and   Sewook Seo   commited 2022-05-05 08:43:50 +00:00
b9bacba803
Improve logging for NetworkStatsObservers
In order to have better logging to gather information
about the callers. This change includes:
 1. Add pid and package name into RequestInfo for better logging.
 2. Print current observers in dumpsys section.
 3. Enable register/unregister usage request logging by default.

The log added in the dumpsys section looks like:
Stats Observers:
  RequestInfo from pid/uid:2001/1000(android) for DataUsageRequest [...] accessLevel:3
  ...

Test: NetworkStatsObserversTest
Bug: 229103088
Change-Id: Ide68776dc279610e8dee0efd924b59a1fac2b7b6

Junyu Lai   commited 2022-05-05 16:30:50 +08:00
c259e615e6
Merge "Test [set|get]AppExclusionList"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-05-05 01:58:49 +00:00
34a257ad5f
Merge "Add tests for LinkProperties#EXCLUDED_ROUTES"
Taras Antoshchuk   authored and   Gerrit Code Review   commited 2022-05-04 10:38:59 +00:00
3c80d34147
Test [set|get]AppExclusionList
Bug: 192078259
Test: atest FrameworksNetTests
Change-Id: Iee81d84b4127420121ce2d5a7defc3dbe34b6cde

chiachangwang   authored and   Chiachang Wang   commited 2022-05-04 10:13:46 +00:00
218d5652de
Add tests for LinkProperties#EXCLUDED_ROUTES
Add CTS tests for LinkProperties#EXCLUDED_ROUTES gated change.
These tests check LinkProperties#getRoutes and
LinkProperties#getAllRoutes behavior depending on whether the gated
change is enabled.

Bug: 186082280
Test: atest HostsideLinkPropertiesGatingTests
Change-Id: Id353714331a19d09022d20f186c8f71343686da7

Taras Antoshchuk   commited 2022-05-03 23:45:33 +02:00
f0c8daa0eb
Rename of InternalNetworkManagementException
Test update for renaming InternalNetworkManagementException to
EthernetNetworkManagementException.

Bug: 210485380
Test: atest FrameworksNetTests
Change-Id: I8b48655dc090eecda1dfd0542092308036fe6da7

James Mattis   commited 2022-05-03 13:22:21 -07:00
371b229216
InternalNetworkManagementExceptionTest unit tests
Bug: 210485380
Test: atest FrameworksNetTests
:android.net.InternalNetworkManagementExceptionTest

Change-Id: I8ff4e371be961a4ffce5e6281c86ab4c2968f971
Merged-In: I8ff4e371be961a4ffce5e6281c86ab4c2968f971

James Mattis   commited 2022-05-03 13:22:15 -07:00
d9d03808f1
Merge "Update VPN isolation code for excluded routes"
Prerana Patil   authored and   Gerrit Code Review   commited 2022-05-03 17:40:12 +00:00
a1c6dbbd53