Commit graph android_packages_modules_Co.../service/src/com/android/server/ConnectivityService.java
Message SHA1
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
Remove ConnectivityManager swapActiveStatsMap API
swapActiveStatsMap is temporary added for the NetworkStatsFactory to
call BpfNetMaps#swapActiveStatsMap in tethering mainline module. Now
NetworkStatsFactory already be mainlined, calling BpfNetMaps#swapActiveStatsMap
directly.

Bug: 218494448
Test: atest ConnectivityCoverageTests
      atest FrameworksNetTests
Change-Id: I3358e4ac5fb7ed0964273afdbccd1b4128ca7645

markchien   commited 2022-03-07 12:25:47 +08:00
49e944cc1c
Merge changes from topic "dedup-interfaceparams"
* changes:
  Remove unused InterfaceParams jarjar rule
  Deduplicate InterfaceParams

Maciej Å»enczykowski   authored and   Gerrit Code Review   commited 2022-03-05 08:23:55 +00:00
a63535bfd1
Deduplicate InterfaceParams
CS should use InterfaceParams from frameworks/libs/net.

Test: builds
Bug: 222448728
Change-Id: I1f45d3171b265461a8724b4be7b212c030b63fe9

Patrick Rohr   commited 2022-03-04 16:53:51 +01:00
9f371f024b
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
Rename redactNetworkCapabilitiesForPackage and update its javadoc
The API won't modify the passed NetworkCapabilities and
LinkProperties, but redactNetworkCapabilitiesForPackage and
redactLinkPropertiesForPackage sound like they will. To reduce
the confusion, rename the API with prefix "getRedacted".
Also modify the javadoc to describe more about what the API will
do if the given UID doesn't have location permission.

Bug: 220367512
Test: atest CtsNetTestCases
Change-Id: I964f1062da1ae96df9b369b911486da1379b8a19

lucaslin   commited 2022-03-02 10:56:57 +08:00
d2b0613814
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