Commit Graph

47154 Commits

Author SHA1 Message Date
Lorenzo Colitti
8b7896b51a Merge "Rename setUidForeground to noteUidForeground" 2022-03-15 23:33:26 +00:00
Sewook Seo
c8fadc5cde Merge "API review: Additional comment for QosSession." 2022-03-15 10:10:27 +00:00
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
Frank Li
3f5703df80 Merge "[DU09-3]Modify the NetworkStatsCollection Builder API" 2022-03-14 02:36:08 +00:00
Nucca Chen
3938102448 Merge changes I5af6ce96,Ibc1f6813
* changes:
  Refactor make{Tether4Key, Tether4Value ConntrackEvent} helper
  BpfCoordinatorTest: refactor upstream and downstream setup functions
2022-03-11 18:05:14 +00:00
sewookseo
5f703feca1 API review: Additional comment for QosSession.
Additional comment on getSessionId in QosSession.

Bug: 216368595
Test: build
Change-Id: I0575253ef490e3d456e69816d52075c2d10813f0
2022-03-10 22:28:15 +00:00
Mark Chien
98502b78bc Merge "Use U32 from shared library" 2022-03-10 16:27:33 +00:00
Aaron Huang
23f5e54efa Merge "Add test coverage for NetworkStats.Bucket#getRoaming()" 2022-03-10 12:14:10 +00:00
Aaron Huang
5417280f17 Rename setUidForeground to noteUidForeground
Addresses API review feedback. Both setUidForeground in
NetworkStatsManager and NetworkStatsService are renamed to
noteUidForeground. Thus, the caller in test should be also
modified.

Bug: 222291301
Test: atest FrameworksNetTests
Change-Id: Ifa1e1af3d9fd8b1dc75a8f37947a5958f60ed415
2022-03-10 18:33:50 +08:00
Remi NGUYEN VAN
2aae895972 Merge "Add DisableConfigSyncTargetPreparer to CTS/MTS" 2022-03-10 09:34:00 +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
Ross Yeh
422c7dd460 Merge "cts: Re-launch the desired activity after screen-on on TVs." 2022-03-10 01:13:37 +00:00
Patrick Rohr
6758a5dfff Merge "Add test for EthernetNetworkUpdateRequest" 2022-03-09 09:16:29 +00:00
Aaron Huang
fdbe9847a9 Add test coverage for NetworkStats.Bucket#getRoaming()
Bug: 217771804
Test: CtsNetTestCases
Change-Id: I16778488540476c2d1e77378a020c548eb894f0a
Merged-In: I16778488540476c2d1e77378a020c548eb894f0a
2022-03-09 08:42:40 +00:00
markchien
22c1a3aa1f Use U32 from shared library
There is U32 added in frameworks/libs/net. Use shared one to avoid
duplicated code.

Bug: 215095957
Test: m
Change-Id: I861bc2f65ea947a908de2ec83e9b137d3342c8ce
2022-03-09 15:05:16 +08:00
Mark Chien
cc29690fc1 Merge "Split updateMeteredNetwork{Allow, Deny}List into add and remove" 2022-03-09 05:00:58 +00:00
markchien
e46042b833 Split updateMeteredNetwork{Allow, Deny}List into add and remove
Split the updateXXX methods into an addXXX and removeXXX instead of using
a boolean parameter to indicate whether the uid should be added or removed

Bug: 218494748
Test: atest FrameworksNetTests
Change-Id: I868cf35c8f51b25d8719e618c6c48a5cd642da7f
2022-03-09 11:17:27 +08:00
Remi NGUYEN VAN
a3f45ecdff Merge changes from topic "start_nearby_cp"
* changes:
  Add try/catch, shim in Nearby initialization
  Add stub NearbyService
  Start Nearby from Connectivity ServiceInitializer
2022-03-09 01:39:50 +00:00
Patrick Rohr
30d33f4ee3 Add test for EthernetNetworkUpdateRequest
Test: atest EthernetNetworkUpdateRequest
Change-Id: I2aeacca81f07cf2d73814d20fc9e63e9f1a65843
2022-03-08 16:29:43 +01:00
Remi NGUYEN VAN
46d7ddb725 Add try/catch, shim in Nearby initialization
The try/catch allows using a stub NearbyService on branches that do not
support it yet.

Also update Context.NEARBY_SERVICE to ConstantsShim to be compatible
with all branches.

Bug: 189355156
Test: boots
Change-Id: I7db0035b0d9ada79f00d6ef1ac5b54b2e98489d0
2022-03-08 10:33:32 +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
Maciej Żenczykowski
70d1026b6d Merge "BpfHandler: only allow to tag INET/INET6 socket" 2022-03-08 00:44:59 +00:00
Xin Li
f08c6c060f Merge Android 12L
Bug: 222710654
Merged-In: I03636e6b8b4dc200fcb039b99190759bc7d5e776
Change-Id: Ib9fccbbe6b6ace0a4ecddc8b84f7244e465b83b6
2022-03-08 00:19:47 +00:00
Gurpreet Singh
3acad24476 Merge "Using common apex_defaults for com.android.tethering module." am: 6802eadef5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2007756

Change-Id: I03636e6b8b4dc200fcb039b99190759bc7d5e776
2022-03-07 17:56:53 +00:00
Gurpreet Singh
6802eadef5 Merge "Using common apex_defaults for com.android.tethering module." 2022-03-07 17:32:37 +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
Treehugger Robot
b9c6d49a6f Merge "API review: Addional documentation for QosFilter" am: 3b45bca306
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2008676

Change-Id: I8882c865b00a530b1dd14d1f698a3413b9ccd177
2022-03-07 09:55:50 +00:00
Treehugger Robot
1e60378519 Merge "BpfHandler: only allow to tag udp/tcp socket" am: ca2c473781
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2009295

Change-Id: I0bd5824c5afada42f68fece2a83593a01a3edfb2
2022-03-07 09:55:37 +00:00
Treehugger Robot
3b45bca306 Merge "API review: Addional documentation for QosFilter" 2022-03-07 09:45:13 +00:00
Treehugger Robot
ca2c473781 Merge "BpfHandler: only allow to tag udp/tcp socket" 2022-03-07 09:31:33 +00:00
Frank
349fadfa52 [DU09-3]Modify the NetworkStatsCollection Builder API
1. Adding the bucketDuration with unit as bucketDurationmillis
2. make the Key class be final
3. The Key set parameter be marked with an IntDef

Bug: 220153505
Test: atest NetworkStatsCollectionTest
Change-Id: I8919ed595c2d339e8a5c0fc163b3c40edb4a2ad8
2022-03-07 16:31:26 +08:00
Hungming Chen
bcc0f5b14f BpfHandler: only allow to tag INET/INET6 socket
This is a follow up commit for the family validation {INET, INET6}.
The protocol validation {TCP, UDP} has been added in previous
commit.

The TrafficController socket destroy listener only monitors
on the group {INET_TCP, INET_UDP, INET6_TCP, INET6_UDP}.
Tagging listener unsupported socket causes that the tag can't
be removed from tag map automatically. Eventually, the tag map
run out of space because of dead tag entries.

See TrafficController::makeSkDestroyListener in
packages/modules/Connectivity/service/native/TrafficController.cpp

Also address the comments from previous commit.
- Remove the useless else-statment in tagSocket protocol validation.
- Make the socket cookie query and test into one line in
  BpfHandlerTest#TestTagSocketWithUnsupportedProtocol

Bug: 223094609
Test: atest BpfHandlerTest
Change-Id: I0f571fc00caa01c86399f0dbb593e8a40ad94bbd
2022-03-07 16:04:32 +08:00
Hungming Chen
478c0eb21c BpfHandler: only allow to tag udp/tcp socket
The TrafficController socket destroy listener only monitors
on the group {INET_TCP, INET_UDP, INET6_TCP, INET6_UDP}.
Tagging listener unsupported socket causes that the tag can't
be removed from tag map automatically. Eventually, the tag map
run out of space because of dead tag entries.

See TrafficController::makeSkDestroyListener in
packages/modules/Connectivity/service/native/TrafficController.cpp

Bug: 223094609
Test: atest BpfHandlerTest
Change-Id: Icc19b7c9f37fef498b89f43e44767f6b9e931a5a
2022-03-07 16:03:05 +08:00
sewookseo
4aac074872 API review: Addional documentation for QosFilter
Improve API document for matchecLocalAddress & matchesRemoteAddress

Bug: 188798655
Test: Build
Change-Id: Ic74e34469677364d3b1aa1fbf802f12c66b22461
2022-03-07 06:56:11 +00:00
Mark Chien
c4b5faefaf Merge "Make isTetheringSupported respect all tethering downstreams" am: 8dcc3000fd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1938694

Change-Id: Ic5f106a611a729fd63af2710bb9354be447641fd
2022-03-07 06:17:57 +00:00
Mark Chien
8dcc3000fd Merge "Make isTetheringSupported respect all tethering downstreams" 2022-03-07 05:56:20 +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
markchien
259d5c08a8 Make isTetheringSupported respect all tethering downstreams
Currently if wifi, usb and bluetooth tethering is not supported,
isTetheringSupported would return false. Then ethernet, ncm tethering
and wifi p2p would also not be supported anymore. Make
isTetheringSupported respect all tethering downstreams after T.

Also remove redundant code:
1. tethering always has upstream configuration, checking whether has
upstream configuration for isTetheringSupported is useless.
2. Remove TetheringDependencies#isTetheringSupported because it don't
have any caller.

Test: atest TetheringTests
Change-Id: I3db5ce410c064d37c9e9e704fce2a2b68705834e
2022-03-07 10:55:51 +08:00