Commit Graph

710 Commits

Author SHA1 Message Date
Lorenzo Colitti
9f6e6c4e27 Merge "Add a NetworkAgent API to indicate that a network will be replaced." 2022-03-15 04:44:16 +00:00
Lorenzo Colitti
ffa2ed3d1c 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
2022-03-14 21:52:37 +09:00
Remi NGUYEN VAN
bcf3b1b58b Merge "Rename "service-nearby" to "service-nearby-pre-jarjar"" 2022-03-14 09:07:43 +00:00
Lucas Lin
ba61dca57c Merge "Rename redactNetworkCapabilitiesForPackage and update its javadoc" 2022-03-14 08:05:08 +00:00
Remi NGUYEN VAN
b6cde3d2dc Rename "service-nearby" to "service-nearby-pre-jarjar"
Change-Id: I99ef6ee39e89f99b0878909e2d1f2962df513d1a
Test: unit test
Bug: 217115866
Merged-In: I80c8538372659a04145178fcc8e1af98e78e3681
2022-03-10 04:32:19 +00:00
Xin Li
e6953d54a5 Merge "Merge Android 12L" 2022-03-08 06:55:42 +00:00
Treehugger Robot
5635d505e0 Merge "Remove ConnectivityManager swapActiveStatsMap API" 2022-03-08 06:31:23 +00:00
Maciej Żenczykowski
984c39992c Merge changes Id5f5bdfc,I67b9f30b
* changes:
  [CLATJ#32] ClatCoordinator: untag clat raw socket
  [CLATJ#31] ClatCoordinator: tag raw socket to uid AID_CLAT
2022-03-08 00:47:17 +00:00
Treehugger Robot
23037308c6 Merge "Don't attempt to enable rate-limiting before T." am: 33f4e14073
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2010337

Change-Id: If26026f57421c51eb34f38c82229fd524b734299
2022-03-07 16:17:40 +00:00
Treehugger Robot
33f4e14073 Merge "Don't attempt to enable rate-limiting before T." 2022-03-07 15:51:32 +00:00
Mark Chien
1e048b4432 Merge "Remove dead code in BpfNetMaps." am: e06458378d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2008696

Change-Id: I1d44c652972e43f6598fcb231bdc538e3836a046
2022-03-07 15:44:27 +00:00
Mark Chien
e06458378d Merge "Remove dead code in BpfNetMaps." 2022-03-07 15:19:25 +00:00
Lorenzo Colitti
f79dcecf9b 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
2022-03-07 12:21:40 +00:00
Lorenzo Colitti
82244fd16c 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
2022-03-07 12:56:18 +08:00
markchien
49e944cc1c 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
2022-03-07 12:25:47 +08:00
Hungming Chen
1c257cdb8d [CLATJ#32] ClatCoordinator: untag clat raw socket
Untag clat raw socket while stopping clatd.

Bug: 218407445
Test: atest FrameworksNetTests
Test: connect and disconnect to/from IPv6 only network
Check dumpsys tag map and logging for tagging/untagging socket
03-04 16:29:17.247  1330  1714 I jniClatCoordinator: tag uid AID_CLAT to socket fd 420, cookie 16524
03-04 16:29:31.343  1330  1714 I jniClatCoordinator: untag socket cookie 16524

Change-Id: Id5f5bdfc97a15abfa1a49b06dcb3c2c25743c74f
2022-03-07 11:38:40 +08:00
Hungming Chen
89d12060e1 [CLATJ#31] ClatCoordinator: tag raw socket to uid AID_CLAT
Tag socket as uid AID_CLAT to avoid duplicated data usage counting by
bpf program.

Test: atest FrameworksNetTests
Test: check dumpsys for tag mapping and check logging for socket cookie

$ adb shell dumpsys connectivity trafficcontroller
  mCookieTagMap:
    cookie=28831 tag=0x0 uid=1029

03-02 22:43:13.201  1719  1921 I jniClatCoordinator: tag uid AID_CLAT to socket fd 609, cookie 28831
03-02 22:43:13.217  5496  5496 I clatd   : tunnel.write_fd6 609, cookie 28831, flags 0x0 (debug only)

Bug: 218407445
Change-Id: I67b9f30b143e791ddf59d5627e068ec3107e3328
2022-03-07 11:37:41 +08:00
Maciej Żenczykowski
c6a4f658a8 Merge "[CLATJ#29] Remove the throwaway sockets for dup2 fds" am: 171db11c5f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2005551

Change-Id: I4fa687a08f32b1f4413cda18825b08f38c22db08
2022-03-05 08:50:54 +00:00
Maciej Żenczykowski
ef0b4884d0 Merge changes from topic "dedup-interfaceparams" am: a63535bfd1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2007154

Change-Id: I7bd8c3a2ef89d0f358d6002d87dd08d6cd818691
2022-03-05 08:50:34 +00:00
Maciej Żenczykowski
171db11c5f Merge "[CLATJ#29] Remove the throwaway sockets for dup2 fds" 2022-03-05 08:32:47 +00:00
Maciej Żenczykowski
a63535bfd1 Merge changes from topic "dedup-interfaceparams"
* changes:
  Remove unused InterfaceParams jarjar rule
  Deduplicate InterfaceParams
2022-03-05 08:23:55 +00:00
Patrick Rohr
e0f3847b59 Remove unused InterfaceParams jarjar rule
InterfaceParams has moved to com.android.net.module.util for which a
jarjar rule already exists. It is about to be removed from
android.net.util.

Test: builds
Bug: 222448728
Change-Id: I384bfd3a3def98e16c353c4e599deb84205319cb
2022-03-04 16:53:51 +01:00
Patrick Rohr
9f371f024b Deduplicate InterfaceParams
CS should use InterfaceParams from frameworks/libs/net.

Test: builds
Bug: 222448728
Change-Id: I1f45d3171b265461a8724b4be7b212c030b63fe9
2022-03-04 16:53:51 +01:00
Hungming Chen
e250c95bb8 [CLATJ#29] Remove the throwaway sockets for dup2 fds
Don't need these temporary socket fds anymore because the
posix_spawn_file_actions_adddup2() will clean up the flag
O_CLOEXEC for dup2 fd == new_fd before forking.

Bug: 218407445
Test: connect to ipv6 only network and ping 8.8.8.8
Change-Id: I70b8a03a6a13393a30a8a63599b8d1468347c560
2022-03-04 11:53:25 +08:00
Patrick Rohr
2d3a6696ba Do not enable ingress rate limit until clsact qdisc exists am: f1fe8ee928
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2003978

Change-Id: I81ef8189ca04738b16a584e079e73ffa92e31a9f
2022-03-02 20:15:09 +00:00
Patrick Rohr
f1fe8ee928 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
2022-03-02 20:41:13 +01:00
Paul Hu
e435b5b513 Merge "Rename framework-connectivity-tiramisu to framework-connectivity-t" am: c871c08d8d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1976727

Change-Id: I1d69a7e13408a2d3bf61250b6568ea522b27880c
2022-03-02 07:27:24 +00:00
lucaslin
d2b0613814 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
2022-03-02 10:56:57 +08:00
paulhu
537f72061a Rename framework-connectivity-tiramisu to framework-connectivity-t
Bug: 215434166
Test: build, flash, device boot to home.
Merged-In: I9ebedf8813cbfa30d979bc35a3b2306715be682b
Change-Id: I9ebedf8813cbfa30d979bc35a3b2306715be682b
2022-03-01 09:44:21 +08:00
Remi NGUYEN VAN
97edc959c2 Add JNI stats libraries to connectivity am: d95048929c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1987449

Change-Id: Ibae3c96be03017135b9aff4caf6f3f5f1a86075a
2022-02-28 06:26:45 +00:00
Junyu Lai
2eea4e4bd0 [MS54.3] Move NetworkStats to updatable sources am: eb6f4bef96
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1987447

Change-Id: I5c527290654b76405776efd54e57a1b469c62add
2022-02-28 06:26:36 +00:00
Lorenzo Colitti
cebdfba1bb Merge changes from topic "ms52-movenetstats"
* changes:
  Update API files to unhide MATCH_PROXY.
  Update tests for NetworkStats code move.
  Add setPollForce to module API
  Add JNI stats libraries to apex Android.bp
  Add JNI stats libraries to connectivity
  [MS62.2] Add NetworkStatsService into service initializer
  [MS54.8] Add hiddenapi-unsupported-t.txt to apex Android.bp
  [MS54.3] Move NetworkStats to updatable sources
2022-02-28 05:32:23 +00:00
Remi NGUYEN VAN
d95048929c Add JNI stats libraries to connectivity
Add new symbols to libservice-connectivity loaded on T only, and the
framework libraries to apex and tests.

Bug: 197717846
Test: atest FrameworksNetTests
  (cherry-picked and splitting apex Android.bp to aosp/1994130)
Change-Id: Iae44344701a3267110e5cbf271120201134d59e5
Merged-In: Iae44344701a3267110e5cbf271120201134d59e5
2022-02-28 04:16:17 +00:00
Junyu Lai
eb6f4bef96 [MS54.3] Move NetworkStats to updatable sources
This CL builds NetworkStats related codes with the
connectivity module instead of platform.

Test: TH
Bug: 197717846
Change-Id: I4eeb7ea9cfc3139991caf0fc22474e0052a0391c
Merged-In: I4eeb7ea9cfc3139991caf0fc22474e0052a0391c
2022-02-28 03:24:19 +00:00
Treehugger Robot
93765193d3 Merge changes Ie68356a4,I2b63c24b am: d6a5303cd8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1993952

Change-Id: Id3cb1919302d5c232ac9ec4149eca9c3a6821c70
2022-02-22 11:31:45 +00:00
Treehugger Robot
d6a5303cd8 Merge changes Ie68356a4,I2b63c24b
* changes:
  Attempt to deflake NetworkAgentTest#testRejectedUpdates.
  Fix a couple of JavaDoc errors in NetworkAgentInfo.
2022-02-22 10:41:37 +00:00
Treehugger Robot
f105588f91 Merge changes Ib1cd342a,Iab23d414 am: 1c5ce5542a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1991622

Change-Id: I3aab26bc9351e7dd065071b11d58ef9be7224a92
2022-02-22 09:35:16 +00:00
Treehugger Robot
1c5ce5542a Merge changes Ib1cd342a,Iab23d414
* changes:
  Add an IS_DESTROYED flag to FullScore.
  Use MessageUtils instead of hardcoded strings in policyNameOf.
2022-02-22 09:26:38 +00:00
Treehugger Robot
d022d49a39 Merge "Remove redundant "using" statement" am: fa017ea2e4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1993951

Change-Id: I618295d0ef86209d5c08d766a1b87f5a11de2c5f
2022-02-22 08:49:32 +00:00
Lorenzo Colitti
8c7a8860f9 Add an IS_DESTROYED flag to FullScore.
This is being added as the lowest priority score factor, just
above the tie-breakers. It ensures that a network that has been
destroyed will lose to another identical network that has not
been destroyed, but will otherwise be scored identically.

The flag is a CS-managed flag that is stored in NetworkAgentInfo.
Currently it is always false, but it will be populated in
future CLs.

Bug: 216567577
Test: atest FrameworksNetTests
Change-Id: Ib1cd342ab7dfc4df45715da19b743d711fe8d605
2022-02-22 16:39:44 +09:00
Lorenzo Colitti
38bbdbd1aa Fix a couple of JavaDoc errors in NetworkAgentInfo.
These don't break compilation because NetworkAgentInfo doesn't
expose any APIs and thus doesn't generate javadoc, but they
are flagged by the IDE.

Test: treehugger
Change-Id: I2b63c24b2afbc98950f53c38f80d27474aab0622
2022-02-22 16:39:44 +09:00
Yi Kong
38c4cd90db Remove redundant "using" statement
Test: presubmit
Bug: 219872355
Change-Id: Ie4fc87e5231e31799644c26943bbc13000091e92
2022-02-22 13:37:51 +08:00
Treehugger Robot
b8c555afb2 Merge "Rename one of the two EVENT_NETWORK_TESTED messages." am: 4b654c9038
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1989916

Change-Id: I546f6aaecc6f8d42e6b0d7dadd303c432c57daef
2022-02-21 00:51:17 +00:00
Treehugger Robot
4b654c9038 Merge "Rename one of the two EVENT_NETWORK_TESTED messages." 2022-02-21 00:22:11 +00:00
Treehugger Robot
3990ff6dfc Merge "reduce log level when no interface is present for rate limiting" am: 19ce06b05f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1985028

Change-Id: Ia805d853e0a7d7d041888bfbff12abc9819fd7de
2022-02-19 21:50:10 +00:00
Treehugger Robot
19ce06b05f Merge "reduce log level when no interface is present for rate limiting" 2022-02-19 21:31:05 +00:00
Lorenzo Colitti
c6d3f3cf25 Use MessageUtils instead of hardcoded strings in policyNameOf.
This makes the code easier to maintain because we do not need to
manually add string representations, and because it will throw at
static initialization time if the clas contains duplicate
POLICY_xxx values. The memory overhead is likely negligible.

Bug: 216567577
Test: new coverage in FullScoreTest
Change-Id: Iab23d414c8e28ff7f26060ad44fa996f277d361f
2022-02-19 19:45:43 +09:00
Lorenzo Colitti
0261ced634 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
2022-02-19 02:24:02 +09:00
Wayne Ma
c6f0c0287b Address comment from aosp/1948169 am: 5545291ef5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1991613

Change-Id: I2c0c37455e8b6341b4a080e5905aa56bd4b5b9d5
2022-02-18 10:39:09 +00:00
Patrick Rohr
a517f20ef0 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
2022-02-18 09:18:20 +01:00