Commit Graph

969 Commits

Author SHA1 Message Date
Nucca Chen
db4ac8ea40 Merge "IpServerTest: add test addRemoveTetherClient" 2022-10-26 06:49:22 +00:00
Hungming Chen
df57abfd4b BpfCoordinatorTest: add testDumpDoesNotCrash
Simple dump test for improving tethering test coverage.

Bug: 255466740
Test: atest BpfCoordinatorTest
Test: dump the content of testDump

Output:
mIsBpfEnabled: true
Polling not started
Stats provider registered
Upstream quota: {}
Polling interval: 5000 ms
Bpf shim: mBpfDownstream6Map{OK}, mBpfUpstream6Map{OK}, mBpfDownstream4Map{OK}, mBpfUpstream4Map{OK}, mBpfStatsMap{OK}, mBpfLimitMap{OK}, mBpfDevMap{OK}
Forwarding stats:
 <empty>
BPF stats:
 ifindex: 1001: rxPackets: 0, rxBytes: 0, rxErrors: 0, txPackets: 0, txBytes: 0, txErrors: 0

Forwarding rules:
 IPv6 Forwarding rules by downstream interface:
  [null]: iif(iface) oif(iface) v6addr [srcmac] [dstmac]
   1001(rmnet0) 1003(1003) 2001:db8::1 [12:34:56:78:90:ab] [00:00:00:00:00:0a]
 IPv6 Upstream: iif(iface) [inDstMac] -> oif(iface) etherType [outSrcMac] [outDstMac]
  1003(1003) [12:34:56:78:90:ab] -> 1001(rmnet0) 86dd [00:00:00:00:00:00] [00:00:00:00:00:00]
 IPv6 Downstream: iif(iface) [inDstMac] neigh6 -> oif(iface) etherType [outSrcMac] [outDstMac]
  1001(rmnet0) [00:00:00:00:00:00] 2001:db8::1 -> 1003(1003) 86dd [12:34:56:78:90:ab] [00:00:00:00:00:0a]
 IPv4 Upstream: proto [inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
  tcp [12:34:56:78:90:ab] 1003(1003) 192.168.80.12:-3087 -> 1001(rmnet0) 1.0.0.1:-3087 -> 140.112.8.116:443 [00:00:00:00:00:00] -
 IPv4 Downstream: proto [inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
  tcp [00:00:00:00:00:00] 1001(rmnet0) 140.112.8.116:443 -> 1003(1003) 1.0.0.1:-3087 -> 192.168.80.12:-3087 [00:00:00:00:00:0a] -

Device map:
 ifindex (iface) -> ifindex (iface)
  1001 (rmnet0) -> 1001 (rmnet0)
Client Information:
 <empty>
IPv4 Upstream Indices:
 <empty>

Forwarding counters:
 INVALID_IPV4_VERSION: 1000

Change-Id: I6346737157936cff7e164bbfe78d9a98dab3395a
2022-10-26 05:48:03 +00:00
Hungming Chen
771bc597b6 Move error count BPF map initialization into class Dependencies
The preparation for testing BpfCoordinator#dump().
Used to wrap error count BPF map access to avoid SYS_SECCOMP on some
test device. Ex: cuttlefish.
https://android-build.googleplex.com/builds/tests/view?invocationId=I01200010101524265&testResultId=TR03228338750686157

Bug: 255466740
Test: atest BpfCoordinatorTest

Change-Id: Id4405b70bc6d500b35943b4f81b88e7515fff3b0
2022-10-26 13:47:19 +08:00
Mark Chien
381e339647 Merge "Remove unused TetheringConfigurationParcel fileds" 2022-10-21 07:50:23 +00:00
Nucca Chen
df46aeb098 Merge "Add toString() to Ipv6ForwardingRule" 2022-10-14 07:27:03 +00:00
Wayne Ma
fe6ecc6333 Add new fields - |upstream_events| and |duration_millis| in stats.proto
Revise annotations in previous fields and deprecate |upstream_type|.

Ignore-AOSP-First: Merge conflict if submits in AOSP first.
Bug: 153942334
Test: statsd_testdrive 303
Change-Id: Id4d594f9238e18266dce5bf2ba238c1f86f655db
(cherry picked from commit 71c8495cea)
Merged-In: Id4d594f9238e18266dce5bf2ba238c1f86f655db
2022-10-12 05:32:12 +00:00
Hungming Chen
afdf104d68 IpServerTest: add test addRemoveTetherClient
Bug: 250552545
Test: atest IpServerTest
Change-Id: Id8e801ccbf9a958c6b82de6022165d921761a86f
2022-10-04 23:14:55 +08:00
Hungming Chen
de5fb7370b Add toString() to Ipv6ForwardingRule
Needed because default Ipv6ForwardingRule#toString doesn't dump
actual data. It is hard to know why two rule comparison failed
in the test failure.

Bug: 250552545
Test: atest BpfCoordinatorTest
Change-Id: Iaf29c888238573c7c9a0a4e0bd65fbe468084e51
2022-10-04 23:14:55 +08:00
Hungming Chen
09d163dfa8 BpfCoordinator: ignore stopping event monitoring if never started
Ignore stopping monitoring if the monitor has never started
for a given IpServer.

Also fix the related bug in
BpfCoordinator#testStartStopConntrackMonitoring.

Bug: 250552545
Test: atest BpfCoordinatorTest
Change-Id: I7ac71f0ed52bf52244aadaa3c90ca8df239873e4
2022-10-03 11:56:38 +00:00
Junyu Lai
3e7778805b Merge "Revert^2 "[ST02.2] Use the getters of DnsHeader"" 2022-09-22 02:39:42 +00:00
Sorin Basca
14343732c3 Fix errorprone 2.15.0 errors
Bug: 246761518
Test: RUN_ERROR_PRONE=true m javac-check lint-check dist
Change-Id: I4b81ef161fab5ee80a1713de87b89500a88e625e
2022-09-21 13:29:19 +01:00
Hungming Chen
c79efc8e8e EthernetTetheringTest: test testTetherClatTcp on S+ device
Only test testTetherClatTcp on S+ device because R device test
is blocked on b/234727688.

Bug: 234727688
Test: atest EthernetTetheringTest
Change-Id: I65a4a8c4fe13b8320b036380b9038af094ac95a5
2022-09-20 10:24:32 +00:00
Hungming Chen
b4f8a08825 EthernetTetheringTest: add testTetherClatTcp
Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: Ic66c22040ca8aa29b8399fabed066107a736e842
2022-09-19 19:43:34 +08:00
Hungming Chen
2ef51d11eb EthernetTetheringTest: add testTetherTcpV6
Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: I476a8d984eb8ccb6b2e64d6c36dbb455029a4c51
2022-09-19 19:43:30 +08:00
Hungming Chen
53ce3df628 EthernetTetheringTest: add testTetherTcpV4
Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: I411ac8dc0a36413e2e65633375218b25c412e004
2022-09-19 19:43:14 +08:00
Hungming Chen
e2fb681aec EthernetTetheringTest: add testIcmpv4Echo
Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: I96278c17ce97b63860b9379675c6ac2941b4016f
2022-09-19 15:53:15 +08:00
Hungming Chen
90551145ae EthernetTetheringTest: add testTetherClatIcmp
Bug: 237369591
Test: atest EthernetTetheringTest
Change-Id: I9dad9b559e0963a2d3a3f6a4c8d3b159a185801d
2022-09-19 15:53:11 +08:00
Junyu Lai
4c93f83290 Revert^2 "[ST02.2] Use the getters of DnsHeader"
Reason for revert: November mainline trains has been branched,
                   re-submit CLs and request API review.

Re-submitted Changes:
Ib5616c65c:[ST02.2] Use the getters of DnsHeader
I5e58f99b0:[ST02.1] Add TYPE_CNAME constant to DnsResolver
I0c1547cbc:[ST02] Add methods for synthesizing DNS packets

Change-Id: Ifb727e464d3523bd8dee0f2d919a8fb4a9d207c5
2022-09-16 07:41:27 +00:00
Treehugger Robot
1949d98e81 Merge "Revert "UpstreamNetworkMonitor: add NOTIFY_TEST_NETWORK_AVAILABLE"" 2022-09-14 14:25:13 +00:00
Treehugger Robot
4e81086326 Merge "EthernetTetheringTest: toggle wifi while test network is not selected" 2022-09-14 14:25:13 +00:00
Hungming Chen
d09bb0773a EthernetTetheringTest: toggle wifi while test network is not selected
Used to avoid flaky test because upstream changed events
order can't be guaranteed. Once tethering choose non-test
upstream {wifi, ..}, test network wont't be chosen.

Fix flaky tests which are using initTetheringTester():
testIcmpv6Echo
testTetherClatUdp
testTetherUdpV4_VerifyBpf
testTetherUdpV4
testTetherUdpV4Dns
testTetherUdpV6

Moreover, add permission ACCESS_WIFI_STATE to AndroidManifest.xml
to avoid nested runAsShell while using CtsNetUtils to access WIFI.

STACKTRACE:
java.lang.IllegalStateException: adoptShellPermissionIdentity calls must not be nested
at com.android.testutils.TestPermissionUtil.runAsShell(TestPermissionUtil.kt:49)
at com.android.testutils.TestPermissionUtil.runAsShell(TestPermissionUtil.kt:70)
at com.android.testutils.TestPermissionUtil.runAsShell$default(TestPermissionUtil.kt:65)
at com.android.testutils.TestPermissionUtil.runAsShell(Unknown Source:16)
at android.net.cts.util.CtsNetUtils.disconnectFromWifi(CtsNetUtils.java:293)
at android.net.cts.util.CtsNetUtils.disconnectFromWifi(CtsNetUtils.java:255)
at android.net.cts.util.CtsNetUtils.toggleWifi(CtsNetUtils.java:160)

Bug: 243314243
Test: atest EthernetTetheringTest
Change-Id: I814899ae71f5c302d490a0dd81d7210ac138faa5
2022-09-14 04:03:24 +00:00
KH Shi
b259ee802f Merge "Fix TetheringServiceTest#testTetheringManagerLeak flaky" 2022-09-13 11:16:13 +00:00
Treehugger Robot
f62267c7db Merge "EthernetTetheringTest: use EthernetManager to check iface before T" 2022-09-13 11:10:31 +00:00
Hungming Chen
f927fbae30 EthernetTetheringTest: use EthernetManager to check iface before T
For cuttlefish before T, TetheredInterfaceRequester may be responded
to over 200ms. That causes tests to become flaky. Using ethernet
manager to check available tethering interface instead of repeated
increases TetheredInterfaceRequester timeout
AVAILABLE_TETHER_IFACE_REQUEST_TIMEOUT_MS.

Bug: 243314243
Test: atest EthernetTetheringTest

Change-Id: I9cfab19adf1a54be82040da225c89b6570a36d4c
2022-09-13 09:37:36 +00:00
KH Shi
b254987348 Fix TetheringServiceTest#testTetheringManagerLeak flaky
The clearance of the weak reference to TetheringManager can't be a
confirmation check of the completion running of its finalization.
The weak references to a weakly-reachable object will be cleared
before it becomes eligible for finalization. Calling of
System.runFinalization() method doesn't guarantee finalizers are
executed synchronously. In fact, finalizer of TetheringManager is
running in a different thread in this test.

GCs and finalizers behaviors could be vary on different JVMs.
Due to the unsynchronization, besides the weak reference of
TetheringManager, we need to add retries to the checking of
unregister Tethering internal callback as well.

Bug: 243340454
Test: atest TetheringServiceTest#testTetheringManagerLeak --iterations 10000
Change-Id: I8231146f26deb0825dadb70d8d0dbdc963989558
2022-09-13 05:56:29 +00:00
Treehugger Robot
ae2faae09a Merge "EthernetTetheringTest: reduce test upstream prefix range" 2022-09-11 13:34:16 +00:00
Motomu Utsumi
08ccd0d2e1 Merge changes from topic "idiag_sock_id"
* changes:
  Switch SkDestroyListener based on the flag.
  Add startSkDestroyListener flag to native_init
  Add SkDestroyListenerTest
2022-09-10 02:02:11 +00:00
Anton Hansson
3483b9b35c Merge changes from topic "revert-1387135-st02-CRMRFENEPA"
* changes:
  Revert "[ST02.1] Add TYPE_CNAME constant to DnsResolver"
  Revert "[ST02.2] Use the getters of DnsHeader"
2022-09-09 07:58:06 +00:00
Remi NGUYEN VAN
c7043880ef Revert "[ST02.2] Use the getters of DnsHeader"
Revert submission 1387135-st02

Reason for revert: Usage of TYPE_CNAME in a library shared among
modules does not interact well with current module release process

Reverted Changes:
Ib5616c65c:[ST02.2] Use the getters of DnsHeader
I5e58f99b0:[ST02.1] Add TYPE_CNAME constant to DnsResolver
I0c1547cbc:[ST02] Add methods for synthesizing DNS packets

Change-Id: Ia35cb3e21cd90e036a07018e2d9c1ee662ce86a2
2022-09-08 11:01:05 +00:00
Nucca Chen
b7fe0667db EthernetTetheringTest: reduce test upstream prefix range
Change upstream address prefix range from "10.0.0.0/8" to
"10.0.0.1/24" for reducing the flaky rate which caused by the
downstream address prefix conflict with upstream address.
Especially, "10.0.0.0/8" is one of downstream address prefix
range candidate. See PrivateAddressCoordinator.

Bug: 243314243
Change-Id: If995f1d20ac52b84757ac3dec198cae1ebb7e272
Test: atest EthernetTetheringTest
2022-09-08 02:00:12 +00:00
Junyu Lai
7119e9cf5e Merge changes from topic "st02"
* changes:
  [ST02.2] Use the getters of DnsHeader
  [ST02.1] Add TYPE_CNAME constant to DnsResolver
2022-09-07 02:25:41 +00:00
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