Commit Graph

656 Commits

Author SHA1 Message Date
Nucca Chen
199e86dcb3 Revert "[CTT-5] Stop update TCP conntrack entry timeout"
This reverts commit a5c742be69.

Reason for revert:
Stop releasing this commit because it needs more test coverage.

Bug: 190783768
Bug: 192804833
Change-Id: I6e6b40b0f6207ed197d01bfabb616f1afa31fb70
Test: atest TetheringCoverageTests
2021-07-20 08:52:38 +00:00
Nucca Chen
254ba6b235 Revert "[CTT-6] Update TCP conntrack entry timeout while adding rules"
This reverts commit 299a81157c.

Reason for revert:
Stop releasing this commit because it needs more test coverage.

Bug: 190783768
Bug: 192804833
Change-Id: I6a0d93e04814ae73e1ec7d6fd4df19e1d2787207
Test: atest TetheringCoverageTests
2021-07-20 08:50:49 +00:00
Treehugger Robot
ed62eb3a5b Merge "Skip bpf offload if upstream interface is VCN" am: 097d65b0f3 am: 9743c8165e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764307

Change-Id: Id3546b8888439ee9228fb2b5687b117165fdbbd7
2021-07-13 17:45:37 +00:00
Treehugger Robot
097d65b0f3 Merge "Skip bpf offload if upstream interface is VCN" 2021-07-13 17:16:04 +00:00
markchien
7dc1b4da7b Skip bpf offload if upstream interface is VCN
Bpf offload do not support VCN network yet, don't start bpf offload
if the interface is ipsec*.

Bug: 191178945
Test: atest TetheringTests
Change-Id: I1ad8cededddec42f45b08aaa31d583c548d105f0
2021-07-13 15:35:31 +00:00
Nucca Chen
523e11ef67 Merge "[CTT-6] Update TCP conntrack entry timeout while adding rules" am: db30678605 am: f22f935082
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760692

Change-Id: I759b26fa36116578c84fd6c226725ece3fbe5b7c
2021-07-13 12:31:16 +00:00
Nucca Chen
709d91215f Merge "[CTT-5] Stop update TCP conntrack entry timeout" am: 69ccea4839 am: 23e3eadde5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760691

Change-Id: Idf2680669d1c881f3d1846f379f5a8163c4ac274
2021-07-13 12:31:10 +00:00
Nucca Chen
db30678605 Merge "[CTT-6] Update TCP conntrack entry timeout while adding rules" 2021-07-13 12:07:05 +00:00
Nucca Chen
69ccea4839 Merge "[CTT-5] Stop update TCP conntrack entry timeout" 2021-07-13 12:06:55 +00:00
Hungming Chen
299a81157c [CTT-6] Update TCP conntrack entry timeout while adding rules
Needed because a payload data packet may have gone through
non-offload path, before we added offload rules, and that this
may result in in-kernel conntrack state being in ESTABLISHED
but pending ACK (ie. UNACKED) state. But the in-kernel conntrack
might never see the ACK because we just added offload rules.
As such after adding the rules we need to force the timeout back
to the normal ESTABLISHED timeout of 5 days.

Issue: the timeout is set to unacknowledged 300s (countdwon to 298s)
$ adb shell cat /proc/net/nf_conntrack
ipv4     2 tcp      6 298 ESTABLISHED src=192.168.244.128
dst=140.112.8.116 sport=45694 dport=443 ..

Test: atest TetheringCoverageTests
Manual check:
$ adb shell cat /proc/net/nf_conntrack
ipv4     2 tcp      6 431988 ESTABLISHED src=192.168.40.162
dst=140.112.8.116 sport=40774 dport=443 ..

Bug: 190783768
Bug: 192804833

Change-Id: I8c34e85e26c9d976e5e2b85473db75ff46d8abd4
2021-07-13 14:28:30 +08:00
Hungming Chen
a5c742be69 [CTT-5] Stop update TCP conntrack entry timeout
This is a preparation for only update the tcp timeout while
adding rules. Also add slack time for updating UDP timeout
interval.

Bug: 190783768
Bug: 192804833

Test: atest TetheringCoverageTests
Change-Id: I3151b531e6581e257f3cfa39ad2fcf1650358b3d
2021-07-13 14:26:58 +08:00
Maciej Żenczykowski
954c8d383e Merge "[CTT-1] Rename conntrack related function, variable and constant" am: 2c2eccac73 am: d85fc83e41
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1762185

Change-Id: Ie0b8eee8dd649432835ef89369d3ac2e6166d8da
2021-07-13 02:44:53 +00:00
Maciej Żenczykowski
2c2eccac73 Merge "[CTT-1] Rename conntrack related function, variable and constant" 2021-07-13 02:09:00 +00:00
Hungming Chen
378bdbc2ef [CTT-1] Rename conntrack related function, variable and constant
Bug: 190783768
Bug: 192804833
Test: atest TetheringCoverageTests

Change-Id: Ib7ba480138b8aa8c6f8dffaa97787bac74a3972e
2021-07-11 15:04:37 +08:00
Lorenzo Colitti
25423d4f5e Merge "Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true" am: 844ca1290e am: 51f5f61742
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755176

Change-Id: Iceb3d25f31da76f4f12115a7ceabd68a81faebfa
2021-07-06 04:04:42 +00:00
Lorenzo Colitti
86d7e6bbb4 Merge "Enable and disable usb IpServer according to ACTION_USB_STATE" am: d479e694f0 am: 736df2cb2f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1731453

Change-Id: I334710d0bbbe18a769a79fb58d10a558dd8f7b37
2021-07-06 04:04:36 +00:00
Lorenzo Colitti
844ca1290e Merge "Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true" 2021-07-06 03:39:31 +00:00
Lorenzo Colitti
d479e694f0 Merge "Enable and disable usb IpServer according to ACTION_USB_STATE" 2021-07-06 03:39:15 +00:00
markchien
b28740ec89 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
Change-Id: I0c542560bd04e8c0a6a78d632da5a00a34d9a3fa
2021-07-05 23:11:50 +08:00
markchien
b41a00e778 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
Change-Id: I8375e3f998d677dc658370b2553facaec0d5ff7c
2021-07-05 22:53:07 +08:00
Remi NGUYEN VAN
4a980eebf5 Merge "Apply jarjar rules on coverage tests" am: d590b30f72 am: 073f6e299a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1749680

Change-Id: I80209723541bdfb8f5b08cd5e9cf0e76afa3593e
2021-07-01 01:08:32 +00:00
Remi NGUYEN VAN
d590b30f72 Merge "Apply jarjar rules on coverage tests" 2021-06-30 23:53:57 +00:00
Remi NGUYEN VAN
8ea5ee6d33 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
Change-Id: Ib95b58dab93f7adebc445b662a6d15db1ce0e7c2
2021-06-30 16:00:26 +09:00
Treehugger Robot
897ed3fc3d Merge "Fix OffloadControllerTest on R" am: 767b2180e9 am: 634ad9792d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1748154

Change-Id: I2cd282bf6d7a4638cbb65f20f2ccd886ec113713
2021-06-29 05:24:11 +00:00
Treehugger Robot
767b2180e9 Merge "Fix OffloadControllerTest on R" 2021-06-29 05:02:47 +00:00
Remi NGUYEN VAN
9f4a31af59 Merge "Fix ConnectivityManagerTest initialization on Q" am: 72f59b3019 am: 82a32e3f4a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1740779

Change-Id: I40abcac7db563480fe3c13fb5e0178d7a3629652
2021-06-28 07:40:27 +00:00
Remi NGUYEN VAN
72f59b3019 Merge "Fix ConnectivityManagerTest initialization on Q" 2021-06-28 07:24:49 +00:00
Mark Chien
4114bb1a2a Merge "Fix and test usb function configuration change" am: 840e2efd7f am: 717c8ff590
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1740778

Change-Id: Iac2ab9a589c878bee92179956df7802ea51c7a3e
2021-06-28 04:39:21 +00:00
Mark Chien
840e2efd7f Merge "Fix and test usb function configuration change" 2021-06-28 04:16:14 +00:00
markchien
34f7857b07 Fix and test usb function configuration change
Allow stop TETHERING_NCM no matter ncm is used for TETHERING_USB or
TETHERING_NCM.

Add a test:
1. NCM is started for TETHERING_NCM
2. The config changes to use NCM for TETHERING_USB.
3. Then the config changes to use RNDIS for TETHERING_USB.

Also let some logs not only print in dumpsys, but also in logcat to
easiler debug unit test.

Bug: 185649441
Test: atest TetheringTests
Change-Id: Ia8d76a29646f36941cbb16cd68ae6887100ec8ec
2021-06-28 02:59:33 +00:00
Remi NGUYEN VAN
0d54d7992d 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
Change-Id: I87488d0f23628a1ef2d7af0242513fcc5401d598
2021-06-28 11:24:27 +09:00
Remi NGUYEN VAN
9207702d66 Fix OffloadControllerTest on R
Data warning is not supported on R, and the notifyWarningOrLimitReached
callback also only exists in S.

Bug: 182962001
Test: atest OffloadControllerTest
Change-Id: I4914240967bba341f16e505acd29b80b90ab8569
2021-06-28 10:15:57 +09:00
Remi NGUYEN VAN
59be04dcca Merge "Improve TestConnectivityManager readability" am: 883df67f3f am: 265ec28e25
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1733779

Change-Id: Ic81a3604724855233dffc4e989bcee69feb8d91c
2021-06-28 00:13:10 +00:00
Remi NGUYEN VAN
883df67f3f Merge "Improve TestConnectivityManager readability" 2021-06-27 23:47:45 +00:00
Nucca Chen
2791e3fe11 Merge "Refresh conntrack entry timeout" am: a569410667 am: a729b103ff
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1566871

Change-Id: I5508b5b47d17c01d2ce95fb30d9dfc14e279f932
2021-06-25 18:55:47 +00:00
Nucca Chen
8516b3f120 Merge "Clear IPv4 offload rules when tethering stopped" am: 7238b31c15 am: 70504b2f6b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1579873

Change-Id: Ibfea3e14e0e06a59c3b29534ab5ffbf4d4bd2148
2021-06-25 18:55:09 +00:00
Nucca Chen
a569410667 Merge "Refresh conntrack entry timeout" 2021-06-25 18:34:22 +00:00
Nucca Chen
7238b31c15 Merge "Clear IPv4 offload rules when tethering stopped" 2021-06-25 17:56:21 +00:00
Remi NGUYEN VAN
86b39c8c34 Merge "Update TetheringTests for new connectivity shims" 2021-06-25 05:42:14 +00:00
junyulai
991433d8c8 [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
Merged-In: Ie49461694d77ab7f25a549433b01b5b0167bd489
Change-Id: Ie49461694d77ab7f25a549433b01b5b0167bd489
  (cherry-picked from ag/13981692)
2021-06-24 08:33:28 +00:00
junyulai
da52dab266 [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
Merged-In: Iec01cb01fd1ce481ce0bd736762baddde1e38084
Change-Id: Iec01cb01fd1ce481ce0bd736762baddde1e38084
  (cherry-picked from ag/13981691)
2021-06-24 08:33:28 +00:00
junyulai
37a7e620b4 [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
Merged-In: I6505a04de8c57357dd1fa9ce898c13395e497816
Change-Id: I6505a04de8c57357dd1fa9ce898c13395e497816
  (cherry-picked from ag/13973147)
2021-06-24 08:33:28 +00:00
Remi NGUYEN VAN
2e0f0da0b7 Improve TestConnectivityManager readability
Remove NetworkCallbackInfo to use Handler directly, and separate
registerSystemDefaultNetworkCallback from requestNetwork.

Also verify that requestNetwork is only used with a default-like network
request on R, as S should be using registerSystemDefaultNetworkCallback.

Test: atest TetheringTests
Bug: 189581241
Change-Id: If6b9124b2d795b9db1e85256c694d0120c852542
2021-06-24 17:17:54 +09:00
Remi NGUYEN VAN
11e5cf0b0b 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.

Bug: 189581241
Test: atest TetheringTests
Merged-In: Ibc04e64a1e9d82b67aff10d1a6d77f9e6b1bbdfb
Change-Id: Ibc04e64a1e9d82b67aff10d1a6d77f9e6b1bbdfb
2021-06-24 17:17:54 +09:00
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