Commit graph android_packages_modules_Co.../Tethering/tests
Message SHA1
Merge "TestOnly: reduce duplicated start/stop hotspot verification"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-08-10 16:13:51 +00:00
b40cbad40c
TestOnly: reduce duplicated start/stop hotspot verification
Test: atest TetheringTests
Change-Id: Id6469c5be4a424a68e370bea475dc7399a0037ac

Mark   commited 2022-08-10 12:24:13 +00:00
0a1a97250d
BpfCoordinator: avoid attach/deatach ipv6 program on 464xlat interface
464xlat interface v4-* doesn't have IPv6 address. IPv6 program should
not be attached/deatached on v4-* interface.

Bug: 241106456
Test: atest BpfCoordinatorTest
Test: manual test

Use IPv6-only wifi to test because there is no IPv6-only live
cellular environment here.

1. Patch TetheringInterfaceUtils.allowIpv6Tethering to allow WIFI.
2. Connect to IPv6-only wifi Google-Guest.
3. Enable USB tethering.
4. Check that v4-wlan0 doesn't have IPv6 program.

$ adb shell tc filter show dev wlan0 ingress;
filter protocol ipv6 pref 2 bpf chain 0
filter protocol ipv6 pref 2 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_downstream6_ether:[*fsobj] direct-action not_in_hw id 2 tag 7d9be9d02d02e8d8
filter protocol ip pref 3 bpf chain 0
filter protocol ip pref 3 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_downstream4_ether:[*fsobj] direct-action not_in_hw id 8 tag 434b3ecac7968bb3
filter protocol ipv6 pref 4 bpf chain 0
filter protocol ipv6 pref 4 bpf chain 0 handle 0x1 prog_clatd_schedcls_ingress6_clat_ether:[*fsobj] direct-action not_in_hw id 24 tag 06763574e0e1f984

$ adb shell tc filter show dev v4-wlan0 ingress;
filter protocol ip pref 3 bpf chain 0
filter protocol ip pref 3 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_downstream4_rawip:[*fsobj] direct-action not_in_hw id 6 tag 9e6e587e0c6cf0bc

$ adb shell tc filter show dev v4-wlan0 egress;
filter protocol ip pref 4 bpf chain 0
filter protocol ip pref 4 bpf chain 0 handle 0x1 prog_clatd_schedcls_egress4_clat_rawip:[*fsobj] direct-action not_in_hw id 27 tag 9158397a2869247e

$ adb shell tc filter show dev ncm0 ingress;
filter protocol ipv6 pref 2 bpf chain 0
filter protocol ipv6 pref 2 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_upstream6_ether:[*fsobj] direct-action not_in_hw id 3 tag 5f70a4f42dffe899
filter protocol ip pref 3 bpf chain 0
filter protocol ip pref 3 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_upstream4_ether:[*fsobj] direct-action not_in_hw id 9 tag 26f324113d54c30a

Change-Id: Ic1c1cfc7646b4d4004856850b66428e4651d42ab

Hungming Chen   commited 2022-08-08 20:56:50 +08:00
1668b2da03
Merge "BpfCoordinator: avoid attach/deatach duplicate downstream program"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-08-06 11:05:35 +00:00
896b893500
BpfCoordinator: avoid attach/deatach duplicate downstream program
The forwarding pairs may use the same downstream. Ex: 464xlat
tethering has rmnet0:ncm0, v4-rmnet0:ncm0 forwarding pairs.
Need to avoid duplicate downstream program.

Bug: 241106456
Test: atest BpfCoordinatorTest
Change-Id: Ic41b3ad856e4876808f8497a760081afcfd04988

Hungming Chen   commited 2022-08-05 20:56:04 +08:00
6f54391340
Remove mts-tethering from TetheringIntegrationTests
TetheringIntegrationTests is not in MTS (it is not part of the tests
list XML); but CtsTetheringTestLatestSdk contains all its tests and is
part of MTS.

Remove the mts-tethering tag to avoid confusion and get faster build
times.

Change-Id: Ic68fad48179cbf206a8867b81afc76e89f085772
Test: m

Remi NGUYEN VAN   commited 2022-08-01 03:01:38 +00:00
86d7a05d16
Merge changes I99bd5c9d,Id1676567
* changes:
  EthernetTetheringTest: separate out tether IPv4 UDP BPF offload tests
  EthernetTetheringTest: use wrapper to send test UDP packet

Treehugger Robot   authored and   Gerrit Code Review   commited 2022-07-29 10:41:54 +00:00
d70c34fef2
EthernetTetheringTest: separate out tether IPv4 UDP BPF offload tests
Refactor test testTetherUdpV4* into basic tethering test and tethering
BPF offload tests which breakdown into three tests:
- testTetherUdpV4_VerifyBpf
- testKernelSupportBpfOffloadUdpV4
- testTetherConfigBpfOffloadEnabled

These tests provide a easy way to know if BPF offload is verified or
which condition caused a skip.

Example:
  Disable offload in tethering config
  packages/modules/Connectivity/Tethering/res/values/config.xml
  config_tether_enable_bpf_offload: false

  [..] testTetherUdpV4: PASSED (229ms)
  [..] testTetherUdpV4_VerifyBpf: ASSUMPTION_FAILED (2ms)
  [..] testKernelSupportBpfOffloadUdpV4: PASSED (1ms)
  [..] testTetherConfigBpfOffloadEnabled: ASSUMPTION_FAILED (13ms)

Bug: 237369591
Bug: 238288883

Test: atest EthernetTetheringTest
Change-Id: I99bd5c9d6be9a67cdeb809d46c907754f21ca5eb

Hungming Chen   authored and   Nucca Chen   commited 2022-07-29 05:41:09 +00:00
30dfd666a1
EthernetTetheringTest: use wrapper to send test UDP packet
Using send{Download, Upload}PacketUdp() in test
{testTetherUdpV4*, testTetherClatUdp} helps reduce the redundant
codes.

Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: Id1676567b9a9885ce8f65ff86a682653910ea150

Hungming Chen   authored and   Nucca Chen   commited 2022-07-29 05:40:19 +00:00
5b11293d25
Merge "EthernetTetheringTest: add testTetherUdpV6"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-07-28 14:44:33 +00:00
ce5ea3619d
Merge changes I41ae1d61,I334860af
* changes:
  Make tethering APIs unsupported synchronously when disallowed
  Revert "Revert "Add onSupportedTetheringType callback""

Mark Chien   authored and   Gerrit Code Review   commited 2022-07-28 02:22:07 +00:00
794d04d779
EthernetTetheringTest: add testTetherUdpV6
Add tethering IPv6 UDP test and fix a bug which may apply wrong
ethernet type to ethernet header builder.

Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: I0d619b6e338d082366d5b2c305047d8f2ebf630d

Hungming Chen   commited 2022-07-27 21:21:42 +08:00
5157b1e69c
Make tethering APIs unsupported synchronously when disallowed
To backward compatible existing behavior, make tethering APIs
unsupported synchronously when tethering is disallowed. There
are two APIs register/unregisterTetheringEventCallback still
supported even tethering is disallowed.
This could avoid some existing tests flaky. The test assume
startTethering would fail right away after tethering restricted
apply.

Bug: 184996041
Bug: 239500515
Test: atest TetheringTests
Change-Id: I41ae1d61647c9baf69bcb246965e8d9b4a89b497

Mark   commited 2022-07-27 09:41:42 +00:00
cf230301e3
BpfMapTest: add fd leak test
Test that there is no fd leak with persistent fd cache.

Bug: 236320567
Test: atest BpfMapTest#testNoFdLeaks (cached fd) [PASSED]
Test: atest BpfMapTest#testNoFdLeaks (noncached fd) [FAILED] (as expected)
[8/14] com.android.networkstack.tethering.BpfMapTest#testNoFdLeaks: FAILED (241ms)

STACKTRACE:
java.lang.AssertionError: Fd leak after 1000 iterations:  expected:<89> but was:<1089>
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.failNotEquals(Assert.java:835)
	at org.junit.Assert.assertEquals(Assert.java:647)
	at com.android.networkstack.tethering.BpfMapTest.testNoFdLeaks(BpfMapTest.java:420)

Test Code:
fd noncached BpfMap
frameworks/libs/net/common/device/com/android/net/module/util/BpfMap.java
@@ -97,7 +97,7 @@ public class BpfMap<K extends Struct, V extends Struct> implements IBpfMap<K, V>
      */
     public BpfMap(@NonNull final String path, final int flag, final Class<K> key,
             final Class<V> value) throws ErrnoException, NullPointerException {
-        mMapFd = cachedBpfFdGet(path, flag);
+        mMapFd = ParcelFileDescriptor.adoptFd(nativeBpfFdGet(path, flag));

Change-Id: I66f477fd1c291c56bccc97d385b2a554c2367b5a

Hungming Chen   authored and   Nucca Chen   commited 2022-07-26 14:23:29 +00:00
a81f1251dd
Merge "Stop using adoptShellPermissionIdentity in setUp"
Mark Chien   authored and   Gerrit Code Review   commited 2022-07-23 03:38:14 +00:00
ad3eab1c8b
Revert "Revert "Add onSupportedTetheringType callback""
This reverts commit 4bf22ae076.

Reason for revert: land the change again

Change-Id: I334860af201ce0faa09f1dbb8935bc9fddd66c50

Mark Chien   authored and   Mark   commited 2022-07-20 06:18:13 +00:00
874a3e273e
Make Tethering module depend on net-utils-device-common-ip.
NetworkStack module utils are duplicated to net-utils-device-common-ip,
delete the module utils source code and use net-utils-device-common-ip
instead.

Bug: 235901424
Test: atest TetheringTests
Change-Id: I19fe72a92d6de1084963c2b3a38d094f8da2a91e

Xiao Ma   commited 2022-07-13 04:32:28 +00:00
c81c066958
Merge "Revert "Add onSupportedTetheringType callback""
Mark Chien   authored and   Gerrit Code Review   commited 2022-07-12 07:30:50 +00:00
370ba4f3c5
Revert "Add onSupportedTetheringType callback"
This reverts commit ae3d303344.

Reason for revert: this cause GTS fail
Bug: 238038401

Change-Id: I3e21321e931f60208cb0befaed38e58b088ff966

Mark Chien   commited 2022-07-12 02:11:48 +00:00
4bf22ae076
Use frameworks/libs/net version of SharedLog
Test: m
Bug: 235901424
Change-Id: Ibfa7821c68c41036a47e765f15078cd5d195afb8

Patrick Rohr   commited 2022-07-07 12:52:58 -07:00
b873e25ab4
Merge "Use BpfDump.toBase64EncodedString to dump raw map"
Nucca Chen   authored and   Gerrit Code Review   commited 2022-07-06 12:04:54 +00:00
bf28a595f2
Stop using adoptShellPermissionIdentity in setUp
Using adoptShellPermissionIdentity in setUp to use the shell permission
idnetity in whole test make the test not easy to
development. If the test want to use the library which would also
start/stop shell permission identity, this let the test lose shell
identify unexpectly after using that library. Only adopt shell permission
idnetity when necessary instead.

Test: atest CtsTetheringTest
Change-Id: I6cf24e6cbf227944bc914446337a247dc350562a

Mark   commited 2022-07-05 11:24:20 +00:00
ee2699379f
Move struct {Clat*, Tether4*, TetherStats*} to connectivity module
Needed because these struct classes should not be exposed.
Only used for the connectivity module and its tests.

Bug: 234160319
Test: atest ConnectivityCoverageTests

The moved files are identical.

diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatEgress4Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatEgress4Key.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatEgress4Value.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatEgress4Value.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatIngress6Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatIngress6Key.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatIngress6Value.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatIngress6Value.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/Tether4Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/Tether4Key.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/Tether4Value.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/Tether4Value.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/TetherStatsKey.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/TetherStatsKey.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/TetherStatsValue.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/TetherStatsValue.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatEgress4Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatEgress4Key.java
(no diff)

Change-Id: I4ce8045150bdbf04c63c5262c58a0ebcc30d395c

Hungming Chen   authored and   Nucca Chen   commited 2022-06-29 11:34:19 +00:00
01f2550ac4
Merge "Ignore BPF tethering offload test if tether config is disabled"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-06-29 07:57:56 +00:00
dd9a89c2f2
Fix metrics doesn't work if multiple tethering requested
There is a bug in TetheringMetrics that the on-going builders would be
cleared when creating new builder. This means if multiple tethering
created at the same time, only latest tethering would have metrics.

Bug: 153942334
Test: atest TetheringTests
Change-Id: I16a66790bc19072d8ffe570348bcbafa91263573

Mark   authored and   Mark Chien   commited 2022-06-28 10:31:02 +00:00
26cf9b6728
Ignore BPF tethering offload test if tether config is disabled
Needed because OEM can disable BPF offload by PRO.

Bug: 237144191
Bug: 236925089
Test: atest EthernetTetheringTest
Change-Id: Idf965caa44aeaae1f084d2c4fcd516a352c1b138

Hungming Chen   commited 2022-06-27 15:11:23 +08:00
b37f76f28e
Use BpfDump.toBase64EncodedString to dump raw map
Move base64 related bpf map function and constant to f/l/n.
This is preparation for testing BPF map in ClatCoordinator.

Test: atest EthernetTetheringTest
Change-Id: Ieb1e0a0f128c9aa0d7c9f043e90eecf3c61252f5

Hungming Chen   commited 2022-06-23 21:42:20 +08:00
264cac59bb
[TestOnly] Use probeV4TetheringConnectivity in getClatIpv6Address
Test: atest EthernetTetheringTest
Change-Id: Ib741e4f9cd452c7ce37e829210d30046a9f391ef

Mark   commited 2022-06-14 04:38:33 +00:00
06238c1aa6
[TestOnly]Create TetheringTester in initTetheringTester
If tethering's upstream have ipv6, the #initTetheringTester
would make sure ipv6 tethering connectivity is ready for testing.

Test: atest EthernentTetheringTest

Change-Id: Iade99eeb95fa94483248799eb852a81662bbb1e0

Mark   commited 2022-06-13 09:01:53 +00:00
01971ad969
[TestOnly] Move isExpectedUdpPacket into TetheringTester
isExpectedUdpPacket and isIcmpv6Type is similar util, put them in the
same place and have isExpectedIpPacket to share the ip/eth parsing code.

Test: atest EthernetTetheringTest
Change-Id: I3ede46f5ff1799f575fad7aca277f2bc0bf6c391

Mark   commited 2022-06-13 09:01:42 +00:00
73284988cd
[TestOnly]Remove RemoteResponder from TetheringTester
This is no-op change. Originally RemoteResponder design for providing a
base responder that user could extend it like DnsServerResponder,
TcpResponder, UdpResponder. But actually user could just simply extend
TetheringTester that make RemoteResponder useless. Thus, remove it to
simply the code.

Test: atest EthernetTetheringTest
Change-Id: I47b22a1460ca312c678778143033aadf5e3e0b82

Mark Chien   authored and   Mark   commited 2022-06-13 09:00:27 +00:00
03693623c1
Merge "[TestOnly] Replace isRouterAdvertisement with isIcmpv6Type"
Mark Chien   authored and   Gerrit Code Review   commited 2022-06-08 02:15:53 +00:00
4fcf168399
[TestOnly] Replace isRouterAdvertisement with isIcmpv6Type
Test: atest EthernetTetheringTest
Change-Id: I5dca7a05a982139d8fc6f8272c8b829b74a34722

Mark   commited 2022-06-07 15:29:34 +00:00
6078d6edd6
Skip testTetherClatUdp before S
The test does not pass on R.

Bug: 234727688
Test: atest EthernetTetheringTest
Change-Id: I831859e521b026ed4acb84de5857a7d3ec318ba5

Remi NGUYEN VAN   commited 2022-06-03 12:04:23 +09:00
8b56874caa
Revert "Revert "EthernetTetheringTest: add testTetherClatUdp""
This reverts commit 5bbd292bed.

Bug: 215655463
Change-Id: I06490001b06446b6a4ff3dc084ce11e8ebbe17f8
Test: atest ConnectivityCoverageTests

Remi NGUYEN VAN   commited 2022-06-03 02:55:26 +00:00
e78cfa130b
Revert "EthernetTetheringTest: add testTetherClatUdp"
This reverts commit b0274cf796.

Reason for revert: Breaks presubmit: b/234727688

Change-Id: I736752dca3707588a525f28d208bdb20f7280972

Remi NGUYEN VAN   commited 2022-06-03 02:32:48 +00:00
5bbd292bed
EthernetTetheringTest: add testTetherClatUdp
Bug: 215655463
Test: atest ConnectivityCoverageTests
Change-Id: Id5d237b96b1d171c1e353cfd0aeba5aa4606fcc7

Hungming Chen   commited 2022-06-02 12:07:13 +08:00
b0274cf796
Merge "Add tethering icmpv6 forwarding test"
Mark Chien   authored and   Gerrit Code Review   commited 2022-06-01 15:15:37 +00:00
86a800f911
Merge "Bump tethering target sdk to 33"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-06-01 08:57:46 +00:00
d10244feb8
Add tethering icmpv6 forwarding test
Bug: 183166581
Test: atest EthernetTetheringTest

Change-Id: I77ad4a468530f3ef834cd7b72e585798a23f64c3

markchien   authored and   Mark Chien   commited 2022-05-31 23:53:47 +08:00
a40f2fe746
Bump tethering target sdk to 33
Note: to avoid missing some dependeices change only happen in T+, below
testing verification is perform by internal branch.

Test: atest TetheringTests
      atest TetheringIntegrationTests
      atest CtsTetheringTest
      atest MtsTetheringLatestSdk
      manually change entitlement check recheck period to 1 min and
      monitor schedule alarm works.
      Dogfood this change personally 7 days, major use hotspot sharing network to notebook to work.
Bug: 232193147
Change-Id: I3cba98f42ac1a9c0c1db4b2ad036aff714a428f3

Mark Chien   commited 2022-05-31 03:31:18 +00:00
d25a1e05ae
Merge "Test testTetherUdpV4AfterR only verify bpf in precise kernel range"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-27 19:03:58 +00:00
875daa69eb
Test testTetherUdpV4AfterR only verify bpf in precise kernel range
Use three-part kernel version numbers to check which device
needs to verify BPF offload. Only check major and minor number
is not enough. Ex: mixed build T + R may have an unsupported kernel
version 4.19.160 (require 4.19.176+). Now check the subminor
number as well.

For UDPv4 support, kernel require 4.14.222+ 4.19.176+ 5.4.98+, 5.8.0+

Test: atest EthernetTetheringTest (raven @ internal master build)
Test: cts test (bramble @ T + R mixed build)
> run cts-on-gsi -m CtsTetheringTest -t android.net.EthernetTetheringTest#testTetherUdpV4AfterR

Bug: 232332847
Change-Id: I466df73b0fa35b086a2c5e11f8624c84eb79c8fd

Hungming Chen   commited 2022-05-27 22:15:24 +08:00
d7e713283d
Fix incorrect sdk version check in SCV2 device test
Test: atest ConnectivityCoverageTests:com.android.networkstack.tethering.OffloadControllerTest
Bug: 229190480
Change-Id: I4e37a9d6634daac14ef41ab30ab986b2e96dacd4

Frank   commited 2022-05-24 13:55:03 +08:00
a632356e05
Merge "fix BpfMapTest"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-05-20 07:44:13 +00:00
e273ba1e21
Fix testUpdateConnectedClientsForLocalOnlyHotspot
testUpdateConnectedClientsForLocalOnlyHotspot should not run before T,
but it don't be ignored correctly because missing DevSdkIgnoreRule
setup.

Bug: 233077722
Test: TH
Change-Id: Ib2d241f927ccdc5d2bc392962481ecb86a223e09

Mark Chien   commited 2022-05-19 21:14:21 +08:00
7e4eab5153
Merge "Register localOnly softapCallback for local only hotspot"
Mark Chien   authored and   Gerrit Code Review   commited 2022-05-17 09:07:38 +00:00
46c86bbf82
Prepare for refactoring wifi ipserver start/stop
This is a preparing change.
1) In enableWifiIpServing, replace
   ensureIpServerStarted(ifname) +
   changeInterfaceState(ifname, ipServingMode)
   with enableIpServing(TETHERING_WIFI, ifname, ipServingMode).

   And checking whether corresponding wifi or p2p feature is
   avaialble before enableWifiIpServing. Note: If the wifi or p2p
   feature wasn't supported before, it would still call
   changeInterfaceState without ipServer created but
   changeInterfaceState would be no-op because there is no
   corresponding ipServer for changing state.

2) Splitting enableWifiIpServing into enableWifiIpServing and
   enableWifiP2pIpServing.

3) No longer guess the interface name after T. WIFI_AP_STATE_CHANGED
   intent should always include ifname and it should be tracked by
   mTetherStates. If OEM have modification in wifi framework to send
   empty ifname, tethering no longer support this after T.

4) After T, tethering always trust the ifname which pass by wifi or p2p
   intent broadcast and treat it as TETHERING_WIFI or
   TETHERING_WIFI_P2P. This allow tethering to deprecate wifi/p2p regexs
   after T.

Bug: 189410000
Bug: 178116595
Bug: 185451791
Bug: 190145323
Bug: 176048959

Test: atest TetheringTests

Change-Id: Ia5f69ddf2d842536ce0df75eeae57866f56df571

markchien   commited 2022-05-16 21:17:40 +08:00
f2e9409f55
Register localOnly softapCallback for local only hotspot
Before T, wifi local only mode won't update onConnectedClientsChanged.
To support updating tethered client information for localOnly hotspot,
register localOnly softap callback to get connected wifi client update.

Bug: 171928468
Test: atest TetheringTests

Change-Id: I0e974feea9497809ea02a4138c7b9c2c584a8a45

markchien   commited 2022-05-16 15:09:10 +08:00
4ccb419602
Merge changes from topic "tethering_metrics"
* changes:
  Add tethering stats into statsd
  Injecting tethering stats into statsd

Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-16 05:06:01 +00:00
42f38d0bdf