Commit Graph

29245 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
7c9f83b244 Jarjar all classes in service-connectivity am: b240e2a86e
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15261893

Change-Id: I764011af0667ca401be07b42086118954c953c2d
2021-07-13 12:46:30 +00:00
Remi NGUYEN VAN
b240e2a86e Jarjar all classes in service-connectivity
This ensures classes are used from the service-connectivity jar, instead
of using classes from the system_server bootclasspath when there is a
name conflict.
Any developer adding a future class should do so in a subpackage of
com.android.connectivity (such as com.android.connectivity.server).
Otherwise, jarjar rules need to be added manually until b/180995093 is
fixed.

Also update current jarjar rules so that classes are jarjared to
com.android.connectivity.[original name], making it easier to find the
original source. This is consistent with the wifi module.

Bug: 193086215
Test: atest CtsNetTestCases
      dexdump on service-connectivity.jar shows no classes outside of
      com.android.connectivity and com.android.server
Original-Change: https://android-review.googlesource.com/1759589
Merged-In: I2aadeca32751267b74d4fd2fd93bb3e8c62e46c0
Change-Id: I2aadeca32751267b74d4fd2fd93bb3e8c62e46c0
2021-07-13 04:42:07 +00:00
paulhu
1ac1c693ab Update network preference priority value for VPN am: b5c9e3567f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15258458

Change-Id: I79451722e100dcb8d066e9047656b4410d3bab82
2021-07-13 03:30:37 +00:00
paulhu
b5c9e3567f Update network preference priority value for VPN
Currently netd supports only the default value for VPN but CS
send priorty value 1 to netd. It will break the default routing
for VPN. Thus, update network preference priority value to 0 for
VPN.

Bug: 193245476
Test: atest CtsHostsideNetworkTests:HostsideVpnTests
Original-Change: https://android-review.googlesource.com/1762867
Merged-In: I197cb358e8e30355fbf675e4c623abebe7abdb7f
Change-Id: I197cb358e8e30355fbf675e4c623abebe7abdb7f
2021-07-12 16:02:38 +00:00
James Mattis
a89e4e03ed Only pass the NRI for removal in NRI#binderDied am: 4846fff84d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15236913

Change-Id: I101f9e5e148b77ffde136db16c75f21991d39d98
2021-07-09 05:36:14 +00:00
James Mattis
4846fff84d Only pass the NRI for removal in NRI#binderDied
When NetworkRequestInfo#binderDied is called in ConnectivityService,
only pass the NRI to handleRemoveNetworkRequest. This is to prevent a
potential crash when unlinkDeathRecipient is called twice for the same
NRI.

Also, as a cleanup, don't iterate mRequests in the log message on binderDied.

As per the bug, the chain of events leading to a potential crash are:

- `Connectivity.NetworkRequestInfo#binderDied()` is called for an NRI
tracking multiple `NetworkRequest` items. This can happen for a TRACK_DEFAULT
request filed by a UID on a different preference than the default, which
copies the request list.
- This in turn triggers multiple `EVENT_RELEASE_NETWORK_REQUEST` events
for the same NRI, one for reach `NetworkRequest` tracked.
- When handling `EVENT_RELEASE_NETWORK_REQUEST`, each `NetworkRequest`
that is passed in will then be used to look up the parent NRI that originally
sent it to be released.
- Therefore if an NRI was tracking three requests, it would trigger three
release network events, then each request would be used to look up the
same NRI again when handling said release event.
- Finally, `ConnectivityService.NetworkRequestInfo#unlinkDeathRecipient` is
called for the NRI in question. Using the scenario above, that means we could
call `unlinkDeathRecipient` multiple times for the same NRI if it was tracking
multiple network requests causing the associated crash.
- If `unlinkDeathRecipient` is called more than once for the same NRI, it will
cause the crash listed in this bug.
- The fix is to only call handleRemoveNetworkRequest for the NRI once. This
works since when removing the NRI, we iterate over all of its requests to
remove them. By only calling handleRemoveNetworkRequest once, it's ensured
`unlinkDeathRecipient` for this NRI as part of
`Connectivity.NetworkRequestInfo#binderDied()` is only called  once and not
potentially multiple times.

Bug: 185541983
Change-Id: I918c8620f2975d810894c178277771764923b5a4
Test: atest FrameworksNetTests
Merged-In: I2a2ad4ec6d415423182a1856a898779203658f8b
2021-07-09 02:12:33 +00:00
Sudheer Shanka
a20e2702dd Merge "Recheck if the network state in expedited job is unexpected." into sc-dev am: 1ec983c471
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15191249

Change-Id: I02fb4442949afbe1b6ba4330f4986f7369f97851
2021-07-07 18:35:55 +00:00
Sudheer Shanka
1ec983c471 Merge "Recheck if the network state in expedited job is unexpected." into sc-dev 2021-07-07 18:20:02 +00:00
Sudheer Shanka
ce96fa05a7 Recheck if the network state in expedited job is unexpected.
Unfortunately, this could happen if there is a delay in updating the
network rules for the app hosting the job.

Bug: 179319857
Test: atest tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: I60cfd5c5946a4cd0ef5ebf0c1e56b0667cc3164d
Ignore-AOSP-First: Expedited jobs are not available in AOSP yet
2021-07-07 18:19:50 +00:00
Paul Hu
f534ef200d Merge "Remove exclusivity restriction of multiple preferences" into sc-dev am: fd301c05c5
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14731887

Change-Id: I99af87f0106609da19f93306a8c06b79d4634fed
2021-07-07 14:47:31 +00:00
Paul Hu
fd301c05c5 Merge "Remove exclusivity restriction of multiple preferences" into sc-dev 2021-07-07 14:36:22 +00:00
paulhu
de5efb90cb Remove exclusivity restriction of multiple preferences
- Each network preference has been assigned a priority value so
  that netd can know which uid range rule has higher priority. So
  remove the restriction that all network preferences are
  exclusive.
- Add priority check when getting request for uid.

Bug: 171872461
Test: atest FrameworksNetTests
Ignore-AOSP-First: Needs cherry-picks
Change-Id: I6912db753c8b4a194aa7af92b01ca6dcfec10d8b
2021-07-07 12:38:16 +08:00
Treehugger Robot
9cf3d2a8e6 add test for /system/etc/bpf/{netd,clatd}.o using correct struct sizes am: cba9f66098
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15217930

Change-Id: If33f5d605a5bc6fea760e5c42de74f91a4a21375
2021-07-07 02:17:34 +00:00
Treehugger Robot
cba9f66098 add test for /system/etc/bpf/{netd,clatd}.o using correct struct sizes
This test is required to ensure that the system is compatible
with future updates of the tethering mainline module, which
updates BPF .o files on device.

This test must already be passing on OEM devices because otherwise
the offload.o program in the Tethering mainline module would bootloop
the device.

Bug: 190519702
Test: atest CtsNativeNetTestCases, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Original-Change: https://android-review.googlesource.com/1756440
Merged-In: Ibaedb8fcb28591ffba1506514f2305d55712a26b
Change-Id: Ibaedb8fcb28591ffba1506514f2305d55712a26b
2021-07-06 21:13:24 +00:00
Lorenzo Colitti
c295a80bb6 Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true am: 1d934442ff
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15211236

Change-Id: I89e0fe26656528c89f5ee07490b06634081e279c
2021-07-06 06:08:04 +00:00
Lorenzo Colitti
10909aab6f Enable and disable usb IpServer according to ACTION_USB_STATE am: 0450443f37
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15211231

Change-Id: Ia1858bb88b169a616b0d43b5c372fb8b280b3d29
2021-07-06 06:08:02 +00:00
Lorenzo Colitti
1d934442ff Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true
If config_tether_ncm_regexs is configured, load it to
tetherableUsbRegexs if ncm is used for TETHERING_USB. Load it to
tetherableNcmRegexs if ncm is used for TETHERING_NCM.

Bug: 185649441
Test: atest TetheringTests
Original-Change: https://android-review.googlesource.com/1755176
Merged-In: I0c542560bd04e8c0a6a78d632da5a00a34d9a3fa
Change-Id: I0c542560bd04e8c0a6a78d632da5a00a34d9a3fa
2021-07-06 04:32:35 +00:00
Lorenzo Colitti
0450443f37 Enable and disable usb IpServer according to ACTION_USB_STATE
Before this change, usb IpServer would be created if corresponding
interface is available even there is no enable tethering attempt. And
usb IpServer only be disabled when interface is removed. Usb tethering
could not be stopped if interface is always avaialbe.
After this change, usb IpServer would be enabled and disabled according
to ACTION_USB_STATE.

Bug: 185649441
Test: atest TetheringCoverageTests
      atest MtsTetheringTestLatestSdk
      atest CtsTetheringTest
Original-Change: https://android-review.googlesource.com/1731453
Merged-In: I8375e3f998d677dc658370b2553facaec0d5ff7c
Change-Id: I8375e3f998d677dc658370b2553facaec0d5ff7c
2021-07-06 04:22:21 +00:00
Remi NGUYEN VAN
f1dfc9cd6a Merge changes from topic "am-cc17cb7d48ea4bd7adc9183dc0c381e3-sc-dev" into sc-dev am: 0f956db686
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15165007

Change-Id: I498d487fbf36f16f9757f6ba42e3c44c68b205a5
2021-07-06 03:04:28 +00:00
Remi NGUYEN VAN
e6fa71092c Re-skip connectivity unit tests before S am: fda49a5f17
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15165006

Change-Id: I97b4ed4f8ec54a75396dbbebe964568054809786
2021-07-06 03:04:25 +00:00
Treehugger Robot
04352ea573 Move ConnectivityCoverageTests to general-tests am: bd01bbaa92
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15165005

Change-Id: I76cdbf70a8cc38c1e1d59dabce20c1df129fe341
2021-07-06 03:04:23 +00:00
Remi NGUYEN VAN
0e586ad73a Fix ConnectivityManagerTest initialization on Q am: a6c016a65d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15165004

Change-Id: I4c208ed755696483fed3797d25aa3536a8d49ec5
2021-07-06 03:04:21 +00:00
Treehugger Robot
e32bc089be Move test_mainline_modules to AndroidTest.xml am: fb34c5861a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15165003

Change-Id: I8c39006cbe24964a277f7c45eed861836fcaf9b2
2021-07-06 03:04:18 +00:00
Remi NGUYEN VAN
4f4bf8d05b Add ConnectivityCoverageTests to postsubmit am: 1c45a8a623
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15165002

Change-Id: Ic58bad518f0239e3cbfcfaac4e51048a86c5d3cd
2021-07-06 03:04:15 +00:00
Remi NGUYEN VAN
a620f9ef6e Add connectivity coverage tests am: 168b3d19f1
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14873769

Change-Id: I27e4004d35491d99f4fe53de5edacaea47954aa7
2021-07-06 03:04:13 +00:00
Remi NGUYEN VAN
ce711c422e Make tests compatible with mockito-extended am: ad8f23fef4
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15165000

Change-Id: I8e5ea50c0ff34a069681d878c3f8668d92cfae2b
2021-07-06 03:04:11 +00:00
Remi NGUYEN VAN
c97783e308 Fix KeepalivePacketDataUtilTest crash on eng build am: 8f260383f7
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15164999

Change-Id: I64c9bd2da7cbfd6d6c254287309e0738201c336f
2021-07-06 03:04:09 +00:00
Treehugger Robot
d6848cf464 Update connectivity TEST_MAPPING am: 0e2dbf3106
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15165001

Change-Id: I92940eaf52326100e3ffafffcb22120f34aae71f
2021-07-06 03:04:06 +00:00
Remi NGUYEN VAN
0f956db686 Merge changes from topic "am-cc17cb7d48ea4bd7adc9183dc0c381e3-sc-dev" into sc-dev
* changes:
  Apply jarjar rules on coverage tests
  Re-skip connectivity unit tests before S
  Move ConnectivityCoverageTests to general-tests
  Fix ConnectivityManagerTest initialization on Q
  Move test_mainline_modules to AndroidTest.xml
  Add ConnectivityCoverageTests to postsubmit
  Add connectivity coverage tests
  Make tests compatible with mockito-extended
  Fix KeepalivePacketDataUtilTest crash on eng build
  Update connectivity TEST_MAPPING
2021-07-06 02:42:51 +00:00
Remi NGUYEN VAN
0b3f20a64d Apply jarjar rules on coverage tests
Apply their respective jarjar rules on tethering and general
connectivity tests, then merge both into the coverage tests suite.
This is necessary to ensure that classes covered by tests have names
matching classes used in code.

Also fix IpConnectivityLogTest to use the module utility instead of the
hidden BitUtils, as the test would fail after internal utils are
jarjared.

Bug: 187935317
Test: atest ConnectivityCoverageTests TetheringCoverageTests
Original-Change: https://android-review.googlesource.com/1749680
Merged-In: Ib95b58dab93f7adebc445b662a6d15db1ce0e7c2
Change-Id: Ib95b58dab93f7adebc445b662a6d15db1ce0e7c2
2021-07-05 05:02:05 +00:00
Remi NGUYEN VAN
fda49a5f17 Re-skip connectivity unit tests before S
The tests are packaged together with other tests in a common coverage
suite, so need to be individually annotated so that they are skipped
before S.

They do not need to pass on platforms older than S, because such
platforms will not updated with the code that is tested.

This applies a previous change, this time using DevSdkIgnoreRunner,
as SdkSuppress does not work as expected in branches that have a
codename 2 versions above the SDK version, as is the case in AOSP.

Bug: 187935317
Test: atest ConnectivityCoverageTests on R
      atest FrameworksNetTests on S
Original-Change: https://android-review.googlesource.com/1749684
Merged-In: I5808d34459a4c19238baf8873afa7cf942828460
Change-Id: I5808d34459a4c19238baf8873afa7cf942828460
2021-07-05 05:01:54 +00:00
Treehugger Robot
bd01bbaa92 Move ConnectivityCoverageTests to general-tests
The test suite is not signed with any particular key so
can be in general-tests. This is also required for TEST_MAPPING.

Bug: 187935317
Original-Change: https://android-review.googlesource.com/1749025
Merged-In: I9dbf98eaa28172a172e707091ea75ffdddd4971b
Change-Id: I9dbf98eaa28172a172e707091ea75ffdddd4971b
Test: TH for test mapping
2021-07-05 05:01:42 +00:00
Remi NGUYEN VAN
a6c016a65d Fix ConnectivityManagerTest initialization on Q
The test can't have TetheringManager as an argument to methods or a
field, otherwise the test runner will crash when scanning the class for
tests because TetheringManager did not exist in Q. Although
testFactoryReset is already skipped on Q, the test runner would fail
at initialization time, before starting the run.

Use CtsTetheringUtils instead. This ensures that TetheringManager does
not have method signatures or members that reference classes that do not
exist on Q, so the test runner can scan the class successfully before
starting the run.

Bug: 188851796
Test: atest ConnectivityManagerTest on Q
Original-Change: https://android-review.googlesource.com/1740779
Merged-In: I87488d0f23628a1ef2d7af0242513fcc5401d598
Change-Id: I87488d0f23628a1ef2d7af0242513fcc5401d598
2021-07-05 05:01:28 +00:00
Treehugger Robot
fb34c5861a Move test_mainline_modules to AndroidTest.xml
When an AndroidTest.xml is used, configuration needs to be in the
AndroidTest.xml file, not in the Android.bp.

This currently causes tests not to be run in TEST_MAPPING as they should
be.

Test: TH needs to test
Bug: 187935317
Original-Change: https://android-review.googlesource.com/1748157
Merged-In: Ie0aca0c64646825175769cd375bcecf65de4b4c8
Change-Id: Ie0aca0c64646825175769cd375bcecf65de4b4c8
2021-07-05 05:01:16 +00:00
Remi NGUYEN VAN
1c45a8a623 Add ConnectivityCoverageTests to postsubmit
Add the tests to both postsubmit and mainline-postsubmit.

This should allow moving the tests to presubmit in the near future,
after they have been verified to pass in postsubmit.

Bug: 187935317
Test: treehugger needs to test
Original-Change: https://android-review.googlesource.com/1736506
Merged-In: I9a05d6a300c5f777497e867d0456bc59b06eee80
Change-Id: I9a05d6a300c5f777497e867d0456bc59b06eee80
2021-07-05 05:01:02 +00:00
Remi NGUYEN VAN
168b3d19f1 Add connectivity coverage tests
The coverage tests will allow measuring code coverage for all
Connectivity+Tethering code.

This is a combination of the current TetheringCoverageTests, and
FrameworksNetTests.

Adding min_sdk_version to the test prevents it from using deprecated
IoUtils utilities. Replace it with the non-deprecated alternative.

Bug: 187935317
Test: atest ConnectivityCoverageTests
Original-Change: https://android-review.googlesource.com/1731232
Merged-In: I5366e1cc9cd6ddb41f24718246381cc2b1cc1383
Change-Id: I5366e1cc9cd6ddb41f24718246381cc2b1cc1383
2021-07-05 05:00:36 +00:00
TreeHugger Robot
675f699927 Merge "Add tests for in-kernel VPN/VCN dataplane" into sc-dev am: f3c6c3e5b4
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15191238

Change-Id: I90f31700dd49b958c3eb33a4d22e90998236d147
2021-07-03 02:15:41 +00:00
Maciej Żenczykowski
27c370a509 ipv4 tethering offload - decrement ttl during forwarding am: f416b8a1ff
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15192718

Change-Id: I8590f50c99335b5b5549f1c3da3c009b9ec24e32
2021-07-03 02:12:35 +00:00
TreeHugger Robot
f3c6c3e5b4 Merge "Add tests for in-kernel VPN/VCN dataplane" into sc-dev 2021-07-03 02:01:54 +00:00
Maciej Żenczykowski
f416b8a1ff ipv4 tethering offload - decrement ttl during forwarding
Bug: 192635131
Test: atest, TreeHugger, flashed on phone, forwarded ipv4 traffic
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Original-Change: https://android-review.googlesource.com/1755049
Merged-In: I88e5293a54b7867a8e7dd76f6fd8e2a52d31e51a
Change-Id: I88e5293a54b7867a8e7dd76f6fd8e2a52d31e51a
2021-07-02 22:08:34 +00:00
Benedict Wong
6dd0516b56 Add tests for in-kernel VPN/VCN dataplane
This change adds relevant tests for the migrateTun functionality in
NetworkStats.

Bug: 190620024
Test: atest NetworkStatsTest
Original-Change: https://android-review.googlesource.com/1749069
Merged-In: I33f14f2d0f71013a594fd4c8c3914a590d30ea06
Change-Id: I33f14f2d0f71013a594fd4c8c3914a590d30ea06
2021-07-02 19:29:06 +00:00
TreeHugger Robot
b8beb3d6d2 Merge "Allow non-VPNs to have underlying networks." into sc-dev am: 0868536de9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15182605

Change-Id: I6f9895eee27be8f6b179270f15a0bdf56baf47bd
2021-07-02 19:12:34 +00:00
TreeHugger Robot
0868536de9 Merge "Allow non-VPNs to have underlying networks." into sc-dev 2021-07-02 18:56:30 +00:00
Paul Hu
6f9ba0496e Merge "Listen EXTERNAL_APPLICATIONS_AVAILABLE intent" into sc-dev am: 790d3eb079
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14772860

Change-Id: I9b09ac787d1ec4580c724426a66abf8c1446217c
2021-07-02 14:32:26 +00:00
Paul Hu
790d3eb079 Merge "Listen EXTERNAL_APPLICATIONS_AVAILABLE intent" into sc-dev 2021-07-02 14:17:17 +00:00
Treehugger Robot
4703a8c392 Allow non-VPNs to have underlying networks.
Certain network types, like the VCN, have underlying
networks for the purpose of data usage, but do not want to
propagate the underlying network capabilities.

Allow these networks to set underlying networks, but continue
not to propagate the capabilities.

Bug: 190620024
Test: new unit test
Original-Change: https://android-review.googlesource.com/1753619
Merged-In: I53d6080f48707ff3c37fbfbef534284ba77a7432
Change-Id: I53d6080f48707ff3c37fbfbef534284ba77a7432
2021-07-02 13:56:28 +00:00
Paul Hu
3dc7387fdb Merge "Use Netd new added/removed uid range methods" into sc-dev am: 29194db12f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14911836

Change-Id: I5639000ecd2669b677c98e359cb042ac17a69efc
2021-07-02 12:21:16 +00:00
Paul Hu
29194db12f Merge "Use Netd new added/removed uid range methods" into sc-dev 2021-07-02 12:08:35 +00:00
Paul Hu
75ca971c66 Merge "Force only system uid can set uids allowed on restricted networks" into sc-dev am: 77739d37b3
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15172131

Change-Id: I0e35396ef80f046aa31931940714dee65a7b781c
2021-07-02 11:02:59 +00:00
Paul Hu
77739d37b3 Merge "Force only system uid can set uids allowed on restricted networks" into sc-dev 2021-07-02 10:46:19 +00:00