Commit Graph

808 Commits

Author SHA1 Message Date
Junyu Lai
702e0f3deb Merge "Limit data usage request per uid" am: fc938cf026 am: 26acc088a5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2085772

Change-Id: I8a9bee88f0f8ddec5f19b8bf5ce05d110d3f5aca
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-13 10:20:59 +00:00
Junyu Lai
fc938cf026 Merge "Limit data usage request per uid" 2022-05-13 09:06:41 +00:00
Hungming Chen
2a1430893e Revert "Open and close clat bpf map while clat is starting and stoping" am: b135921ed7 am: e5f50f95d3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2092304

Change-Id: I0f95fbb9cddd7b63c2569c954ea2d35ee8614e48
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 14:28:40 +00:00
Hungming Chen
6f2fa97132 Revert "ClatCoordinator: replace BpfMap with IBpfMap" am: 9416307fa1 am: c88f684b8f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2092303

Change-Id: I55dfa80bc07273f797a506510ecf43b71788ec1b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 14:28:34 +00:00
Hungming Chen
e5f50f95d3 Revert "Open and close clat bpf map while clat is starting and stoping" am: b135921ed7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2092304

Change-Id: Id5570149952ef685c37d63373d375839be8b7e52
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 14:07:30 +00:00
Hungming Chen
c88f684b8f Revert "ClatCoordinator: replace BpfMap with IBpfMap" am: 9416307fa1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2092303

Change-Id: Ic3209c5995442ad1782df44ec30ece1d06218c37
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 14:07:25 +00:00
Nucca Chen
f889ed7a30 Merge changes from topic "wrap_fd_to_parcelfiledescriptor"
* changes:
  Catch new exceptions from BpfMap
  Revert "Open and close clat bpf map while clat is starting and stoping"
  Revert "ClatCoordinator: replace BpfMap with IBpfMap"
2022-05-12 13:42:23 +00:00
Martijn Coenen
27a3d32c5b Merge "Modify VPN unit tests to include SDK sandbox UIDs." am: fc43f671dc am: 4fb520fa44
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2073533

Change-Id: I1c154da26188e5c369dc37a0ecd65855ab842ec6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 12:43:13 +00:00
Martijn Coenen
021d8b08c1 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
2022-05-12 08:07:29 +00:00
Chiachang Wang
ce7f5db86b Merge "Address leftover comments" am: 68936325f0 am: 7478298be2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2095368

Change-Id: I3f89b18d929a5c463826f767a0eb72983fd1ca4d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 07:04:53 +00:00
Chiachang Wang
68936325f0 Merge "Address leftover comments" 2022-05-12 06:06:40 +00:00
Chiachang
a023f88193 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
2022-05-12 02:50:22 +00:00
Sooraj Sasindran
95aa795f56 Merge "Fallback should be evaluated for each preference" am: 5ea6f517a6 am: 8522fc4532
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2092882

Change-Id: I232ff4d279e7e2d26654637247967055f2e666e4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 00:56:06 +00:00
Paul Hu
0554b3e11b Merge changes I5eaeb415,I236f1550 am: 7d180e679a am: af3dffefd7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2015175

Change-Id: Ib20e505f1a6776a49e0c7bfc31a709328e77edf5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 00:55:45 +00:00
Junyu Lai
f3c946278c Limit data usage request per uid
Currently, there is no limtation for an app to request
data usage callback, which is dangerous if the app fire
hundreds of thousands requests and potientially this might
cause OOM if the apps don't free them.

Test: atest NetworkStatsObserversTest#testRegister_limit
Bug: 229103088
Change-Id: I8299f46fd47a82ec9b25ba2e0d3c95db5512c331
2022-05-12 08:53:21 +08:00
Sooraj Sasindran
5ea6f517a6 Merge "Fallback should be evaluated for each preference" 2022-05-11 21:05:18 +00:00
Sooraj Sasindran
b0e283c900 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
2022-05-10 22:11:55 -07:00
Paul Hu
7d180e679a Merge changes I5eaeb415,I236f1550
* changes:
  Check carrier privilege for CBS network requests synchronously
  Allow 3p apps to request restricted networks
2022-05-10 14:38:30 +00:00
junyulai
96bd9fe4de 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
2022-05-10 10:26:54 +00:00
Lorenzo Colitti
784d9b492c Merge "Do not remove profile network preference for different uids" am: 42791188b2 am: e625192614
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2076720

Change-Id: I6cbdc8dedb869a45190482e8c5f71d8278f5ba59
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-09 14:26:47 +00:00
Sooraj Sasindran
235dfbd6a8 Merge "Add more tests for setProfileNetworkPreferences" am: a457b6fdf1 am: d248be0c71
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2083223

Change-Id: Ia92b4bc8b691163ae15ba36c98bd136ec7106a3d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-09 14:26:37 +00:00
Hungming Chen
b135921ed7 Revert "Open and close clat bpf map while clat is starting and stoping"
Test: build
This reverts commit c03323c8ef.

Change-Id: I0cd8b2b409bb4df248d9b9d49a3392a1fe7ecafe
2022-05-09 19:37:19 +08:00
Hungming Chen
9416307fa1 Revert "ClatCoordinator: replace BpfMap with IBpfMap"
Test: build
This reverts commit 12c625bbf8.

Change-Id: I100dc77a8e29ac21ca649d6487563021e8cf0f80
2022-05-09 19:37:08 +08:00
Lorenzo Colitti
42791188b2 Merge "Do not remove profile network preference for different uids" 2022-05-09 09:40:52 +00:00
Sooraj Sasindran
a457b6fdf1 Merge "Add more tests for setProfileNetworkPreferences" 2022-05-09 09:12:48 +00:00
Junyu Lai
f85b4ad8d8 Merge "Improve logging for NetworkStatsObservers" am: ef1fdc95dd am: b5fa10f4cf
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2085625

Change-Id: I0e7c0ef887764b5f513f6a974c4adbab12c8bc7a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-07 02:52:03 +00:00
Junyu Lai
ef1fdc95dd Merge "Improve logging for NetworkStatsObservers" 2022-05-07 02:11:07 +00:00
Sewook Seo
83583570e8 Merge "Support QosCallback with UDP socket. UnitTest" am: baabe211be am: 889bef0398
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2019537

Change-Id: I06e1cce27c4faaf942756160810e8335358bd021
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-06 21:40:22 +00:00
Sewook Seo
baabe211be Merge "Support QosCallback with UDP socket. UnitTest" 2022-05-06 20:47:05 +00:00
Sooraj Sasindran
9cc129f37d 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
2022-05-06 00:58:33 -07:00
Sooraj Sasindran
95e02c5d5a 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
2022-05-06 00:58:28 -07:00
Nucca Chen
2b0673f70f Merge "ClatCoordinator: replace BpfMap with IBpfMap" am: 93c35bdd78 am: 0098a3313f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2088123

Change-Id: Ic604849c29a403bf3004c62a60f709ff76c7128b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-06 06:15:43 +00:00
Hungming Chen
12c625bbf8 ClatCoordinator: replace BpfMap with IBpfMap
Test: atest ClatCoordinatorTest
Change-Id: I3d046d4f195be6bbedc15df08114fafb2b77c2d3
2022-05-05 23:48:37 +08:00
Nucca Chen
54169ca53b Merge "Open and close clat bpf map while clat is starting and stoping" am: e01d2733bc am: e196eafcdb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2085871

Change-Id: I2f4450f50d32644a8483fc115ee380dc409a8c49
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-05 13:44:17 +00:00
Hungming Chen
c03323c8ef 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
2022-05-05 18:53:37 +08:00
sewookseo
04ced836b8 Support QosCallback with UDP socket. UnitTest
Adding unit tests to QosSocketFilterTest

Bug: 203146631
Test: atest & verified on LTE test equipment
Change-Id: I0cd82dde0067d754dfab01ed0406370d7debb937
2022-05-05 08:45:00 +00:00
Junyu Lai
c259e615e6 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
2022-05-05 16:30:50 +08:00
Chiachang Wang
e85648b4a5 Merge "Test [set|get]AppExclusionList" am: 34a257ad5f am: 227e4f18a5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2076483

Change-Id: I93b2b057f6c2ab0fd63f2d39de5eefad0743ddc1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-05 02:20:04 +00:00
chiachangwang
218d5652de Test [set|get]AppExclusionList
Bug: 192078259
Test: atest FrameworksNetTests
Change-Id: Iee81d84b4127420121ce2d5a7defc3dbe34b6cde
2022-05-04 10:13:46 +00:00
Aaron Huang
132df4ed06 Merge "Add NetworkTemplateTest to common test for cts coverage" 2022-05-03 07:01:55 +00:00
Mark Chien
e470dac462 Merge "Fix ConnectivityManager memory leak" am: 8e3b96b61f am: 4d8cf6676c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2076481

Change-Id: I5824a3dc5fb3a37cd2dac51054b3a7ef4bf86bb7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-03 05:42:23 +00:00
Mark Chien
14921d65d5 Merge "Add a test to identify memory leak in ConnectivityManager" am: 15b83ab323 am: a00d1c34f2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2076480

Change-Id: Ibe3673064e0fc4d83d68e57bfcffa8bedc5c27c2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-03 05:41:47 +00:00
Mark Chien
8e3b96b61f Merge "Fix ConnectivityManager memory leak" 2022-05-03 02:46:05 +00:00
Mark Chien
15b83ab323 Merge "Add a test to identify memory leak in ConnectivityManager" 2022-05-03 02:43:24 +00:00
Treehugger Robot
2d30a274d9 Merge "Follow-up 2076940: Allow device owner to configure profile network preference " am: a14bd2a032 am: 82e76fab0a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2083405

Change-Id: I6e6f284076e1eb4de8dc09b7eebdbf2eff19ae95
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-02 15:49:56 +00:00
Treehugger Robot
a14bd2a032 Merge "Follow-up 2076940: Allow device owner to configure profile network preference " 2022-05-02 15:00:55 +00:00
Vadim Caen
baade1ca1e Follow-up 2076940: Allow device owner to configure profile network preference
https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2076940

Fixes build failure


Bug: 231104107
Test: tests/unit/java/com/android/server/ConnectivityServiceTest.java
Change-Id: I7b6a3880ce0b0b9ad6fc6aa7a5fd4e249bb1606d
2022-05-02 09:22:32 +00:00
Sooraj Sasindran
19f11ae93c Merge "Allow device owner to configure profile network preference" am: 07a20408db am: 87f4d52d9f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2076940

Change-Id: I3c170a47f89bfe87cacdc7332cb318b63c05d5a0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-02 07:43:12 +00:00
Sooraj Sasindran
07a20408db Merge "Allow device owner to configure profile network preference" 2022-05-02 07:13:21 +00:00
Sooraj Sasindran
bb65aa8fc2 Allow device owner to configure profile network preference
isMangedProfile returns true for managed profiles.
But enterprise device can be fully managed like device owner.
Hence check specifically if request is coming on fully managed
device.

Bug: 226966328
Bug: 231071836

Test: ran DevicePolicyManager CTS and ConnectivityServiceTest
Change-Id: I7827466bd61e24ba9c36c3a2e25043257e2ed602
2022-05-01 21:20:36 -07:00