Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
Clean up BpfNetMaps
Cleans up BpfNetMaps.java before enabling mainline code path.

Bug: 202086915
Test: atest FrameworksNetTests
Change-Id: I28e5d63ed4624df540b1ca47b71899cff7321ded

Ken Chen   authored and   Patrick Rohr   commited 2022-02-01 12:31:03 +01:00
f5f51339af
Merge changes Ifd6be50a,I857e40c9,I1b9f4fde,Ib3b43cf2
* changes:
  Prevent native_init from starting TrafficController
  Remove libutils dependency from libservice-connectivity
  Merge libtraffic_controller_jni into libservice-connectivity
  [NETD-TC#15] Make ConnectivityService and PermissionMonitor calls BpfNetMaps on T

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-02-01 03:02:36 +00:00
76709a18e9
[NETD-TC#15] Make ConnectivityService and PermissionMonitor
calls BpfNetMaps on T

Since TrafficController moves to mainline module for T, so some netd binder
interfaces revelant to BPF are going to deprecated. Provide JNI APIs to
call TrafficController inside mainline module for T.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: Ib3b43cf2840e02806395af9f1e019ca6fccd032e

Wayne Ma   authored and   Patrick Rohr   commited 2022-01-31 09:19:08 +01:00
2fde98c87b
Send access UIDs to netd
Test: FrameworkNetTests CtsNetTestCases
Change-Id: I8301abaddf5850071fa23d41e8e736ab7071e299

Chalard Jean   commited 2022-01-31 17:04:58 +09:00
e6c9527554
Add accessUids to NetworkCapabilities.
For now, all entry points reject this. Followup changes
will allow the supported use cases.

Test: new unit tests and CTS for this in this patch
Change-Id: I7262811a2e46336d3bb63c80886fc0578a36da94

Chalard Jean   commited 2022-01-31 17:04:58 +09:00
9a30acf744
Clean up restrictions on network agent capabilities
This is a no-op change.

Test: FrameworkNetTests

Change-Id: I658e579bf49e1baf57a8aeaabc8d07d7d3293c56

Chalard Jean   commited 2022-01-31 17:04:56 +09:00
1522857564
Sanitize NetworkCapabilities from agent on the handler thread
NetworkAgents send NetworkCapabilities to ConnectivityService but
there are limits to what exactly they can send. Going forward,
some of these checks will have to happen on the handler thread,
which is already the case when an agent updates its capabilities,
but not upon registration.

This patches moves the sanitization on the handler thread, after
the network monitor is created for a network agent.

Before this patch, upon registration of a new agent, the binder
thread would copy and sanitize the capabilities, then store them
in nai.networkCapabilities. It would store the original caps from
the agent in the NAI, mix in what is known from the network info,
process the LinkProperties, and then proceed to create the
network monitor, but not yet store the NAI in the internal
structures because its registration is not finalized, so other
methods should not see it yet. After the monitor is created in
the network stack process, the NAI is stored in the internal
structures which publishes it for all methods to see. After
that is done, the NAI calls to the network monitor to warn it
that it's registered, what its capabilities are, and that it's
time to start validation if applicable.

With this patch, the validation no longer happens on the binder
thread. Instead, the binder thread stores the capabilities and
link properties as is, before sanitization, in the NAI. This is
fine because no other method can access these until the
registration completes upon notification that the monitor has
been created ; this agent is only stored in the network monitor
callbacks in a self-destructing object precisely to make sure
that's the case.
When the monitor is created and CS receives notification of the
same, it will sanitize the capabilities before adding the NAI
to the internal structures, to protect the invariant that the
un-sanitized capabilities inside the NAI can't ever be seen by
any other method. After that's done, it will call to the
monitor to start validation as usual.

Test: FrameworksNetTests CtsNetTestsCases
Change-Id: I7d43ef0e25955e0349903b4801b9dfd8c3c92586

Chalard Jean   commited 2022-01-31 17:04:46 +09:00
366c525b15
Allow Carrier app to request for CBS capability
Test: unit test and CTS
Bug: 194332512
Change-Id: I29680b56d790106ad082f1a398c2bddb030f834a

Sooraj Sasindran   commited 2022-01-30 12:12:17 -08:00
e9cd2084e4
Don't enable DscpPolicyTracker on pre-T devices.
The code cannot work before T because before T the tethering
module can only load BPF programs/maps into /sys/fs/tethering/bpf
and the system server cannot access that directory.

Additionally, this is causing unit tests to fail on pre-T devices
because on those devices the seccomp filter blocks the bpf
syscall from apps (including Java tests).

Test: revert aosp/1907693 and atest FrameworksNetTests:ConnectivityServiceTest
Change-Id: I6c398031dffb840da1d723b11ea4d0845ad6c6f2

Lorenzo Colitti   commited 2022-01-27 14:16:49 +00:00
debd9eaffa
Process DSCP QoS events for policies
New events to handle adding and removing of DSCP QoS policies.
Async indication sends status back to client if the policy
has been added, failed, or if the policy limit has been
reached.

Bug: 202871011
Change-Id: I7988d22ae625ad0dd415927d2943de4a749e6fb8

Tyler Wear   authored and   Patrick Rohr   commited 2022-01-27 10:19:27 +00:00
723882126a
Merge "Send exclude local routes value to netd for VPN network"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-01-26 02:09:35 +00:00
317be96553
Add support for Multiple enterprise slice
Bug: 194332512
Test: unit test
CTS-Coverage-Bug: 211133973
Change-Id: Ie8be08a7cfa9155168d1da146d02fd1643248bdc

Sooraj Sasindran   commited 2022-01-22 14:39:40 -08:00
f4a58dcd45
Ability to specify which all applications fall under enterprise slice.
Bug: 194332512
Test: unit test
Change-Id: I94549a41aaa717add22b0a3e5035beacf6f1b8f2

Sooraj Sasindran   commited 2022-01-21 01:05:12 -08:00
499117f279
Send exclude local routes value to netd for VPN network
Bug: 184750836
Test: atest FrameworksNetTests
Change-Id: I40ce741b6e918db7bf62cb5f29d9be1b16a94902

Chiachang Wang   commited 2022-01-18 17:45:30 +08:00
9164c10b67
Merge "Add swapActiveStatsMap API for NetworkStatsFactory"
Mark Chien   authored and   Gerrit Code Review   commited 2022-01-14 05:35:25 +00:00
21f0d58294
Merge "Add replaceFirewallChain API"
Mark Chien   authored and   Gerrit Code Review   commited 2022-01-14 05:33:58 +00:00
094de6b7c4
Merge "Add setFirewallChainEnabled API"
Mark Chien   authored and   Gerrit Code Review   commited 2022-01-14 05:33:38 +00:00
9bba8e8c78
Merge "Add updateFirewallRule API"
Mark Chien   authored and   Gerrit Code Review   commited 2022-01-14 05:33:22 +00:00
c65ecacd6f
Add swapActiveStatsMap API for NetworkStatsFactory
This CL should be reverted before T sdk finalized.
This API is temporary added for the NetworkStatsFactory which is platform
code but will be moved into connectivity (tethering) mainline module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: I5894450f3089b2ea105722a18ddf8f1eed1c28a0

markchien   commited 2022-01-14 10:23:26 +08:00
9c8061134c
Add replaceFirewallChain API
To deprecated firewallReplaceUidChain netd binder and move the
functionality to tethering (connectivity) mainline module, expose
replaceFirewallChain to support the caller outside the module.
Currently the API are still call to netd. Will replace with the
implementation inside tethering (connectivity) module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: If7a87548b0a3acda00a1455da4e4ff24a630ddc7

markchien   commited 2022-01-14 10:23:21 +08:00
00a0bed534
Add setFirewallChainEnabled API
To deprecated firewallEnableChildChain netd binder and move the
functionality to tethering (connectivity) mainline module, expose
setFirewallChainEnabled to support the caller outside the module.
Currently the API are still call to netd. Will replace with the
implementation inside tethering (connectivity) module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: I9b64c9d12260521489a87fbeae5afbee2a8ea8f6

markchien   commited 2022-01-14 10:23:15 +08:00
98a6f95d0f
Add updateFirewallRule API
To deprecated firewallSetUidRule netd binder and move the functionality to
tethering (connectivity) mainline module, expose updateFirewallRule to
support the caller outside the module. Currently the API are still call
to netd. Will replace with the implementation inside tethering
(connectivity) module.

Bug: 209935649
Test: atest CtsHostsideNetworkTests
Change-Id: I0b53c999e06c2378afec0eb491815ec398c91b0b

markchien   commited 2022-01-14 10:19:51 +08:00
e1561fa800
Merge "Ability for DPM to specify fallback mechanism"
Sooraj Sasindran   authored and   Gerrit Code Review   commited 2022-01-13 17:24:07 +00:00
226131ab48
Merge "Add updateMeteredNetwork{Allow, Deny}List APIs"
Mark Chien   authored and   Gerrit Code Review   commited 2022-01-13 08:21:03 +00:00
136f2d2d91
Ability for DPM to specify fallback mechanism
Bug: 194332512
Test: unit test
Change-Id: Id4d85da8f64e7559326c4657b8833dac3ce5ce3d

Sooraj Sasindran   commited 2022-01-13 06:07:36 +00:00
06baf4cfa1
Merge "Add a method to apply a set of network preferences to a user profile"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-01-13 04:08:34 +00:00
296a343528
Add a method to apply a set of network preferences to a user profile
Add a method to apply a set of network preferences to a user profile

Bug: 194332512
CTS-Coverage-Bug: 211133973
Test: CTS
Change-Id: I97730ea14e7c96922236fd77a591e5acadd875ba

Sooraj Sasindran   commited 2022-01-11 21:07:23 -08:00
e7aee2736e
Add excludeLocalRoutes in NativeNetworkConfig
Add extra field in NativeNetworkConfig to allow CS to notify
netd whether the local traffic should be excluded from the VPN
network.

Bug: 184750836
Test: atest FrameworksNetworkTests
Change-Id: If230fe7057722c80a09433673ac3cec857f7a7a5

Chiachang Wang   commited 2022-01-11 11:33:44 +08:00
bf6b879b55
Add updateMeteredNetwork{Allow, Deny}List APIs
To deprecated below netd binder interfaces and move the functionality to
tethering(connectivity) mainline module:
  bandwidthAddNaughtyApp
  bandwidthRemoveNaughtyApp
  bandwidthAddNiceApp
  bandwidthRemoveNiceApp
Expose updateMeteredNetwork{Allow, Deny}List APIs to support the caller
outside the module. Currently the two APIs are still call to INetd
binders. Once functionality is moved to mainline module, will switch to
use them.

Bug: 209935649
Test: m
Change-Id: I8df720935748c2587f91a7b760cfd5a93a0fa852

markchien   commited 2022-01-07 10:16:13 +08:00
738ad911c7
Update to ConnectivityService to use utils
Update to ConnectivityService to use permission utils to validate the
existence of a system feature.

Bug: 210485380
Test: atest FrameworksNetTests:
com.android.server.ConnectivityServiceTest

Change-Id: Ia537cc5b37ef8d80f49f1a83ba572b3b8a9f6874

James Mattis   commited 2022-01-05 09:15:24 -08:00
4ab1ffca29
Genericize NC#hasSameUids
This will be used by another set of UIDs in a future patch

Test: FrameworksNetTests
Change-Id: I2c5d18ef93e73b702723814592ef3f3baf5dfbc4

Chalard Jean   commited 2021-12-16 23:03:42 +09:00
f4802fa4c2
Merge "Enable strict_updatability_linting in connectivity src" am: 81bc609550
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1902533

Change-Id: I5cf42aa64a838f711cd1ecc589f86aecb19b358f

Chiachang Wang   authored and   Automerger Merge Worker   commited 2021-12-08 02:53:16 +00:00
e5c363a3bd
Enable strict_updatability_linting in connectivity src
Bug: 188851968
Test: m lint-check
Change-Id: I3cd06ea16f05cb37d9369a48dd0285d8239fd764

Chiachang Wang   commited 2021-11-26 10:31:58 +08:00
3bc5276568
Merge sc-qpr1-dev-plus-aosp-without-vendor@7810918
Bug: 205056467
Merged-In: I745ef4d42ecaf06bb81d9dbe0b7162267fea65a8
Change-Id: I7b2a1fc519124cfc10806dde5fd543504a51e072

Xin Li   commited 2021-11-10 08:06:18 +00:00
e41bbea995
Don't rematch all requests when adding new ones
With the network selection rewrite in S, rematching a single request can
now easily be done; this can be used as an optimization in
handleRegisterNetworkRequests to avoid rematching all requests when
registering a new one.

This can be disabled by a flag that is unset by default,
REMATCH_ALL_REQUESTS_ON_REGISTER.

Test: atest ConnectivityServiceTest
Change-Id: If76f79b41ac88863974f7025624667134bea2570

Remi NGUYEN VAN   commited 2021-11-08 19:17:57 +09:00
959d2cb6bd
Improve logs in checkNrisConsistency
Test: ConnectivityServiceTest
Change-Id: If5235443217ad4abbdd40e89d5721d4f7832d52f

Chalard Jean   commited 2021-10-28 12:45:12 +09:00
ba551d4dbb
Apply a workaround, and try to detect a system crash
This will prevent the system crash in b/194394697, and on T try to
detect the issue much earlier and crash the system at that time
together with much more expansive logs.

Bug: 194394697
Test: ConnectivityServiceTest
Change-Id: Ia4be82179160216d41bf4d88b896e4814385063a

Chalard Jean   commited 2021-10-27 16:00:56 +09:00
524f0b1d7f
Merge "No-op cleanup"
Chalard Jean   authored and   Gerrit Code Review   commited 2021-10-26 02:39:47 +00:00
e88bfbc015
No-op cleanup
Binders from the system server don't help, because if the process
dies there is nobody to listen to its binder deaths.

Test: ConnectivityServiceTest
Change-Id: I993cb9481edfaeb652b875be7f90166db16d0e1d

Chalard Jean   commited 2021-10-25 19:24:48 +09:00
a3578a5465
Add underlying networks into NetworkAgentInfo if any
Now, VPN will set underlying networks into NetworkCapabilities
directly. So the declaredUnderlyingNetworks can also be set
directly when creating a NetworkAgentInfo.

Bug: 191918368
Test: atest FrameworksNetTests:ConnectivityServiceTest
Change-Id: I507072d00ae1eb0c391e5261ab93e359b9c4cb5c

lucaslin   commited 2021-10-19 15:04:56 +08:00
6adf5ac19b
Merge "Update Permission only if the network is created"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-10-14 06:13:54 +00:00
29f0350da3
Merge "Stop using PerUidCounter#transact" am: a7db5ddda5 am: fe5e2742b6 am: 707437622a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1821293

Change-Id: I30d748c01fa05f05a02ee5ef8bbc721fc32eafae

Paul Hu   authored and   Automerger Merge Worker   commited 2021-10-04 14:23:49 +00:00
2541cf6d81
Merge "Stop using PerUidCounter#transact" am: a7db5ddda5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1821293

Change-Id: Icd1072ef5b8281fa54f71796e7eaa981b0fd943b

Paul Hu   authored and   Automerger Merge Worker   commited 2021-10-04 13:58:26 +00:00
fe5e2742b6
Merge "Stop using PerUidCounter#transact"
Paul Hu   authored and   Gerrit Code Review   commited 2021-10-04 13:48:07 +00:00
a7db5ddda5
Merge "Updating formatting and text for per-app dumpsys" am: 7ece4bb71e am: 3a44ebe9a1 am: 388ae1444f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723618

Change-Id: Iaac0cb2ec69b2335759f10787a3698c636b11753

Treehugger Robot   authored and   Automerger Merge Worker   commited 2021-10-03 06:32:52 +00:00
3fcefe8039
Merge "Updating formatting and text for per-app dumpsys" am: 7ece4bb71e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1723618

Change-Id: Id13fe82d772d51b935a86076b1b660f57b4f5032

Treehugger Robot   authored and   Automerger Merge Worker   commited 2021-10-03 06:11:23 +00:00
3a44ebe9a1
Merge "Ensure calling package name and uid are matched" into sc-qpr1-dev am: e93efb6f96
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15618365

Change-Id: I80aa5da33f8c4c5154a721ceec58852b6c2d42f1

TreeHugger Robot   authored and   Automerger Merge Worker   commited 2021-10-01 14:21:16 +00:00
0a2d680a4d
Updating formatting and text for per-app dumpsys
Fixing the indentation for dumpsys CONNECTIVITY for per app network
info. Also updated to more clearly show when the active network is
currently tagged to the "no service network" for configured apps so as
to more clearly show intent to dumpsys consumers. Finally, correctly
showing profile network preferences which weren't being shown
previously.

Prior formatting with no per-app networks:
Current per-app default networks: Per-App Network Preference:
    none

Updated formatting with no per-app networks:
Current network preferences:
  Default requests:

Prior formatting with active per-app networks ("none" is shown in this
case since profile network preferences weren't correctly displayed):
Current per-app default networks: Per-App Network Preference:
    none
  Is per-app network active:
    true
    Active network: 100
    Tracked UIDs:
      {1100000-1199999}

Updated formatting with active per-app networks:
Current network preferences:
  Profile preferences:
    [[ProfileNetworkPreference user=UserHandle{11} caps=[ Capabilities:
    INTERNET&TRUSTED&NOT_VCN_MANAGED&ENTERPRISE Uids:
    <{1100000-1199999}>]]]
  OEM preferences:
    OemNetworkPreferences{mNetworkMappings={android.net.cts=-1}}
  Mobile data preferred UIDs:
    mMobileDataPreferredUids: {1, 2, 3}
  Default requests:
    Request: [uid/pid:1000/1423] - Satisfier: [100] Preference order: 10
    Tracked UIDs:{1100000-1199999}

Bug: 189860802
Test: adb shell dumpsys connectivity
Change-Id: I5ed4bb83e9e5a4497f5019ab4e4c0f238989a246

James Mattis   commited 2021-09-30 11:47:36 -07:00
8b298a00b2
Stop using PerUidCounter#transact
PerUidCounter#transact is used to adjust the request counter for
the per-app API flows. Directly adjusting the counter is not
ideal however in the per-app flows, the nris can't be removed
until they are used to create the new nris upon set.

In fact, satisfiers are the info that new nris need reference.
Without satisfiers in new nris, the avaiable callbacks would be
sent to listeners agin when assign new satisfiers. Even the new
best networks are same as previous satisfiers, but the new nris
have lost those info if calling handleRemoveNetworkRequests()
before createPerAppCallbackRequestsToRegister().

However, removing satisfiers from nris is not necessary actually
because the CS will update the best network to nri when compute
network reassignment. It doesn't need to be cleared when
calling handleRemoveNetworkRequest(). Thus, keep that info and
adjust the sequence to remove nri first. The counter is still
correct and doesn't hit limit artificially.

Bug: 201648050
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I4cbc953def7866b23c2b8ebc8deaadf0ffc3b75d

paulhu   authored and   Paul Hu   commited 2021-09-30 15:35:53 +00:00
74128521ad
Update Permission only if the network is created
Reproduction steps:

- Register a NetworkAgent but don't mark it as connected.
- Set teardownDelayMs for the NetworkAgent to 100
- Unregister the NetworkAgent then see system crashed.

Tests:

- Builds, Boots
- ConnectivityServiceTest

Change-Id: Ib8e517acb0193a2454d672612fe61fc199de46a4
Bug: 200023207

Pavan Kumar M   commited 2021-09-29 12:37:42 +00:00
be994246f4