Commit Graph

662 Commits

Author SHA1 Message Date
Hungming Chen
c27ec7c4a2 Refresh conntrack entry timeout
Needed because the BPF maps offloads IPv4 traffic. The kernel can't
trace the offloaded traffic to keep the conntrack entry.

Bug: 190783768
Test: atest TetheringCoverageTests
Change-Id: Idbcf686c9b2124b192944156ac5111be741744fb
2021-06-23 15:41:30 +08:00
Hungming Chen
a6e7869646 Clear IPv4 offload rules when tethering stopped
The condition for deleting IPv4 forwarding rules.
1. When the tethering client has gone, deletes the client and its
   rules.
2. When the upstream has gone, deletes all rules.
3. When the upstream has changed, deletes all rules.

Test: atest TetheringCoverageTests and check IPv4 offload rules
via dumpsys tethering in the following test cases.

Bug: 190783768

Test cases:
a. Loss upstream interface while tethering
  1. Enable WIFI tethering
  2. Disable upstream interface
  3. Check the rules are removed.
b. Loss downstream interfaces while tethering
  1. Enable WIFI tethering
  2. Enable BT tethering
  3. Disable BT tethering
  4. Check the BT tether rules are removed.
  5. Disable WIFI tethering
  6. Check the WIFI tether rules are removed.
c. Switch upstream interface while tethering
  1. Enable WIFI tethering
  2. Enable BT tethering
  3. Switch upstream interface from cellular to wifi.
  4. Check all rules are removed.
d. Enable NAT failure (manual)

Log:
The rule deletion in each case.
- IpServer#stopIPv4: case b and case d.
- BpfCoordinator#updateUpstreamNetworkState: case a and case c.

Test case a
06-23 09:58:59.245  [...] Tethering: [BpfCoordinator]
    updateUpstreamNetworkState tetherOffloadRule4Clear wlan2

Test case b
06-07 22:17:51.886  [..] Tethering: [bt-pan] cleanupUpstream bt-pan
06-07 22:17:51.888  [..] Tethering: [bt-pan] stopIPv4 bt-pan
06-07 22:18:23.769  [..] Tethering: [wlan2] cleanupUpstream wlan2
06-07 22:18:23.772  [..] Tethering: [wlan2] stopIPv4 wlan2

Test case c
06-08 11:11:48.277  [..] Tethering: [BpfCoordinator]
    updateUpstreamNetworkState tetherOffloadRule4Clear bt-pan
06-08 11:11:48.396  [..] Tethering: [BpfCoordinator]
    updateUpstreamNetworkState tetherOffloadRule4Clear wlan2
06-08 11:11:48.579  [..] Tethering: [wlan2] cleanupUpstreamInterface
    wlan2
06-08 11:11:48.808  [..] Tethering: [bt-pan] cleanupUpstreamInterface
    bt-pan

Enabling NAT failure
06-08 13:04:18.117  [..] Tethering: [wlan2] Exception enabling NAT [..]
06-08 13:04:18.234  [..] Tethering: [wlan2] cleanupUpstream wlan2
06-08 13:04:18.246  [..] Tethering: [wlan2] stopIPv4 wlan2

Change-Id: Id505a3deb277bbe0f44403234d8ca8bbf01eec80
2021-06-23 15:41:27 +08:00
Junyu Lai
69bc4fede1 Merge "[SP32] Try to get 1.1 OffloadControl hardware if available" 2021-06-22 20:31:18 +00:00
Mark Chien
0e57c7e589 Merge changes I270ff43c,Ifc7eee24 am: cec294d1b4 am: 82b26e0d1f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1730548

Change-Id: I382f551487f70865761b4dcd0dcdcdb425538f3e
2021-06-21 13:57:31 +00:00
Remi NGUYEN VAN
3d25f6e8a7 Merge "Add connectivity coverage tests" am: cc79d7c0f8 am: 68114fe408
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1731232

Change-Id: I6cc7f3a3abe97fccc59e14e77e99a0843f3363bb
2021-06-21 13:56:37 +00:00
Mark Chien
cec294d1b4 Merge changes I270ff43c,Ifc7eee24
* changes:
  Add enable and disable ip serving common functions
  Allow to use ncm function for usb tethering
2021-06-21 10:56:45 +00:00
Remi NGUYEN VAN
381358371f Merge "Allow mocking permission in TetheringServiceTest" am: ec48bb82aa am: 4abe3f8db3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1731231

Change-Id: Ic54d721af3ea589f3383cfe9c6dfb32928ba80ac
2021-06-21 10:35:50 +00:00
markchien
cab01b7ebc Allow to use ncm function for usb tethering
Adding the configuration to decide using rndis or ncm for usb tethering.
If ncm is configured for TETHEIRNG_USB, then TETHERING_NCM is not
available.

Bug: 162920185
Test: atest TetheringTests
      manul testing usb tethering
Change-Id: Ifc7eee2457a950a0e2d1c3cc89a3373a7ad23c9c
2021-06-18 11:20:26 +08:00
Remi NGUYEN VAN
fe20e1317d 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.

Test: atest ConnectivityCoverageTests
Change-Id: I5366e1cc9cd6ddb41f24718246381cc2b1cc1383
2021-06-16 19:45:20 +09:00
Remi NGUYEN VAN
0ae7e5bdcd Allow mocking permission in TetheringServiceTest
The test will currently fail if it is run in a package that has
ACCESS_NETWORK_STATE. Add utilities to mock permissions, and mock the
ACCESS_NETWORK_STATE permission to be denied.

Bug: 187935317
Test: atest TetheringServiceTest
Change-Id: I8df5f2ac21bf0314098e8c2e5ba583676ae8ab38
2021-06-16 17:53:10 +09:00
Remi NGUYEN VAN
79471813b4 Merge "Update TetheringTests for new connectivity shims" into sc-dev am: b81724602f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14928587

Change-Id: I3827d12719ddc930a18e8651dd66a2e28b6f92f6
2021-06-10 14:03:59 +00:00
Remi NGUYEN VAN
c94a1ffd55 Update TetheringTests for new connectivity shims
The stable connectivity shims are updated to now contain S API, so
tethering tests that assumed that compatibility R behavior was used need
to be updated.

To avoid such failures Tethering tests should have a test target using
updated shims (TetheringNextTests), but this was not done in S
timeframe.

Ignore-AOSP-First: topic needs differences in AOSP
Bug: 189581241
Test: atest TetheringTests
Change-Id: Ibc04e64a1e9d82b67aff10d1a6d77f9e6b1bbdfb
2021-06-10 13:44:00 +00:00
junyulai
9c5d40beca Fix TetheringTest crash on eng build
startTrackDefaultNetwork was allowed to called multiple times
before even though there is no one actually do it. However,
in the TetheringTest#verifyDefaultNetworkRequestFiled, a
manual invocation is used to ensure that function supports
multiple entrance.

But with aosp/1697371, startTrackDefaultNetwork is no longer
allowed to be called multiple times, it would lead to log.wtf
and crash system in eng build.

Since the manual invocation of startTrackDefaultNetwork is not
realistic and no longer valid anymore, remove the invocation
that caused the trouble.

Test: atest TetheringCoverageTests
Bug: 188613493
Merged-In: I61f6088783d521fd17ae1e87370842b4239fbe75
Change-Id: I61f6088783d521fd17ae1e87370842b4239fbe75
  (cherry-picked from aosp/1711433)
2021-06-09 01:57:37 +00:00
Chiachang Wang
0acaa74538 Correct the logic for CtsTetheringUtils.isWifiTetheringSupported
The existing isWifiTetheringSupported only check if tethering side
supports wifi tethering or not but not wifi side. A expected
behavior should include both of them, so add the wifi side check
into the helper function. Also update in the existing caller side
due to a new parameter added.

Bug: 186061922
Test: atest MtsTetheringTestLatestSdk
Megred-In: Id69ac1d30ab2bbf23e870193335b139f54672636
Change-Id: Id69ac1d30ab2bbf23e870193335b139f54672636
Ignore-AOSP-First: cherry-pick
2021-06-04 13:29:38 +00:00
Chiachang Wang
a3df1ed5f1 Merge changes I5d3e448e,Id69ac1d3 am: 02eea987c0 am: b675eba4c1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1711429

Change-Id: Iede15400f50e5e0f37a95f59b924d8b7dd698509
2021-06-03 09:22:36 +00:00
Chiachang Wang
4f5c4c4323 Correct the logic for CtsTetheringUtils.isWifiTetheringSupported
The existing isWifiTetheringSupported only check if tethering side
supports wifi tethering or not but not wifi side. A expected
behavior should include both of them, so add the wifi side check
into the helper function. Also update in the existing caller side
due to a new parameter added.

Bug: 186061922
Test: atest MtsTetheringTestLatestSdk
Change-Id: Id69ac1d30ab2bbf23e870193335b139f54672636
2021-06-01 15:08:48 +08:00
markchien
3a23d2e2a6 Test tethered callback with TetheringInterface
The old callback only report interface list, new callback could provide
the mapping of interface and type. Replace old callback usage in cts
with new callback and check whether old callback could get the correct
interface list by comparing the result between old and new callback.

Bug: 162920185
Bug: 152203943
Test: atest CtsTetheringTest on S
      atest CtsTetheringTestLatestSdk on R
      atest MtsTetheringTestLatestSdk on S and R
Merged-In: I2a0b8c43fb340c3eaed7f0f90464199222a24280
Change-Id: I2a0b8c43fb340c3eaed7f0f90464199222a24280
2021-06-01 14:36:09 +08:00
markchien
35ad54b25e Add the tethering type to TetheringEventCallback methods
Before this change, tethering always report a list of tethered
interfaces and the caller need to use each tethering type's interface
regex to matching tethered list to manual implement the mapping of
tethering type and interface. This change allow caller to get rid of
tethering interface regex.

Bug: 162920185
Bug: 152203943
Test: atest CtsTetheringTest on S

Merged-In: I91bcccd676d109c1b974497ac29bd366a41b8899
Change-Id: I91bcccd676d109c1b974497ac29bd366a41b8899
2021-06-01 14:35:39 +08:00
Mark Chien
1217274ac0 Merge "Disable tryCell when UpstreamMonitor stop" am: 011552cc54 am: bed1ae7b4c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1715791

Change-Id: I4f55ae5885e3904d0d2d17384875cb00809a0eed
2021-05-24 03:00:20 +00:00
Mark Chien
011552cc54 Merge "Disable tryCell when UpstreamMonitor stop" 2021-05-24 02:27:13 +00:00
Mark Chien
6189804a78 Merge "Test tethered callback with TetheringInterface" into sc-dev am: fcda6f1131
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14622456

Change-Id: Ieaf91ca0b5ebff475a24a21ac0b483591f81207e
2021-05-21 16:24:28 +00:00
Mark Chien
fcda6f1131 Merge "Test tethered callback with TetheringInterface" into sc-dev 2021-05-21 16:04:47 +00:00
markchien
89f2670b65 Disable tryCell when UpstreamMonitor stop
tryCell configuration would not be force disabled UpstreamMonitor stop.
If tethering stop with using mobile upstream and swap with SIM fron no
dun to dun supported, dun request would be filed even tethering is not
active.

Bug: 173068192
Test: atest TetheringTests
Change-Id: I5505655f52da9fdca2fd43a58e043a9ab727741d
2021-05-21 20:35:11 +08:00
Junyu Lai
21c9a28ba0 Merge "Fix TetheringTest crash on eng build" am: ff77e99cf0 am: 2d5584fc34
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1711433

Change-Id: I76bacf4edde90cb658fa74ccd8079a2ba68b9f91
2021-05-21 03:08:37 +00:00
Junyu Lai
ff77e99cf0 Merge "Fix TetheringTest crash on eng build" 2021-05-21 02:40:13 +00:00
markchien
2aa768a7e9 Fix tethering unit test fail in R am: 6cee9c5e04
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14660570

Change-Id: I357e2e93204fb67119e7ec81bcf9020b73912d88
2021-05-20 09:17:20 +00:00
markchien
82f99f95b7 Test tethered callback with TetheringInterface
The old callback only report interface list, new callback could provide
the mapping of interface and type. Replace old callback usage in cts
with new callback and check whether old callback could get the correct
interface list by comparing the result between old and new callback.

Bug: 162920185
Bug: 152203943
Test: atest CtsTetheringTest on S
      atest CtsTetheringTestLatestSdk on R
      atest MtsTetheringTestLatestSdk on S and R
Ignore-AOSP-First: Its dependences CL is not in aosp currently.

Change-Id: I2a0b8c43fb340c3eaed7f0f90464199222a24280
2021-05-20 09:02:39 +00:00
markchien
6cee9c5e04 Fix tethering unit test fail in R
The change aosp/1708088 break tethering unit test in R.

Bug: 187946226
Test: atest TetheringTests in R and S
Change-Id: I4eb4b757f6d7cd3458964c81310dcf0687a4f091
Merged-In: I4eb4b757f6d7cd3458964c81310dcf0687a4f091
2021-05-20 14:52:01 +08:00
markchien
52998bed1d Fix tethering unit test fail in R am: 9eac605333 am: b582c81ee8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1711436

Change-Id: Ie6c845f8169df062db77bdd0f80f591d7fb44a1b
2021-05-20 06:10:55 +00:00
markchien
9eac605333 Fix tethering unit test fail in R
The change aosp/1708088 break tethering unit test in R.

Bug: 187946226
Test: atest TetheringTests in R and S
Change-Id: I4eb4b757f6d7cd3458964c81310dcf0687a4f091
2021-05-19 22:58:36 +08:00
junyulai
7ba566dbf7 Fix TetheringTest crash on eng build
startTrackDefaultNetwork was allowed to called multiple times
before even though there is no one actually do it. However,
in the TetheringTest#verifyDefaultNetworkRequestFiled, a
manual invocation is used to ensure that function supports
multiple entrance.

But with aosp/1697371, startTrackDefaultNetwork is no longer
allowed to be called multiple times, it would lead to log.wtf
and crash system in eng build.

Since the manual invocation of startTrackDefaultNetwork is not
realistic and no longer valid anymore, remove the invocation
that caused the trouble.

Test: atest TetheringCoverageTests
Bug: 188613493
Change-Id: I61f6088783d521fd17ae1e87370842b4239fbe75
2021-05-19 16:23:13 +08:00
markchien
9935dbe03e Add the tethering type to TetheringEventCallback methods
Before this change, tethering always report a list of tethered
interfaces and the caller need to use each tethering type's interface
regex to matching tethered list to manual implement the mapping of
tethering type and interface. This change allow caller to get rid of
tethering interface regex.

Bug: 162920185
Bug: 152203943
Test: atest CtsTetheringTest on S
Ignore-AOSP-First: Currently aosp would automerge to mainlne-prod, merge
to sc-dev first to avoid adding new API to mainline-prod

CTS-Coverage-Bug: I already add cts test(ag/14622456), but Lint
still complaint because my cts is under packages/modules/Connectivity/
but it only check whether CL touching platform/cts
Change-Id: I91bcccd676d109c1b974497ac29bd366a41b8899
2021-05-18 14:47:43 +00:00
Mark Chien
540f0d3ce3 Merge "Test mts against last stable api level" am: a59a146b36 am: 9015e276aa am: 726b814899
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1686012

Change-Id: I9d2d08b9c9397c247e2afd54b25a21631233c585
2021-05-14 10:26:06 +00:00
Mark Chien
a59a146b36 Merge "Test mts against last stable api level" 2021-05-14 09:00:11 +00:00
Nucca Chen
1ed7317a2f Merge "bpf: Add interface index to BPF devmap" am: aa10ddfa6f am: 72bd34e343 am: 76cc470496
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1703125

Change-Id: I5669ff227f761da71d8ad12cf7e0a228b3621d81
2021-05-14 03:25:05 +00:00
Nucca Chen
aa10ddfa6f Merge "bpf: Add interface index to BPF devmap" 2021-05-14 02:45:38 +00:00
Junyu Lai
4ec15d5d71 Merge "[SP32.3] No-op refactoring of OffloadControllerTest" 2021-05-14 02:18:12 +00:00
Mark Chien
ec738f3e36 Merge "Revert "Add ACCESS_NETWORK_STATE to Tethering CTS"" into sc-dev 2021-05-13 17:45:31 +00:00
Mark Chien
0d18d18252 Revert "Add ACCESS_NETWORK_STATE to Tethering CTS"
This reverts commit 90255ef0a7.

Reason for revert: this change break TetheringCoverageTests which test whether guard with proper permission (ACCESS_NETWORK_STATE). Instead of adding permission to test, use runAsShell with ACCESS_NETWORK_STATE: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1699426/1/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java

Bug: 187371740

Change-Id: Id8f27dce237ab34c1a735ce4678e661a6113377e
2021-05-13 17:44:05 +00:00
TreeHugger Robot
4959976b6f Merge "Fix MtsTetheringTest fail to access hidden tethering api problem" into sc-dev 2021-05-13 17:31:01 +00:00
Mark Chien
b88f9f0575 Merge "Fix some TetheringCoverageTest failure" am: 08b89743de am: bf74c05038 am: 3d4f367a25
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1699426

Change-Id: Id89d14377c2df4055d7a701129449a68007d40f1
2021-05-13 16:45:01 +00:00
TreeHugger Robot
3345125c08 Merge changes from topic "sp31" into sc-dev
* changes:
  [SP35] Pass data warning to tethering offload
  [SP34] Adapt onSetWarningAndLimit
2021-05-13 15:52:59 +00:00
Mark Chien
08b89743de Merge "Fix some TetheringCoverageTest failure" 2021-05-13 15:46:02 +00:00
markchien
ac3e0bb7fc Fix MtsTetheringTest fail to access hidden tethering api problem
E.g. Accessing hidden method
Landroid/net/TetheringManager$TetheringInterfaceRegexps;
->getTetherableWifiRegexs()Ljava/util/List; (blacklist, linking, denied)

Bug: 183459282
Test: atest MtsTetheringTest on both R and S platform
Ignore-AOSP-First: change already in AOSP.

Change-Id: I3c5f08615fcf897fac59f2493be5337f78c2fdc7
2021-05-13 15:44:18 +00:00
Junyu Lai
5f32284acd Merge "No-op Refactoring of startTrackDefaultNetwork" am: 7fecf6a017 am: 784f54eefb am: 80ccb96458
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1697371

Change-Id: If974c537e869caa6c0f9914b04bc6dc696c76b9c
2021-05-13 15:30:25 +00:00
Junyu Lai
7fecf6a017 Merge "No-op Refactoring of startTrackDefaultNetwork" 2021-05-13 14:32:00 +00:00
junyulai
a36f33ef90 [SP35] Pass data warning to tethering offload
This is supported by:
  1. Utilize the new API from both NetworkStatsProvider
     and IOffloadControl to send data warning quota to hardware.
     And pass the warning reached notification back to NPMS.
  2. Disable software solution introduced in R release for
     V1.1+ hardware, since now we can fully offload data warning
     and limit notification to hardware.

Test: atest TetheringTests
Fix: 149467454
Ignore-AOSP-First: avoid long automerger delay
Change-Id: Ie49461694d77ab7f25a549433b01b5b0167bd489
2021-05-13 22:08:10 +08:00
junyulai
6d8da9f72d [SP34] Adapt onSetWarningAndLimit
This is a no-op change that just adapt new API from
NetworkStatsProvider to get warning and limit bytes at the same
time. This change also stores them locally for subsequent
patches to set warning bytes to hardware.

Test: Will be included in the subsequent patch.
Bug: 149467454
Ignore-AOSP-First: avoid long automerger delay
Change-Id: Iec01cb01fd1ce481ce0bd736762baddde1e38084
2021-05-13 21:55:31 +08:00
TreeHugger Robot
0b4086c713 Merge "[SP33] Adapt ITetheringOffloadCallback V1.1" into sc-dev 2021-05-13 10:38:33 +00:00
junyulai
5454e8978e [SP33] Adapt ITetheringOffloadCallback V1.1
This is a no-op change that redirect both V1.0 and V1.1 callback
events to the same handling function. Since the V1.1 callback
is extended from V1.0 callback, we can safely use V1.1
callback for both V1.0 and V1.1 control.

The change also provides interface for subsequent
OffloadController changes to set warning and limit at the
same time.

Test: atest TetheringTests
Bug: 149467454
Ignore-AOSP-First: avoid long automerger delay
Change-Id: I6505a04de8c57357dd1fa9ce898c13395e497816
2021-05-13 16:45:40 +08:00