Commit Graph

988 Commits

Author SHA1 Message Date
Mark Chien
2c7e2b8448 Merge changes Ibe22b300,I0b0f0bf1 into main
* changes:
  SyncSM08: handle IpServer requestEnableTethering callback in mainSM
  SyncSM07.1: Add a test that shows tethering restarts when disabling
2023-10-27 08:50:04 +00:00
KH Shi
f92d211c71 Merge "Pass upstream prefixes to bpf tethering offload" into main 2023-10-27 07:23:52 +00:00
Jean Chalard
23376e6fe7 Merge "Add forwarding methods to RoutingCoordinator" into main 2023-10-27 05:12:07 +00:00
KH Shi
3f738fcd3d Pass upstream prefixes to bpf tethering offload
BPF needs upstream prefixes information to filter spoofing IPv6 source
addresses carried in downstream traffic.

We retrieve prefixes from upstream interface's LinkProperties and pass
it to the BpfCoordinator. Forwarding rules will also be updated when
upstream interface's IPv6 link addresses change.

Test: atest TetheringTests
Bug: 261923493
Change-Id: If8cfc3b191e520ca838654d1b5211ab9e9ec021d
2023-10-26 13:13:38 +00:00
Chalard Jean
55ccfe19e2 Add forwarding methods to RoutingCoordinator
Test: RoutingCoordinatorServiceTest
      TetheringTest
Change-Id: Ic3b36ddc236e8615e7d931b6e526556bbd2dac17
2023-10-26 20:18:48 +09:00
Mark
5cc386bdef SyncSM08: handle IpServer requestEnableTethering callback in mainSM
This can make it easier to adopt SM shim replacement in follow up change,
as both SyncSM and AsyncSM will process the same message without any
difference.

This change also fix a problem that bring up downstream before it's
IpServer completely disabled.

Previous:
CMD_NOTIFY_PREFIX_CONFLICT -> requestEnableTethering(false) ->
requestEnableTethering(true) -> IpServer stopped ->
reportTetherStateChanged(downstream inactive) -> IpServer started
-> reportTetherStateChanged(downstream active)
New:
CMD_NOTIFY_PREFIX_CONFLICT -> requestEnableTethering(false) ->
IpServer stopped -> reportTetherStateChanged(downstream inactive)
-> requestEnableTethering(true) -> IpServer started
-> reportTetherStateChanged(downstream active)

Test: atest MtsTetheringTestLatestSdk
Change-Id: Ibe22b300c56125359f4fa452bd01a0a2381fda23
2023-10-26 09:28:22 +00:00
Mark
d81f6ef4db SyncSM07.1: Add a test that shows tethering restarts when disabling
When tethering restarts due to an IP conflict, it starts to
bring up downstream before its IpServer is completely disabled.

Test: atest TetheringTests
Change-Id: I0b0f0bf1bb9ac8421c05fe512d5082d095fa7180
2023-10-26 09:26:37 +00:00
Mark
2150296476 SyncSM07: Replace IpServer's state machine with StateMachineShim
A simple replacement without changing any behavior.

Test: atest TetheringTests
Change-Id: I34903b57df68081e974163edec82a851ee4ccc98
2023-10-26 09:26:15 +00:00
Mark
2ec1595d0b SyncSM06: Add StateMachineShim
Test: atest StateMachineShimTest

Change-Id: Ic818aa55e7e0fd7a62dfce50a6ad719e6e1c44ec
2023-10-26 09:24:55 +00:00
Jean Chalard
4e47533688 Merge "Add a routing coordinator class" into main 2023-10-25 09:13:16 +00:00
Mark Chien
cc26d678f2 Merge "Fix testRequestDownstreamAddressWithoutUsingLastAddress flaky" into main 2023-10-25 03:41:10 +00:00
Chalard Jean
2fb66f1b28 Add a routing coordinator class
Test: In followup changes : RoutingCoordinatorManagerTest
Change-Id: Ia6811d614e02123a072c7638291828745abae051
2023-10-24 22:12:26 +09:00
Mark Chien
66ef9d35ce Merge changes I427360f6,Ie6dbbe22 into main
* changes:
  SyncSM05.1: add testMultiDepthTransition
  SyncSM05: add SyncStateMachineTest
2023-10-24 06:50:43 +00:00
Mark Chien
239860a4d6 Fix testRequestDownstreamAddressWithoutUsingLastAddress flaky
The problem is that the test releases mHotspotIpServer’s prefix before testing mUsbIpServer, which means that mUsbIpServer might choose the same address as mHotspotIpServer’s.

To fix this, we need to test that mUsbIpServer and mHotspotIpServer have different addresses before calling releaseDownstream(mHotspotIpServer).

Change-Id: Id7f7bbfeda841ec9b97e24c0f11893fa37b9ef54
Test: TH
Bug: 300127195
2023-10-24 06:16:03 +00:00
Mark
c352f3cb4e SyncSM05.1: add testMultiDepthTransition
Test: atest TetheringTests
Change-Id: I427360f6a106b001123442ccd4802290d4f13369
2023-10-23 07:34:29 +00:00
Mark
8f068a8a1e SyncSM05: add SyncStateMachineTest
A initial test for SyncStateMachine, will add more tests in the
following changes.

Test: atest SyncStateMachineTest
Change-Id: Ie6dbbe22bfef40b1675d50243d14d0a235df1e3a
2023-10-23 07:29:09 +00:00
Chalard Jean
7f2b3dabcd Reapply "Simplify addRoutesToLocalNetwork calls"
This reverts commit 316346be6e.

Change-Id: I86977f6e7a5451d037c7ea6fee5c4bc7082935ff
2023-10-18 15:50:02 +09:00
Anton Kulakov
316346be6e Revert "Simplify addRoutesToLocalNetwork calls"
Revert submission 2777667

Reason for revert: DroidMonitor-triggered revert due to breakage, bug b/305187495

Reverted changes: /q/submissionid:2777667

Bug: 305187495

Change-Id: I516d40b20d775e9c61b2f825bc094329d016d0c3
2023-10-13 15:15:50 +00:00
Chalard Jean
cf70df3e9b Simplify addRoutesToLocalNetwork calls
There are only three calls to this method, and two of them
are with a list of 1 address which means it's simpler inlined.

The last call will be replaced with calls to RouteController
in a followup, meaning we addRoutesToLocalNetwork can be removed.

Test: RouterAdvertisementDaemonTest
      NetdUtilsTest
Change-Id: I3b6ee1db40f09954b336321000735a66306bf000
2023-10-13 16:19:25 +09:00
Paul Hu
ebbbf8f470 Stop the created handler threads on the tests
The created handler thread will stay there for a while until
all the tests are finished. This is considered as a leakage
which will take the resource from the devices. In low end
devices, this may possibly impact the performance. The created
threads should be closed explicitly.

Test: atest ConnectivityCoverageTests ConntrackSocketTest
Change-Id: Ic1beb2a210e7c8c80c66fc9e0727c47599150672
2023-10-12 10:25:03 +08:00
KH Shi
2a6a7359b7 Merge "Decouple Ipv6UpstreamRule with Ipv6DownstreamRule" into main 2023-10-02 05:33:48 +00:00
KH Shi
701c3ca2f5 Decouple Ipv6UpstreamRule with Ipv6DownstreamRule
Currently, Ipv6UpstreamRule is added follows the adding of
Ipv6DownstreamRule when it is the first rule from a downstream
interface to the upstream interface.

This CL changed it to:
1. Upstream interface change updates both IPv6 upstream and downstream
   forwarding rules.
2. Neighbor events updates only IPv6 downstream forwarding rules.

Data limit setting on the upstream interface is now depend on the
upstream rules instead of the downstream rules. This CL also updates
corresponding test cases in IpServerTest and BpfCoordinatorTest.

Test: atest TetheringTests
Bug: 261923493
Change-Id: I5b4df64a3d276afb7a24bbef3a0432f53377e8b2
2023-09-19 08:02:24 +00:00
Treehugger Robot
47158c98b5 Merge "Fix EthernetTetheringTest#testLocalOnlyTethering flaky" into main 2023-09-14 17:40:06 +00:00
Yuyang Huang
fca402abed Add test for downstream tethering
Add end-to-end testing for testing NsdManager advertising and
discovering works fine with downstream tethering interfaces.

Bug: 281639507
Test: atest NsdManagerTest
Change-Id: I5a66423f216cfe0c82db5128502c885980ab264b
2023-09-12 17:53:37 +09:00
Motomu Utsumi
3e0be398a2 Remove unnecessary arguments from isTetheringFeatureEnabled
This CL also updates not to use isTetheringFeatureEnabled for
TETHER_FORCE_UPSTREAM_AUTOMATIC_VERSION which is wrongly configured in
Connectivity namespace.

Test: m
Bug: 279108992
Change-Id: If4f3a57c749bbaeb85454c31248c5bc5feaab936
2023-09-08 16:11:28 +09:00
Mark
801079f25a Fix EthernetTetheringTest#testLocalOnlyTethering flaky
The testLocalOnlyTethering only verifies whether an IPv6 RA
with a ULA prefix is sent out. If the test interface is killed
after the RA is sent out while the DHCP server is starting,
the error callback with exception is raised. RunDhcp
verification is used to ensure that DHCP server is started.

Bug: 286701571
Test: TH

Change-Id: Iccebcedbba7b2f9cd28bb1cc06af928ff8dfaaca
2023-09-05 06:14:21 +00:00
KH Shi
e4d549ab11 Remove duplicated bpf offload support check in IpServer
In current code, IpServer will ensure bpf offload is supported before
calling BpfCoordinator's APIs. But those APIs already have the same
checks inside the function. This CL removed duplicated checks in
IpServer.

After this change, the BPF offload support status is only determined
inside BpfCoordinator and it won't change during the life cycle of
Tethering. Tethering initializes mBpfCoordinator just once in the
constructor. After that point, the value of isUsingBpf can never
change, because mIsBpfEnabled is final and
mBpfCoordinatorShim.isInitialized() is either always true (api30) or
can either never change (api31).

Also fixed a bug in IpServerTest upon this change.

Test: atest TetheringTests
Bug: 261923493
Change-Id: I50f231a83bf678b90eae4fd9bfa6035e86978bb3
2023-09-01 07:37:18 +00:00
KH Shi
480d807057 Merge "Introduce Ipv6UpstreamRule to bpf tethering offload" into main 2023-08-25 10:20:20 +00:00
KH Shi
59ad35ee19 Introduce Ipv6UpstreamRule to bpf tethering offload
Replaced startUpstreamIpv6Forwarding and stopUpstreamIpv6Forwarding
with add/remove Ipv6UpstreamRule. This is a preparation for following
CLs which will pass the upstream's prefixes to the bpf map. We might
have more than one upstream rules.

Also renamed Ipv6ForwardingRule to Ipv6DownstreamRule since we have
defined the Ipv6UpstreamRule.

No logic changes are being made in this CL.

Test: atest TetheringTests
Bug: 261923493
Change-Id: I022f97c2daf468bbd4a4279a069ccf498013e7e7
2023-08-24 12:02:23 +00:00
Yuyang Huang
5c2126ed38 Move ArpPacket.java to frameworks/libs/net
Bug: 281639507
Test: TH
Change-Id: I754c3581438d716d2156b80e4ce29b3f2adf76d4
2023-08-23 18:24:35 +09:00
KH Shi
839cc0b455 Merge "Add tests for OffloadHardwareInterface" into main 2023-08-14 02:13:23 +00:00
Treehugger Robot
b8ea09efd7 Merge "Import RFC7421_PREFIX_LENGTH from NetworkStackConstants." into main 2023-08-10 13:07:20 +00:00
KH Shi
c8fb1a2530 bpf tethering offload - add src subnet to upstream ipv6 direction
This patch is based on aosp/2535559 from maze@.

Add source prefix into the upstream key such that only packets which
source IPv6 address matches it will be forwarded to the upstream
interface.

In this patch, the source prefix is set to zero so there is no
behavior changes. Next CL in patch series will use the real source
prefixes retrieved from upstream interface.

Test: atest TetheringTests
Bug: 261923493
Change-Id: I43d068a29b937c7dfeb6fab632a8effb47ee2263
2023-08-10 16:01:21 +08:00
KH Shi
f5390a9d8f Add tests for OffloadHardwareInterface
NativeHandles shouldn't be closed in OffloadHardwareInterface after
passing them to initOffload() of AIDL service, because their owner
will be changed to ParcelFileDescriptor by libbinder.

Add test cases to verify that NativeHandles are closed correctly.
NativeHandles should be closed after initOffload if:
  - Init with HIDL HAL interface
  - Has null NativeHandle, any non-null NativeHandles should be closed

Bug: 277834236
Test: atest OffloadHardwareInterfaceTest
Change-Id: Icbe74da73d3bdc582d1816b314fdfce9661465fc
2023-08-10 14:56:09 +08:00
Xiao Ma
1f993309c6 Import RFC7421_PREFIX_LENGTH from NetworkStackConstants.
Remove the dependency on services-connectivity-shared-srcs
filegroup gradually.

Bug: 290885904
Test: TH
Change-Id: I6474563a3a0b521945e6467a2832862764ad4770
2023-08-09 20:02:15 +09:00
Mark
f5e4b90ae2 Fix EtherentTetheringTest flaky
The first tethering test case may experience tethering restart
with IP conflict handling. Tethering would cache the last
upstreams so that the next enabled tethering avoids
picking up the address that is in conflict with the upstreams.
To protect subsequent tests, turn tethering on and off before
running them.

Bug: 254183718
Test: atest CtsTetheringTest
      atest MtsTetheringTestLatestSdk
Change-Id: I03729d3212a03bd9fcfe2c09cf327840f13b250c
2023-07-27 16:04:28 +00:00
Mark Chien
df41b36fc9 Merge "Don't run EthernetTetheringTest if Ethernet is not supported" 2023-07-04 09:12:34 +00:00
Mark
dc581e6c8f Don't run EthernetTetheringTest if Ethernet is not supported
Bug: 288844185
Test: atest CtsTetheringTest
Change-Id: Ie918a0657ab17900437918f7ae99f7aa2539052c
2023-07-03 09:25:18 +00:00
Hungming Chen
05ecb5c19e EthernetTetheringTest: test RFC 7050 prefix64 discovery
Reply ipv4only.arpa AAAA query with Pref64::WKA for applying test
prefix64 to LinkProperties of test network.
See Nat464Xlat#setNat64PrefixFromDns.

Currently, the test prefix64 is applied directly in test network
initialization. In order to increase the NAT64 test coverage,
the integration test starts to reply prefix64 discovery DNS query
for testing the RFC 7050 prefix discovery.

These clat related tests are still expected to pass since this
prefix64 source change:
- testTetherClatIcmp
- testTetherClatUdp
- testTetherClatTcp

Bug: 259888307
Test: atest EthernetTetheringTest
Change-Id: Ic94ce997dd0b1d718a1074850c01ea90298cc1c3
2023-06-26 15:51:25 +00:00
Mark Chien
5cebcf7d64 Merge "Move buildXXXPacket methods into TetheringTester" 2023-06-26 02:16:20 +00:00
Mark
4845823f48 Move buildXXXPacket methods into TetheringTester
Move all EthernetTetheringTest buildXXXPacket util into TetheringTester
and make them static public.

Bug: 259888307
Test: atest EthernetTetheringTest
Change-Id: Ice5252c1adfdb98dfaf815f48ac4603711317f65
2023-06-22 07:12:49 +00:00
Mark Chien
c2e434bbc7 Merge "Tethering: ignore duplicate upstream changed event" 2023-06-19 15:03:48 +00:00
Hungming Chen
fc52868213 Tethering: ignore duplicate upstream changed event
Different network objects with the same network ID should be
treated as the same network.

chooseUpstreamType compares the current upstream and new upstream
by object (comparison operator) instead of network id
(Network#equals). This implies that different objects with the
same network id still trigger upstream changed report.

Since this commit, reportUpstreamChanged is only called when upsteam
has really changed (connected, switched or disconnected) in
chooseUpstreamType. In previous code, reportUpstreamChanged is also
called if EVENT_ON_CAPABILITIES is called when the upstream is the
same but its capabilities changed.

The NotificationUpdater#onUpstreamCapabilitiesChanged method only
needs to be called by chooseUpstreamType when it chooses a new
upstream. If the upstream remains the same but its capabilities
change, the EVENT_ON_CAPABILITIES will call
onUpstreamCapabilitiesChanged.

Bug: 243516306
Test: atest TetheringTest
Change-Id: I009383a61a5fabd249ba78fcffd524a5bbe4602e
2023-06-19 06:51:03 +00:00
Mark
cb1fe1a622 Add testIpv4AddressForSapAndLohsConcurrency test case
A test to verify that SAP and LOHS can use different IPv4
addresses if they are both enabled.

Bug: 233175023
Test: atest TetheringTest
Change-Id: I40f0f35221a76e6593cc8d04e9f2b25df8c27c87
2023-06-17 04:04:14 +00:00
Mark
639866b45a Add testConnectedClientsForSapAndLohsConcurrency test case
A test to confirm that connected clients are updated when SAP
and LOHS are enabled simultaneously.

Bug: 233175023
Test: atest TetheringTest
Change-Id: I920f02e5b2ad137af529776141d51b6c83b8ea5b
2023-06-16 09:09:10 +00:00
Xiao Ma
161b70c587 Add NetworkStackModuleTest annotation on the specific test case.
EthernetTetheringTest#testTetherZeroLengthDhcpPacket requires the latest
NetworkStack module, otherwise, the test will fail due to the loss of
the fix. Apply @NetworkStackModuleTest to exclude this testcase from
target test suite CtsTetheringTestLatestSdk.

Bug: 283200648
Test: atest CtsTetheringTestLatestSdk
Change-Id: Iebfb043e2b71427a6feaf90788fe79b6ab6b678d
2023-06-01 18:16:24 +09:00
Mark
49649c9aea Support SAP and LOHS enabled at the same time
Use type + scope as key to build cached address map so that
SAP (key: TETHERING_WIFI + INTERNET) and LOHS
(key: TETHERING_WIFI + LOCAL) can use different address.

Bug: 233175023
Test: atest TetheringTests
Change-Id: I46a4b3ee919628092b7540202a43d79f407b09b6
2023-05-25 08:31:33 +00:00
Mark
ae3abdfa4b Allow SAP and LOHS wifi clients exist at the same time
This change store localOnly wifi clients in its own field so that
tethered and localOnly hotspot clients can exist at the same time.

Currently, there are no tethered and localOnly hotspot clients at
the same time because PrivateAddressCoordinator does not support
SAP + LOHS. A follow-up change will be made to allow this.

When both SAP and LOHS are enabled, the SAP and LOHS clients from
TetheringEventCallback#onClientsChanged are all TETHERING_WIFI.
Currently, there is no way for the listeners to distinguish between
SAP and LOHS clients.

Bug: 233175023
Test: atest TetheringTests
Change-Id: I01b0a6abb084f7135f7825e0c5303e49c16a4c39
2023-05-25 08:31:06 +00:00
Mark Chien
adc6ab5c45 Merge "Add verifyHotspotClientUpdate helper function" 2023-05-18 05:57:39 +00:00
Mark Chien
65a73dbf78 Merge "Fix entitlement recheck fail in U" 2023-05-17 05:54:39 +00:00