Commit Graph

988 Commits

Author SHA1 Message Date
Treehugger Robot
4f062b3f62 Merge "EthernetTetheringTest: give slack time for waiting UDP stream mode" 2022-09-06 15:10:39 +00:00
Hungming Chen
dc311c8aa5 EthernetTetheringTest: give slack time for waiting UDP stream mode
Give slack time for waiting UDP stream mode because handling conntrack
event in user space may not in precise time. Used to reduce the flaky
rate.

Bug: 243314243
Test: atest EthernetTetheringTest
Change-Id: I7aee1a45d9a4d4fecf09739488dcaadeb7e86655
2022-09-06 18:25:01 +08:00
Motomu Utsumi
116af0d892 Add SkDestroyListenerTest
SkDestroyListener monitors the destroy of IPv4/IPv6 TCP/UDP sockets and
removes CookieTagMap entries.
SkDestroyListenerTest closes 100 sockets at once and check all the
entries are removed from the CookieTagMap.

Bug: 217624062
Test: atest MtsTetheringTestLatestSdk

Change-Id: I161006f4ae5bd83085e68bf8de260f04f3da0ea0
2022-09-06 11:23:09 +09:00
Nucca Chen
6cafe04787 Revert "UpstreamNetworkMonitor: add NOTIFY_TEST_NETWORK_AVAILABLE"
This reverts commit 82e7733909.

Reason for revert: don't modify production code for testing only

Change-Id: I19826c3308774ce6f62a2748b4e038500aec33e2
2022-09-05 03:25:33 +00:00
Motomu Utsumi
171c817072 Merge "Use IBpfMap type instead of BpfMap type" 2022-08-31 03:54:28 +00:00
Patrick Rohr
d407328dd4 Merge "Fix EthernetTetheringTest flaky" 2022-08-26 16:37:28 +00:00
Hungming Chen
008adcd004 TetheringTester: Extend PACKET_READ_TIMEOUT_MS from 100ms to 500ms
No DHCPACK received in DHCP process. Because previous DISCOVER/OFFER
steps have done, it implies that DHCP server is launched and
client/server can transmit data to each other. Assume that DHCP server
can reply DHCPACK and CF may need more than 100ms.

Extend the timeout from 100ms to 500ms. Monitor if receiving DHCPACK
timeout is found.

Bug: 243314243
Test: atest EthernetTetheringTest
Change-Id: Id8bb0e03ae1e853beb6242a1c35b977ace9ca190
2022-08-26 16:52:29 +08:00
Mark
f8371fef0f Fix EthernetTetheringTest flaky
The tracking interface of EthernetTracker(mTetheringInterface) is
stopped to track only when it is removed. There is race condition in
EthernetTetheringTest that the new test start ethernet tethering with
previous test interface name because EthernetTracker still tracking
previous test interface.
Destroy test interface then listen untether callback without calling
stopTethering. If EthernetTracker stop tracking test interface, it would
call onUnavailable callback to stop tethering. So the test can check
whether tethering is stopped to ensure the test interface is not tracked
anymore before test finish.

Bug: 191826409
Bug: 243222655
Test: atest TetheringIntegrationTests

Change-Id: I618983d981cd3a707dcb7723cdbb20ba5bf8bd2e
2022-08-26 14:10:54 +08:00
Junyu Lai
ec2b24784f [ST02.2] Use the getters of DnsHeader
Bug: 139774492
Test: atest DnsPacketTest DnsResolverTest
Change-Id: Ib5616c65cce9668e7c6a00571c34ece7b4d8ab39
2022-08-25 14:06:30 +08:00
Motomu Utsumi
73599a5f5d Use IBpfMap type instead of BpfMap type
Currently, production code uses BpfMap type and TestBpfMap extends
BpfMap but this makes it diffcult to test because TestBpfMap loads the
JNI.

This CL updates to use IBpfMap type in the production code.
Upcoming CL updates TestBpfMap to implement IBpfMap instead of extending
BpfMap so that test can still use TestBpfMap but tests do not need to
load JNI.

Bug: 217624062
Test: atest BpfCoordinatorTest BpfNetMapsTest
Change-Id: Ie67e14bf5519fb4427474ecc0fda441877a9555f
2022-08-24 23:31:19 +09:00
Nucca Chen
b19c482980 Merge "EthernetTetheringTest: testTetherUdpV4Dns" 2022-08-24 08:30:56 +00:00
Motomu Utsumi
9988869442 Merge changes from topic "cookie_tag_map_raw_dump"
* changes:
  Add option to dump cookieTagMap in base64 format
  Use BpfDump#fromBase64EncodedString
2022-08-24 03:16:53 +00:00
Hungming Chen
a339588d62 EthernetTetheringTest: testTetherUdpV4Dns
Add a tethering IPv4 DNS test.

DNS query:
tethered device --> downstream --> dnsmasq forwarding --> upstream --> DNS server

DNS reply:
DNS server --> upstream --> dnsmasq forwarding --> downstream --> tethered device

Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: I2baa9d7ccf55d117f644c80e867fb8272f7daac5
2022-08-24 11:15:36 +08:00
Mark Chien
0d3c8b692d Merge "updateSupportedDownstreams when tethering allowed is changed" 2022-08-22 15:15:11 +00:00
Mark
c2cc1b42b8 updateSupportedDownstreams when tethering allowed is changed
There are three configuration could affect tethering allowed:
1. user restriction
2. tether_supported settings
3. ro.tether.denied system properties

When user restricted or tether supported setting change, updating
supported downstreams.
ro.tether.denied is read only properties, so it won't be changed runtime.

Also correct the unit test that there is no TetheringConfiguration change when settings or user restriction change.

Bug: 184996041
Bug: 239500515
Test: atest TetheringTests

Change-Id: I8dfcc42de9787a5e9ba19b69db9444c14ace56f0
2022-08-18 05:42:05 +00:00
Motomu Utsumi
e70bdb8f36 Use BpfDump#fromBase64EncodedString
aosp/2179274 adds fromBase64EncodedString to BpfDump.
This CL updates EthernetTetheringTest to use this function instead of
parseMapKeyValue in EthernetTetheringTest.

Bug: 217624062
Test: atest EthernetTetheringTest
Change-Id: I56b3cd875e16bee6174f0aacd468562ae482cef9
2022-08-18 12:46:54 +09:00
Maciej Żenczykowski
09813ced3e replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifbb7139e9118dd2d0c52e83c5874132e03760b30
2022-08-18 01:07:11 +00:00
Maciej Żenczykowski
91f7d6d906 Merge changes from topic "ethernet-tethering-test-on-cf"
* changes:
  UpstreamNetworkMonitor: add NOTIFY_TEST_NETWORK_AVAILABLE
  EthernetTetheringTest: obtain the required permissions when needed
  Use TetheredInterfaceRequester to check available tethering interface
2022-08-17 17:50:40 +00:00
Xin Li
4455a72e41 Merge "DO NOT MERGE - Merge Android 13" 2022-08-16 19:11:46 +00:00
Mark Chien
40caeb78f3 Remove unused TetheringConfigurationParcel fileds
Bug: 237338640
Test: atest TetheringTests

Change-Id: Ic851e2e9ed16b5be6f5b1380f6b905fcc1e131cf
2022-08-16 15:58:44 +00:00
Mark
b8d1afd408 Manual start tethering if it doesn't restart automatically
Because of race condition inside tethering module, restart tethering is
not reliable when address conflict. Manual start it for testing if it
doesn't restart automatically.

Bug: 176048959
Bug: 240878641
Bug: 178560045
Bug: 178116595

Test: atest MtsTetheringTestLatestSdk
Change-Id: Id1473b968cd20afde70bca1903114df6f0b510a8
2022-08-16 13:17:54 +08:00
Hungming Chen
82e7733909 UpstreamNetworkMonitor: add NOTIFY_TEST_NETWORK_AVAILABLE
Used for test interface upstream can replace existing non-test
upstream interface, like ethernet on cuttlefish.

This helps to fix the flaky test when we are using test interface on
cuttlefish. Because the ethernet and test interface upstream update
event order can't be guaranteed.

Bug: 237369591
Bug: 242067530

Test: atest ConnectivityCoverageTests
Change-Id: I9da71ee116bf1ebc9831f61f25acf42e328a8370
2022-08-15 17:38:06 +08:00
Hungming Chen
f2d62614cc EthernetTetheringTest: obtain the required permissions when needed
Don't adopt all permission in setup, instead obtain permission when
needed. It helps to avoid unexpected permission dropping in functions.

Bug: 237369591
Bug: 242067530

Test: atest EthernetTetheringTest

Change-Id: I1215278271ca6b48e097d7f2cf160416d5411655
2022-08-15 17:38:02 +08:00
Hungming Chen
f70037fa88 Use TetheredInterfaceRequester to check available tethering interface
Used for deciding what test needs to be run. Moreover, the
EthernetManager#isAvailable is not used for this purpose
anymore. The restricted networks permission is not required
as well.

Bug: 237369591
Bug: 242067530
Test: atest EthernetTetheringTest
Change-Id: I1215278271ca6b48e097d7f2cf160416d54116f2
2022-08-15 17:37:57 +08:00
Treehugger Robot
7aaf823fe9 Merge "TestOnly: reduce duplicated start/stop hotspot verification" am: b40cbad40c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2171108

Change-Id: Ic03dd521ff98e53687a6bd7b3a275c12759640c5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-10 17:26:00 +00:00
Treehugger Robot
b40cbad40c Merge "TestOnly: reduce duplicated start/stop hotspot verification" 2022-08-10 16:13:51 +00:00
Mark
0a1a97250d TestOnly: reduce duplicated start/stop hotspot verification
Test: atest TetheringTests
Change-Id: Id6469c5be4a424a68e370bea475dc7399a0037ac
2022-08-10 12:24:13 +00:00
Hungming Chen
10348ae532 BpfCoordinator: avoid attach/deatach ipv6 program on 464xlat interface am: 1668b2da03
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2175693

Change-Id: I4699c563b21f3ed2455802b52c5563749265a29a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-08 16:55:21 +00:00
Hungming Chen
1668b2da03 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
2022-08-08 20:56:50 +08:00
Treehugger Robot
8a6cabe946 Merge "BpfCoordinator: avoid attach/deatach duplicate downstream program" am: 896b893500
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2174903

Change-Id: I5a94f2e318ae2bde6c88bfd74f125f226e50be73
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-06 11:38:53 +00:00
Treehugger Robot
896b893500 Merge "BpfCoordinator: avoid attach/deatach duplicate downstream program" 2022-08-06 11:05:35 +00:00
Treehugger Robot
f97b43e3f3 Merge "Remove mts-tethering from TetheringIntegrationTests" am: 5a316a06e0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2170623

Change-Id: I7c2f4cfdda6e47d80dceec4c2f1679e4c869af25
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-06 07:43:01 +00:00
Hungming Chen
6f54391340 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
2022-08-05 20:56:04 +08:00
Remi NGUYEN VAN
86d7a05d16 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
2022-08-01 03:01:38 +00:00
Treehugger Robot
836b65b10c Merge changes I99bd5c9d,Id1676567 am: d70c34fef2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2160996

Change-Id: I205a368403b33a8541116947e59bd45a1000c310
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-29 11:08:18 +00:00
Treehugger Robot
d70c34fef2 Merge changes I99bd5c9d,Id1676567
* changes:
  EthernetTetheringTest: separate out tether IPv4 UDP BPF offload tests
  EthernetTetheringTest: use wrapper to send test UDP packet
2022-07-29 10:41:54 +00:00
Hungming Chen
30dfd666a1 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
2022-07-29 05:41:09 +00:00
Hungming Chen
5b11293d25 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
2022-07-29 05:40:19 +00:00
Treehugger Robot
fdb585566c Merge "EthernetTetheringTest: add testTetherUdpV6" am: ce5ea3619d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2135057

Change-Id: I8f19420ea4af45bd2dc2ae8d978a6578cb4d238b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-28 15:10:52 +00:00
Treehugger Robot
ce5ea3619d Merge "EthernetTetheringTest: add testTetherUdpV6" 2022-07-28 14:44:33 +00:00
Mark Chien
b03b4dd899 Merge changes I41ae1d61,I334860af am: 794d04d779
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2167064

Change-Id: Ic38c1111925c571ae020a3d0b2437939bd844dfa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-28 02:49:10 +00:00
Mark Chien
794d04d779 Merge changes I41ae1d61,I334860af
* changes:
  Make tethering APIs unsupported synchronously when disallowed
  Revert "Revert "Add onSupportedTetheringType callback""
2022-07-28 02:22:07 +00:00
Hungming Chen
5157b1e69c 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
2022-07-27 21:21:42 +08:00
Mark
cf230301e3 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
2022-07-27 09:41:42 +00:00
Hungming Chen
7a5b5c9ff4 BpfMapTest: add fd leak test am: a81f1251dd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2162428

Change-Id: Ie59096dd9998db69046c6e8856e155b1f8dd0d8b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-27 02:22:29 +00:00
Hungming Chen
a81f1251dd 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
2022-07-26 14:23:29 +00:00
Mark Chien
d124a1e322 Merge "Stop using adoptShellPermissionIdentity in setUp" am: ad3eab1c8b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2120226

Change-Id: I77a0bbaa5288d90f1fa8f8aca9ca4e414555e473
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-23 03:59:54 +00:00
Mark Chien
ad3eab1c8b Merge "Stop using adoptShellPermissionIdentity in setUp" 2022-07-23 03:38:14 +00:00
Mark Chien
874a3e273e Revert "Revert "Add onSupportedTetheringType callback""
This reverts commit 4bf22ae076.

Reason for revert: land the change again

Change-Id: I334860af201ce0faa09f1dbb8935bc9fddd66c50
2022-07-20 06:18:13 +00:00
Xiao Ma
75b5d34c34 Merge "Make Tethering module depend on net-utils-device-common-ip." am: c02e565aac
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2128873

Change-Id: I6e9f5550047a7e4544076bbfbba89f96ab05f4da
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-14 03:07:02 +00:00