Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
Do not enable ingress rate limit until clsact qdisc exists
The tc police filter attaches to the clsact qdisc, so the rate limit
cannot be enabled before the qdisc is added to the interface.
The clsact qdisc is added as part of INetd#networkAddInterface, which is
called from inside updateLinkProperties.

Test: atest FrameworksNetTests:ConnectivityServiceTest
Change-Id: I0713605ff3684f8271eb3f0e29ab7116561963f1

Patrick Rohr   commited 2022-03-02 20:41:13 +01:00
f1fe8ee928
Merge "Rename one of the two EVENT_NETWORK_TESTED messages."
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-02-21 00:22:11 +00:00
4b654c9038
Merge "reduce log level when no interface is present for rate limiting"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-02-19 21:31:05 +00:00
19ce06b05f
Rename one of the two EVENT_NETWORK_TESTED messages.
Currently, there are two EVENT_NETWORK_TESTED message types in
ConnectivityService. One is used by the ConnectivityService
handler to process validation results, and one is used by
ConnectivityDiagnosticsHandler to send connectivity reports.

The two messages have different contents so it is confusing that
they have the same integer and the same name. Rename the second
one to CMD_SEND_CONNECTIVITY_REPORT.

Test: atest ConnectivityServiceTest
Test: atest CtsNetTestCases:android.net.cts.ConnectivityDiagnosticsManagerTest
Change-Id: I77d63dad477315e1fcc7225a5ef03aff2bed8c35

Lorenzo Colitti   commited 2022-02-19 02:24:02 +09:00
0261ced634
reduce log level when no interface is present for rate limiting
TestNetworkAgentWrapper does not set the interface name in its
LinkProperties causing logwtf to fail tests on -eng build.

Test: atest FrameworksNetTests:ConnectivityServiceTest on -eng build
Change-Id: Ieba0453ce897aa1052cb98f1de4c7bb099383c8d

Patrick Rohr   commited 2022-02-18 09:18:20 +01:00
a517f20ef0
Merge "Support "dumpsys connectivity trafficcontroller""
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-02-17 23:10:10 +00:00
bce8cbabbb
Merge changes Iddd50583,I7e6e84ba,If5ade0c0
* changes:
  Improve logging when using ingress rate limits
  Allow test networks to be rate limited
  Fix rate limiting settings observer

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-02-17 22:14:04 +00:00
c301b4412b
Improve logging when using ingress rate limits
Add some happy path logging that informs about active rate limits.

Test: TreeHugger
Bug: 218840346
Change-Id: Iddd50583ca2e90afe83a5c68611418fa794afb3f

Patrick Rohr   commited 2022-02-17 18:28:58 +01:00
64592df482
Allow test networks to be rate limited
Test: atest FrameworksNetTests
Change-Id: I7e6e84baf446ecf4b395f6a611e625871745a20e

Patrick Rohr   commited 2022-02-17 18:28:58 +01:00
ff3b3f8d96
Fix rate limiting settings observer
The obvserver accidentally observed Settings.Secure instad of
Settings.Global.

Test: atest CtsNetTestCases:RateLimitTest
Bug: 218840346
Change-Id: If5ade0c0e269c01b76428d5635d0913330d7015e

Patrick Rohr   commited 2022-02-17 18:28:58 +01:00
cdac749eb0
Ensure all NetworkMonitor messages store the netId in arg2.
All NetworkMonitor messages contain the netId of the source
NetworkMonitor. But the netId is in various places in the
message. It's most frequently in arg2, but sometimes it's boxed
into an Integer in obj, and sometimes it's in another object.

Always pass the netId into arg2. This allows us to write
common code at the beginning of the function that extracts the
netId and nai, and performs common actions on all messages.

Bug: 216567577
Test: atest FrameworksNetTests FrameworksNetIntegrationTests
Test: atest CtsNetTestCases:ConnectivityManageTest
Test: atest CtsNetTestCases:NetworkAgentTest
Change-Id: Idbbe3cddfc5475a2d56df387f840439dc4c9514c

Lorenzo Colitti   commited 2022-02-18 00:28:01 +09:00
d1b11dc70f
Support "dumpsys connectivity trafficcontroller"
Enable ConnectivityService to dump BPF maps from libtraffic_controller.

Bug: 202086915
Test: adb shell dumpsys connectivity trafficcontroller
Test: atest CtsNetTestCases:ConnectivityManagerTest#testDumpBpfNetMaps
Test: run CTS in I021789813f116940d581e2c4a1fd357ff47bfa08
Change-Id: Ib0e935ee2b714ac61daceba6d13fa7a20f97f68f

Ken Chen   commited 2022-02-17 16:58:47 +08:00
e6d511f785
Merge "Add new methods to redact NetworkCapabilities & LinkProperties"
Jean Chalard   authored and   Gerrit Code Review   commited 2022-02-12 11:56:36 +00:00
d537aa42e1
Add new methods to redact NetworkCapabilities & LinkProperties
Some system components like VPN need to know how to redact
NetworkCapabilities & LinkProperties that they received from
the system but need to send to third-party applications with
less privilege than themselves. To make sure the redaction is
consistent, expose system API methods to do it that are wired
to the same redaction code used by ConnectivityService.

Bug: 191413541
Test: atest CtsNetTestCases, which includes new CTS for these
Change-Id: Ia3ae4755b5192884c147d6828f96cedac000a25b

lucaslin   authored and   Chalard Jean   commited 2022-02-12 15:21:13 +09:00
c582d50b8e
Merge changes from topic "bandwidth-limiting"
* changes:
  Add bandwidth limiting to CS
  Add setting that controls network rate limit

Patrick Rohr   authored and   Gerrit Code Review   commited 2022-02-09 18:00:04 +00:00
6b5b7b40d8
Add bandwidth limiting to CS
Adds ingress rate limiting functionality to ConnectivityService. The tc
rate limit is installed before we tell netd about the interface, and
removed after the network is removed from netd. When the setting
changes, the old rate limit needs to be removed before a new one can be
added (unfortunately, we cannot use NLM_F_REPLACE when configuring the
tc-police filter).

Currently, this functionality is always enabled, but may or may not work
based on kernel support.

Bug: 157552970
Test: atest FrameworksNetTests:ConnectivityServiceTest
Change-Id: I4e64b2c40490f061e42b40a1b1b3a6618c3d1a87

Patrick Rohr   commited 2022-02-09 14:46:26 +01:00
2857ac4dd0
Pass the NetworkAgentConfig to NetworkMonitor.
When the network is a VPN, NetworkMonitor needs to know whether
the VPN requests validation, and that information is stored in
NetworkAgentConfig. Pass it.

Test: FrameworksNetTests
Change-Id: I3616f0796b69ce054d92213aafdef43ba7041596

Chalard Jean   commited 2022-02-09 15:19:38 +09:00
d490072cd6
Revert "Revert "Update the UIDs only after the native network is created""
This reverts commit 13b96bc651.

Reason for revert:
- The reverted CL fixes a bootloop on Fi devices and must be submitted again for droidfood stability purposes.
- It's not clear whether the revert actually fixes the test that prompted it.

Change-Id: I68200501d1c587d1c6b3ad81053175c74961a440

Lorenzo Colitti   commited 2022-02-08 16:21:01 +00:00
96a3f144a7
Revert "Update the UIDs only after the native network is created"
This reverts commit a7d4766d0d.

Reason for revert: DroidMonitor: Potential culprit for Bug 218308105 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: Ia9953d023c1eb84846834f92d4f38a72fa14bd30

Jordan Demeulenaere   commited 2022-02-08 10:42:11 +00:00
13b96bc651
Update the UIDs only after the native network is created
UIDs can't be sent to netd until the native network is created.
Also, it's possible that the interface disappears at any moment,
so in that case catch the ServiceSpecificException.

Test: FrameworksNetTests
Bug: 218100554
Change-Id: I79285166acf5d89aa34107e00dfff963ccc22d52

Chalard Jean   commited 2022-02-06 20:06:18 +09:00
a7d4766d0d
Handle Low Power Standby chain in ConnectivityService
Bug: 190822356
Test: atest NetworkManagementServiceTest
Change-Id: If5a07d0ea958d832b00797a9d9a4d5ad4f129b89

Robert Horvath   commited 2022-02-02 22:54:21 +01:00
1db49e1c7f
Introduce ensureListenableCapabilities
Renamed from ensureValid, this is an easier to understand name.
It is also a lot clearer when requestable capabilities also
have to be listenable.

Also move the 2 functions together.

Test: FrameworksNetTests
Change-Id: I685f924a3720846d740837a4a0fee3d88a26725a

Chalard Jean   commited 2022-02-02 13:52:26 +09:00
dd4219978d
Accept accessUids from telephony when it's the carrier config app
Test: FrameworksNetTests, new test in this patch
Change-Id: I50fab91e107c51d33a5e529c73b83db198a88d2c

Chalard Jean   commited 2022-02-02 13:52:25 +09:00
ac9ace0bbe
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