Commit graph android_packages_modules_Co.../Tethering
Message SHA1
Merge "[CTT-4] Improve conntrack timeout update logging"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2021-07-13 02:11:59 +00:00
8d2e46aec3
Merge "[CTT-3] Add a string converter for TCP and UDP protocol number"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2021-07-13 02:10:09 +00:00
7d3d4eaca7
Merge "[CTT-2] Clean up unused {function, exception} and improve readability"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2021-07-13 02:09:36 +00:00
d6ca2420bb
Merge "[CTT-1] Rename conntrack related function, variable and constant"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2021-07-13 02:09:00 +00:00
2c2eccac73
[CTT-4] Improve conntrack timeout update logging
Bug: 190783768
Bug: 192804833

Test: atest TetheringCoverageTests

Change-Id: I56792d75d12a0207e0a83a6d64e303f3bbfc3c6a

Hungming Chen   commited 2021-07-11 15:06:22 +08:00
8d2bbd865a
[CTT-3] Add a string converter for TCP and UDP protocol number
Bug: 190783768
Bug: 192804833

Test: atest TetheringCoverageTests
Change-Id: I6a6452b65dd994fcf392e51917be52537a9d4cd9

Hungming Chen   commited 2021-07-11 15:05:56 +08:00
916ba672b7
[CTT-2] Clean up unused {function, exception} and improve readability
- Remove ipv4MappedAddressBytesToIpv4Address because it can be covered
  by parseIPv4Address.
- Remove IllegalArgumentException from parseIPv4Address because it has
  never happened
- Reverse the order of upstream and downstream timeout refreshing in
  refreshAllConntrackTimeouts for readability because both source and
  destination of the downstream are opposite direction to the
  upstream.

Bug: 190783768
Bug: 192804833
Test: atest TetheringCoverageTests
Change-Id: I6a1e44777a4357dd3847c2e2bb1fc6c3cf01617c

Hungming Chen   commited 2021-07-11 15:05:39 +08:00
71b85591ea
[CTT-1] Rename conntrack related function, variable and constant
Bug: 190783768
Bug: 192804833
Test: atest TetheringCoverageTests

Change-Id: Ib7ba480138b8aa8c6f8dffaa97787bac74a3972e

Hungming Chen   commited 2021-07-11 15:04:37 +08:00
378bdbc2ef
Remove catch clause on compat shim
registerSystemDefaultNetworkCallback no longer throws
UnsupportedApiLevelException as it has compatibility behavior down to Q,
so remove the catch clause for the checked exception.

The exception would previously not be thrown since the Tethering module
is only running on R+.

Bug: 182961265
Test: atest TetheringTests
Change-Id: I3c58235f3a59294995e5f32502fec6ccd17a3cf0

Remi NGUYEN VAN   commited 2021-07-09 10:24:44 +09:00
ca5530ed1d
Merge "Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-07-06 03:39:31 +00:00
844ca1290e
Merge "Enable and disable usb IpServer according to ACTION_USB_STATE"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-07-06 03:39:15 +00:00
d479e694f0
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

markchien   commited 2021-07-05 23:11:50 +08:00
b28740ec89
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

markchien   commited 2021-07-05 22:53:07 +08:00
b41a00e778
Merge "ipv4 tethering offload - decrement ttl during forwarding"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2021-07-02 21:06:41 +00:00
f21f5357e7
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>
Change-Id: I88e5293a54b7867a8e7dd76f6fd8e2a52d31e51a

Maciej Żenczykowski   commited 2021-07-02 11:33:17 +00:00
c29af79e26
Merge "Dump the protocol of IPv4 offload rule"
Nucca Chen   authored and   Gerrit Code Review   commited 2021-07-01 07:27:20 +00:00
3746fdd293
Dump the protocol of IPv4 offload rule
Print the protocol {tcp, udp} of v4 rules in dumpsys.

Format:
proto [inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
  udp [00:00:00:00:00:00] 14(rmnet0) 74.125.10.156:443
  -> 30(30) 10.254.92.123:60262 -> 192.168.128.240:60262
  [0a:bd:b5:e0:41:53] 96067ms

Bug: 190783768
Test: dumpsys tethering
Change-Id: Idae1042cfb454cc97b9b103587f11bc0700e0787

Hungming Chen   commited 2021-07-01 11:52:12 +08:00
3004f0d8d9
Merge "Apply jarjar rules on coverage tests"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-30 23:53:57 +00:00
d590b30f72
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

Remi NGUYEN VAN   commited 2021-06-30 16:00:26 +09:00
8ea5ee6d33
Enable tethering to perform its own hidden API processing
Previously, the hidden API encoding of the tethering boot dex jars,
i.e. those dex jars that tethering contributes to the bootclasspath
were done as part of the monolithic hidden API processing. This change
causes the encoding to be done by the tethering's
bootclasspath_fragment.

This change involves the following:
* Addition of the fragments property to the tethering's
  bootclasspath_fragment module to list all the other
  bootclasspath_fragment modules on which this depends.
* Addition of the additional_stubs property to add stubs for APIs that
  are not provided by another bootclasspath_fragment.

The build automatically checks that the hidden API flags which are
computed by tethering and encoded into its boot dex jars match those
that are generated by the monolithic processing so this is guaranteed
to be safe.

Bug: 179354495
Test: m com.android.tethering
      - ensure that the generated APEX is byte-for-byte identical
        before and after these changes.
      m out/soong/hiddenapi/hiddenapi-flags.csv
      - make sure that they are not changed by this.
(cherry picked from b28cb44e4b)

Merged-In: I4d9621325c7fcea5043cbca4c577ba2ac6125c0c
Change-Id: I4d9621325c7fcea5043cbca4c577ba2ac6125c0c

Paul Duffin   commited 2021-06-30 00:00:41 +01:00
f9a0c868c4
Dump the unused IPv4 BPF rule age correctly
Print a dash for the unused "lastUsed" of the rule.

The age should not equal the bootime if the rule has never been
updated the "lastUsed" field.

Format:
[inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
[00:00:00:00:00:00] 14(rmnet0) 140.112.8.116:443
-> 30(30) 10.170.56.233:43720
-> 192.168.45.236:43720 [be:34:40:28:33:5f] -

Test: dumpsys tethering
Change-Id: Ie771becd2f72518cf02a86e5ae228315785752a5

Hungming Chen   commited 2021-06-29 16:21:49 +08:00
e7dff2f955
Merge "Fix OffloadControllerTest on R"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-06-29 05:02:47 +00:00
767b2180e9
Merge "Make "dumpsys tethering" print the number of registered callbacks."
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-06-28 09:50:04 +00:00
1e50b3ea24
Merge "Remove wigig support from S tethering"
Treehugger Robot   authored and   Gerrit Code Review   commited 2021-06-28 07:51:07 +00:00
0b44491744
Merge "Fix ConnectivityManagerTest initialization on Q"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-28 07:24:49 +00:00
72f59b3019
Merge "Fix and test usb function configuration change"
Mark Chien   authored and   Gerrit Code Review   commited 2021-06-28 04:16:14 +00:00
840e2efd7f
Make "dumpsys tethering" print the number of registered callbacks.
Test: manual
Bug: 177265744
Change-Id: I07f56459125d5629dcafe5683eecb42d0ef9e2bd

Lorenzo Colitti   commited 2021-06-28 12:46:37 +09:00
ced68f5993
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

markchien   authored and   Mark Chien   commited 2021-06-28 02:59:33 +00:00
34f7857b07
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

Remi NGUYEN VAN   commited 2021-06-28 11:24:27 +09:00
0d54d7992d
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

Remi NGUYEN VAN   commited 2021-06-28 10:15:57 +09:00
9207702d66
Merge "Improve TestConnectivityManager readability"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-27 23:47:45 +00:00
883df67f3f
Merge "Refresh conntrack entry timeout"
Nucca Chen   authored and   Gerrit Code Review   commited 2021-06-25 18:34:22 +00:00
a569410667
Merge "Clear IPv4 offload rules when tethering stopped"
Nucca Chen   authored and   Gerrit Code Review   commited 2021-06-25 17:56:21 +00:00
7238b31c15
Merge "Update TetheringTests for new connectivity shims"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-25 05:42:14 +00:00
86b39c8c34
Remove wigig support from S tethering
Bug: 176520801
Test: atest TetheringTests
Change-Id: Id0bf02c01419e0c69a1d0b6a41789826538444d3

markchien   commited 2021-06-25 00:31:43 +08:00
8f9705126a
[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)

junyulai   authored and   Junyu Lai   commited 2021-06-24 08:33:28 +00:00
991433d8c8
[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)

junyulai   authored and   Junyu Lai   commited 2021-06-24 08:33:28 +00:00
da52dab266
[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)

junyulai   authored and   Junyu Lai   commited 2021-06-24 08:33:28 +00:00
37a7e620b4
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

Remi NGUYEN VAN   commited 2021-06-24 17:17:54 +09:00
2e0f0da0b7
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

Remi NGUYEN VAN   commited 2021-06-24 17:17:54 +09:00
11e5cf0b0b
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

Hungming Chen   commited 2021-06-23 15:41:30 +08:00
c27ec7c4a2
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

Hungming Chen   commited 2021-06-23 15:41:27 +08:00
a6e7869646
Merge "[SP32] Try to get 1.1 OffloadControl hardware if available"
Junyu Lai   authored and   Gerrit Code Review   commited 2021-06-22 20:31:18 +00:00
69bc4fede1
Merge changes I270ff43c,Ifc7eee24
* changes:
  Add enable and disable ip serving common functions
  Allow to use ncm function for usb tethering

Mark Chien   authored and   Gerrit Code Review   commited 2021-06-21 10:56:45 +00:00
cec294d1b4
Merge "Add connectivity coverage tests"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-21 10:55:33 +00:00
cc79d7c0f8
Merge "Allow mocking permission in TetheringServiceTest"
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2021-06-21 10:19:07 +00:00
ec48bb82aa
Add enable and disable ip serving common functions
This is a op CL which prepare for refactor.

Bug: 185649441
Bug: 189410000
Bug: 178116595

Test: atest TetheringTests
Change-Id: I270ff43c01736b9d18bd40a8e88e1379e9e4e863

markchien   commited 2021-06-18 21:35:40 +08:00
76e2e1c702
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

markchien   commited 2021-06-18 11:20:26 +08:00
cab01b7ebc
Merge "Correctly dump IPv4 downstream flows."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2021-06-16 11:15:30 +00:00
a8afcd3b0e
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

Remi NGUYEN VAN   commited 2021-06-16 19:45:20 +09:00
fe20e1317d