Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
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>

Sooraj Sasindran   authored and   Automerger Merge Worker   commited 2022-05-12 00:56:06 +00:00
95aa795f56
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>

Paul Hu   authored and   Automerger Merge Worker   commited 2022-05-12 00:55:45 +00:00
0554b3e11b
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
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 "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>

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2022-05-09 14:26:47 +00:00
784d9b492c
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
Merge "Update VPN isolation code for excluded routes" am: a1c6dbbd53 am: 1c0a2da4f8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2078859

Change-Id: Ib62edcdb18eb132ec96501848c3ce21caefcd160
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Prerana Patil   authored and   Automerger Merge Worker   commited 2022-05-03 18:35:15 +00:00
7caa3b8bba
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
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>

Sooraj Sasindran   authored and   Automerger Merge Worker   commited 2022-05-02 07:43:12 +00:00
19f11ae93c
Merge "Allow device owner to configure profile network preference"
Sooraj Sasindran   authored and   Gerrit Code Review   commited 2022-05-02 07:13:21 +00:00
07a20408db
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

Sooraj Sasindran   commited 2022-05-01 21:20:36 -07:00
bb65aa8fc2
Update VPN isolation code for excluded routes
Bug: 230058738
Test: atest LinkPropertiesTest

Result: https://paste.googleplex.com/4706859672928256

Change-Id: I970fca6b0e2cd358e9bd77152563d13367867c74

Prerana   authored and   Prerana Patil   commited 2022-04-29 22:23:02 +00:00
2b97bbebf4
Merge "ClatCoordinator: dump BPF forwarding rules" am: 722346dce4 am: 50b8e0ebd3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2017317

Change-Id: Ie2c13972bb9d4f54b4d874177b4d7bfda2835856
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Treehugger Robot   authored and   Automerger Merge Worker   commited 2022-04-27 17:55:08 +00:00
7f0d9d7351
Merge "ClatCoordinator: dump BPF forwarding rules"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-04-27 14:54:16 +00:00
722346dce4
ClatCoordinator: dump BPF forwarding rules
This is a preparation for moving clat map dump from netd to
mainline module.

Test: compare dumpsys connectivity and netd

$ adb shell dumpsys connectivity
Nat464Xlat:
  ClatCoordinator:
    Forwarding rules:
      BPF ingress map: iif nat64Prefix v6Addr -> v4Addr oif
        47 /64:ff9b::/96 /2a00:79e1:abc:6f02:4aac:17dd:b40e:8bcc -> /192.0.0.4 52
      BPF egress map: iif v4Addr -> v6Addr nat64Prefix oif
        52 /192.0.0.4 -> /2a00:79e1:abc:6f02:4aac:17dd:b40e:8bcc /64:ff9b::/96 47 ether

$ adb shell dumpsys netd
ClatdController
  BPF ingress map: iif(iface) nat64Prefix v6Addr -> v4Addr oif(iface)
    47(wlan0) 64:ff9b::/96 2a00:79e1:abc:6f02:4aac:17dd:b40e:8bcc -> 192.0.0.4 52(v4-wlan0)
  BPF egress map: iif(iface) v4Addr -> v6Addr nat64Prefix oif(iface)
    52(v4-wlan0) 192.0.0.4 -> 2a00:79e1:abc:6f02:4aac:17dd:b40e:8bcc 64:ff9b::/96 47(wlan0) ether

Change-Id: I597709663477b62005b0bc5cc1bf0fc22743e10b

Hungming Chen   authored and   Nucca Chen   commited 2022-04-26 06:44:14 +00:00
707675511a
adjust for new T bpfloader net_shared location am: 0736d7bd91 am: 2d59dc9854
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2071008

Change-Id: I1c90acd36a7105fcf9997c08443d3b624d487f76
Ignore-AOSP-First: this is an automerge
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Å»enczykowski   authored and   Automerger Merge Worker   commited 2022-04-23 09:56:36 +00:00
d560797e5e
adjust for new T bpfloader net_shared location
(this is safe because on pre-T none of these maps and programs are mainlined
 and thus safe to access from mainline code anyway)

Test: TreeHugger, manual
Bug: 218408035
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I23e565d665247f33e084978890a1ee8ffe0fe568

Maciej Å»enczykowski   commited 2022-04-23 09:03:06 +00:00
0736d7bd91
Merge "Remove UserId from UID when checking against BLUETOOTH_UID" am: 64ac247056 am: f271aed404
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2065564

Change-Id: Ie54acb1363d96fdfcec25656cf09ff2c90feda4a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Lorenzo Colitti   authored and   Automerger Merge Worker   commited 2022-04-22 07:50:28 +00:00
dfcab7ca28
Merge "Remove UserId from UID when checking against BLUETOOTH_UID"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2022-04-22 06:51:41 +00:00
64ac247056
Merge "[CLATJ#27] Use ClatdCoordinator since T+ devices" am: b4bf6cea38 am: 8d75a93995
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1951099

Change-Id: I3878e5359349d8195e8741ea69ae437edab68909
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Å»enczykowski   authored and   Automerger Merge Worker   commited 2022-04-21 14:34:12 +00:00
2fadc5413c
[CLATJ#27] Use ClatdCoordinator since T+ devices
- For clatd start and stop, use ClatdCoordinator on T+ and Netd on S-
- Fix the unit test for T+ and S- devices
  Note that mokito.verify(.., times(1)) is replaced by verify(..)
  because times(1) is the default and can be omitted.
  See verify in mockito/src/main/java/org/mockito/Mockito.java

Note that this commit needs to be merged with aosp/1956072.

Bug: 212345928
Test: atest FrameworksNetTests
      manual test
      1. Connect to ipv6-only wifi.
      2. Try IPv4 traffic.
         $ ping 8.8.8.8
      3. Check bpf entries are added
      4. Disconnect from ipv6-only wifi.
      5. Check bpf entries are removed
      6. testipv4.com shows 10/10

Change-Id: I7dfda6eec19de94e4258971effcd8a1210542473

Hungming Chen   commited 2022-04-21 13:24:36 +08:00
eb15a2d816
Remove UserId from UID when checking against BLUETOOTH_UID
A UID can be a concatenation of a UserID with a 5 digit package UID.
E.g., Bluetooth under User10 would have UID 1001002. This CL removes the
UserID (if any), before checking against BLUETOOTH_UID.

Bug: 228598338
Test: m
Change-Id: I532583345cc9ab474fc848a3ede6be9d8be9c5b0

Andrew Cheng   commited 2022-04-20 18:27:23 +00:00
2ae5c735b6
Merge "Improve dumpsys logs for NetworkProvider and NetworkOffer" am: 58f5b1a89e am: 7bc11250bd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2067234

Change-Id: I4cc65e510fcc39ae4e9da0c6821b0ac5f8a97195
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Junyu Lai   authored and   Automerger Merge Worker   commited 2022-04-20 11:27:41 +00:00
b540407e4b
Improve dumpsys logs for NetworkProvider and NetworkOffer
It will look like below:

NetworkProviders for:
  2: WIFI_AWARE_FACTORY
  1: Ethernet

Network Offers:
  NetworkOffer [ Provider Id (1) Score(...) Caps [...] Needed by [1, 2, 3]]
  NetworkOffer [ Provider Id (2) Score(...) Caps [...] Needed by [4, 5, 6]]

Test: manual
Bug: 227408533
Change-Id: I84cb03757877d7127d39c359010c8092a8ca87d9

Junyu Lai   commited 2022-04-20 15:55:09 +08:00
0da479b280
Fix permission bypass problem for Tethering deprecated APIs
Since the tethering functions in ConnectivityService is delegated
to TetheringManager instance and get caches informataion in
TetheringManager without checking ACCESS_NETWORK_STATE permission.
If application use reflection call getTetherXXX functions in
ConnectivityService, it can get tethering status with no additional
execution privileges needed.

Bug: 162952629
Test: manual
Ignore-AOSP-First: security fix
Change-Id: I5b897f216db19fead6ba6ac07915aa0f6ff5bf42

markchien   commited 2022-04-19 19:13:10 +08:00
28160b3141
Add IPv6 Handling for DSCP Policies and Support Interfaces with MAC Addresses
Add bpf functionality to handle IPv6 packets and apply
DSCP value.
Also support DSCP policy rules on multiple interfaces
simultaneously.

Test: atest DscpPolicyTest

Bug: 217166486
Change-Id: I452a87355fd0382a4c38b84aa3465505951d9bf0

Tyler Wear   commited 2022-04-15 07:53:51 -07:00
3ad8089d19
Allow the bluetooth UID to register network factories.
This ensures that bluetooth can register bluetooth tethering
NetworkAgents without having to make NETWORK_FACTORY a privileged
or role permission.

Test: m
Bug: 221949454
Change-Id: I24a5da444b10dde740c1e449c8630de56946d4e1

Lorenzo Colitti   commited 2022-04-06 11:15:12 +09:00
d12af7ebfe
Merge "Add @RequiresPermission for setUnderlyingNetworks"
Lucas Lin   authored and   Gerrit Code Review   commited 2022-03-29 15:34:17 +00:00
41ed965e68
Api review: change updateFirewallRule to setUidFirewallRule
Bug: 218494748
Test: TH

Change-Id: I52a02ebe109b687359f579c16fded4af3c9cd242
Merged-In: I52a02ebe109b687359f579c16fded4af3c9cd242

markchien   commited 2022-03-25 18:49:08 +08:00
3c04e66da0
Rename destroyAndAwaitReplacement to unregisterAfterReplacement.
Rename requested by API council.

Fix: 224764301
Test: existing CTS tests updated
Change-Id: Ibab9c9cd64bf0dde1e22705e81cff11d356fc719

Lorenzo Colitti   commited 2022-03-24 01:12:26 +09:00
a63e2341d6
Add @RequiresPermission for setUnderlyingNetworks
setUnderlyingNetworks() is mainly for the NetworkAgents who hold
the NETWORK_FACTORY to set its underlying networks.

And the underlying networks are only visible and useful for the
caller of getNetworkCapabilities() or the receiver of
onCapabilitiesChanged() who hold one of NETWORK_FACTORY,
NETWORK_SETTINGS and MAINLINE_NETWORK_STACK permissions.
Otherwise, the underlying networks field will be cleard before
sending.

Bug: 205738644
Test: atest CtsNetTestCases:ConnectivityManagerTest
      atest CtsHostsideNetworkTests:HostsideVpnTests
      atest FrameworksNetTests
Change-Id: Ife7630d9676a31ee5ab977cb1b87aec3b6fd7080

lucaslin   commited 2022-03-22 18:15:09 +08:00
69e1aa9117
Allow sending of Administrator UIDs for *NETWORK_STACK
This change allows callers with the NETWORK_STACK or
PERMISSION_NETWORK_STACK to receive administrator UIDs. This will be
used by the VCN to ensure that administrator UIDs are accurately
populated, ensuring that the ConnectivityDiagnostics are triggered for
the VCN.

Bug: 193204385
Test: atest ConnectivityServiceTest
Change-Id: I3ecfbef6847dcc78adac05d0229719c97e3a220c

Benedict Wong   commited 2022-03-18 21:52:57 +00:00
a5604ea50f
Merge "Support ignoring validation failures after roam."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2022-03-18 03:15:49 +00:00
004cbbcdad
Support ignoring validation failures after roam.
In some scenarios, Wi-Fi connectivity is disrupted after roam. If an application reacts to network errors by calling reportNetworkConnectivity(false), validation will immediately fail and the device will switch to cell data.

Add a way to ignore these validation failures for up to 10 seconds after Wi-Fi roams.

Bug: 216567577
Test: new unit tests

Change-Id: I58de486533bcc7c6e32b23536ae15bccb779e394

he_won.hwang   commited 2022-03-18 10:30:28 +09:00
881307a834
Rename setAccessUids to setAllowedUids
Bug: 217725769
Test: ConnectivityServiceTest CtsNetTestCases
Change-Id: Ic8a3f91553d1462b7f54259c467fb90a950bdd59
Merged-In: I8860fbb353eedf5d01e9dc248e4d765046bd562c

Chalard Jean   authored and   Sooraj Sasindran   commited 2022-03-16 17:58:20 +00:00
de665266cd
Merge "Use int array for included and excluded uids"
Sooraj Sasindran   authored and   Gerrit Code Review   commited 2022-03-16 17:56:08 +00:00
2ccbfe9d8f
Merge changes from topic "ethernet_mainline"
* changes:
  Fix the NPE thrown when starting Ethernet service in OS lower than T.
  Remove the stub ethernet service from Connectivity module.
  Update hidden API files for EthernetManager API move.
  Provide a stub ethernet service to build in sc-mainline-prod.
  Build ethernet framework source into framework-connectivity-tiramisu

Patrick Rohr   authored and   Gerrit Code Review   commited 2022-03-16 16:03:30 +00:00
6dde8ac532
Use int array for included and excluded uids
Use int array for included and excluded uids so that uses
same data type as in PreferentialNetworkServiceConfig

Bug: 217365439
Test: ran connectivity service unit tests
Change-Id: I9ac7e6498df2fd20b8397b2c110296e019c7389e

Sooraj Sasindran   commited 2022-03-16 07:19:11 +00:00
4904176454
Merge "Add a NetworkAgent API to indicate that a network will be replaced."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2022-03-15 04:44:16 +00:00
9f6e6c4e27
Build ethernet framework source into framework-connectivity-tiramisu
- move ethernet APIs, build it into framework-connectivity-tiramisu
- start ethernet service from ConnectivityServiceInitializer
- fix EthernetManager dependnecy in Tethering module
- fix EthernetNetworkSpecifier dependency in framework-connectivity
- fix the ethernet related config resource

Bug: 210586283
Test: m
Test: atest FrameworksNetTests EthernetServiceTests
Change-Id: I54857b8517649048a343c72797668394d5225766
Merged-In: I54857b8517649048a343c72797668394d5225766

Xiao Ma   commited 2022-03-14 14:06:35 +00:00
0a171c006c
Add a NetworkAgent API to indicate that a network will be replaced.
This is useful for link layers that disconnect but know they will
reconnect to a similar network soon, and do not want the device
to switch to another network until the reconnect happens. An
example is wifi switching to another network that is on a
different subnet without the device switching to cellular data.

This works by immediately destroying the network, so the link
layer can reuse the same interface name for the new network. It
would be possible to delay destroying the network until the new
network connects, but in practice this does not seem useful,
because the if the link layer reuses the interface, then the
interface will be undergoing reconfiguration, and will likely
not be usable for app traffic.

This CL also moves the call to onNetworkDestroyed into
destroyNativeNetwork. This is needed to ensure that the new
API calls onNetworkDestroyed even though most teardown
operations have not happened. This causes onNetworkDestroyed to
happen before the netId is marked free, but that shouldn't cause
any behavioural changes because netId allocation is an
implementation detail of ConnectivityService and is not
observable by apps or system components.

Bug: 216567577
Test: builds, boots
Test: atest FrameworksNetTests FrameworksNetIntegrationTests
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCases:android.net.cts.NetworkAgentTest#testDestroyAndAwaitReplacement
Change-Id: I9f9e022fef66b31a29cce560413321075e992756

Lorenzo Colitti   commited 2022-03-14 21:52:37 +09:00
ffa2ed3d1c
Merge "Rename redactNetworkCapabilitiesForPackage and update its javadoc"
Lucas Lin   authored and   Gerrit Code Review   commited 2022-03-14 08:05:08 +00:00
ba61dca57c
Merge "Remove ConnectivityManager swapActiveStatsMap API"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-03-08 06:31:23 +00:00
5635d505e0
Merge "Don't attempt to enable rate-limiting before T."
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-03-07 15:51:32 +00:00
33f4e14073
Merge "Remove dead code in BpfNetMaps."
Mark Chien   authored and   Gerrit Code Review   commited 2022-03-07 15:19:25 +00:00
e06458378d
Don't attempt to enable rate-limiting before T.
Rate-limiting cannot work because the BPF program is in the
mainline version of netd.c, which is placed into net_shared
and thus cannot run pre-T.

Disable it entirely to ensure no impact on S.

Test: atest ConnectivityCoverageTests:com.android.server.ConnectivityServiceTest on AOSP
Test: atest ConnectivityCoverageTests:com.android.server.ConnectivityServiceTest on S
Change-Id: I47521a100f8287ecdece25e810db8f3cade46778

Lorenzo Colitti   commited 2022-03-07 12:21:40 +00:00
f79dcecf9b
Remove dead code in BpfNetMaps.
Most of the methods in BpfNetMaps are only used on T+ devices,
where BpfNetMaps never calls into netd. Remove the code in these
methods that calls into netd, because that code can never run.
The code was only written in the first place because it was
necessary when TrafficController had not yet moved to mainline.

The list of methods is:
- addNaughtyApp
- removeNaughtyApp
- addNiceApp
- removeNiceApp
- setChildChain
- replaceUidChain
- setUidRule

Test: treehugger
Change-Id: Ie7d210be2f7983178f5aa550370b9476de66e988

Lorenzo Colitti   authored and   markchien   commited 2022-03-07 12:56:18 +08:00
82244fd16c