Commit Graph

1861 Commits

Author SHA1 Message Date
Jean Chalard
a6190bd658 Merge changes I3b6ee1db,I70e13303,I6fb7dfe4 into main
* changes:
  Simplify addRoutesToLocalNetwork calls
  Add LocalNetworkConfig
  Tell netd about local networks
2023-10-13 09:57:18 +00:00
Chalard Jean
fa21cafc1c Add LocalNetworkConfig
This doesn't do anything at this patchset, but the whole
pipe from the agent to ConnectivityService is built.

LocalNetworkInfo will be the name of the public information
sent in callbacks to clients.

Test: CSLocalAgentTests
Change-Id: I70e133031ef3b0aaf6c3e59ccc2ad895c66d339c
2023-10-13 14:40:45 +09:00
Chalard Jean
774dc3cd51 Tell netd about local networks
This patch does the following :
• When a network is local but the system doesn't support it,
  throw in registerNetworkAgent.
• When a network is local, tell netd about it.
• Add tests for the above, as well as a test for callbacks
  being sent correctly when the caps are set and not when
  they aren't and that the new keep connected flag is
  respected.

Telling netd about the network being local has it add two
routes that do not exist if the network is not local :
• One at PRIORITY_LOCAL_NETWORK matching unmarked sockets
  and looking up the table for the interface.
20000: from all fwmark 0x0/0x10000 lookup xxxx
• One at PRIORITY_EXPLICIT_NETWORK matching explicitly on
  network 99, so that dnsmasq traffic and any OEM traffic
  marked for network 99 flowing there.
16000: from all fwmark 0x10063/0x1ffff iif lo lookup xxxx
IMPLICIT_NETWORK and EXPLICIT_NETWORK rules are installed
by connectivity service as a matter of course whether the
network is local or not.

See commit If8729fc6f3716a580c936584b851bc38000b5de5 for
implementation details of this mechanic.

There is no need to implement anything in particular for the
new connected reason, as the current implementation will
already keep it connected. A new test makes sure of that.

Test: FrameworksNetTests
      CtsNetTestCases
      FrameworksNetIntegrationTests
      NetworkStackTests
      NetworkStaticLibTests
      TetheringTests
      MtsTetheringTestLatestSdk
      TetheringIntegrationTests
Change-Id: I6fb7dfe4c232eea8cac9ac268897ddb36bb794d1
2023-10-13 14:40:38 +09:00
Hansen Kurli
ccfc52145b Merge changes I22d67a7e,Ida4a4bc7,Ie8522862,Id55d8d6c into main
* changes:
  Ensure nri is satisfied before returning.
  Add testLockdownVpn that mocks platform VPN.
  Make variables in testLegacyLockdownVpn() final.
  Update testLegacyLockdownVpn to mock VPN.
2023-10-13 05:00:29 +00:00
Jean Chalard
10353d5351 Merge changes Ic490fee6,If78047c3 into main
* changes:
  Add hidden constants for communicating about local network agents
  Use isAtLeast* from deps
2023-10-12 11:01:36 +00:00
Hansen Kurli
ed972a6fd2 Ensure nri is satisfied before returning.
When a network preference is set, the highest priority nri will
be a managed default request that disallows default networking.
In the case where there is no satisfying network,
mNoServiceNetwork is used as the satisfier instead of null.
(see computeNetworkReassignment)

mNoServiceNetwork should not be returned in any public API.
Check for the nri being satisfied before returning the satisfier
to ensure mNoServiceNetwork is not returned.

Fixes: 301222648
Test: atest FrameworksNetTests
Change-Id: I22d67a7e8d0274d8ad4f6123fbedf6d37eed18e7
2023-10-12 18:48:57 +08:00
Hansen Kurli
48c14686a3 Add testLockdownVpn that mocks platform VPN.
Add a test for lockdown vpn that uses TYPE_IKEV2_IPSEC_PSK and
mocks platform VPN by override in startLegacyVpnPrivileged().
In the context of ConnectivityService, setVpnDefaultForUids()
is the main interaction.

Refactor testLegacyLockdownVpn to take a VpnProfile and assert
behaviors with and without setVpnDefaultForUids().
This includes:
    1. Updating callback asserts and assertActiveNetworkInfo to
       reflect setVpnDefaultForUids().
    2. Adding TODOs where mCm.getActiveNetworkInfo() returns
       unexpected values.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Ida4a4bc745af5ba2fc251795b2ffca56ead79b7f
2023-10-12 18:48:24 +08:00
Paul Hu
0b5d785096 Merge "Stop the created handler threads on the tests" into main 2023-10-12 07:13:30 +00:00
Chalard Jean
d6f4efb1a8 Add hidden constants for communicating about local network agents
Test: FrameworksNetTests
Change-Id: Ic490fee6ee70d74acff0a290199b2946817173d0
2023-10-12 13:30:49 +09:00
Chalard Jean
5efbcf7bab Use isAtLeast* from deps
CSTest and CSAgentWrapper need to agree on what the current
version is

Test: CSTest*
Change-Id: If78047c36ce213a531207d25b410e870691fbb98
2023-10-12 13:30:49 +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
Jean Chalard
02193c0cce Merge changes Ibb8d33b7,Ie168fe1f,I9f699b63 into main
* changes:
  Prepare exposing Network{Request,Caps}.forbiddenCapabilities
  Add a keep connected for test reason
  Improvements to CSTest : legacy type, wait for LOST, permissions
2023-10-12 02:14:52 +00:00
Hansen Kurli
270813c4c5 Merge changes Ib24809ec,Id9d26435 into main
* changes:
  Remove the fail case on IPv6 in testLockdownVpn
  Remove LockdownVpnTracker from testLegacyLockdownVpn
2023-10-11 12:03:37 +00:00
Chalard Jean
c517fb1247 Add a keep connected for test reason
This has been sorely needed for a while. Instead of filing requests
for each of your networks in a CSTest, which is fiddly at best and
sometimes almost impossible (because you can't single out the network),
you can now add this flag and be done with it.

Test: CSKeepConnectedTest
Change-Id: Ie168fe1f3a17de035fdf05e3d6580d3262a3448e
2023-10-11 17:02:52 +09:00
Chalard Jean
026ca940d9 Improvements to CSTest : legacy type, wait for LOST, permissions
• Make sure all Agents have a legacy type. This is necessary to
  avoid crashes in LegacyNetworkTracker
• Wait for LOST when disconnecting a network
• Make sure the test package sees its own permissions (importantly
  it can't see background networks otherwise, because it lacks
  CHANGE_NETWORKING_STATE)

Test: in the followup
Change-Id: I9f699b6372a8fe0d5bcd5310d8f35f72e48a6c61
2023-10-11 17:02:51 +09:00
Chalard Jean
f70919fbec Reword a comment for accuracy
Test: none needed
Change-Id: I7e409827adc86fc13975f394100889a6bf0f1e50
2023-10-10 20:12:40 +09:00
Chalard Jean
eb66389d6a Allow for mocking an SDK in the tests
Test: in followup patches
Change-Id: I540ce2a455c92be52eb94fbd4b54a2081d04d25e
2023-10-10 14:57:22 +09:00
Jean Chalard
4dec273ab4 Merge "Expose the netd mock in CSTest to allow verifying calls on it" into main 2023-10-10 04:17:29 +00:00
Jean Chalard
e339c6b780 Merge "Add missing copyright notices to tests" into main 2023-10-10 04:16:52 +00:00
Kangping Dong
4a8977c452 Merge "[mdns] exclude mDNS advertiser code from standalone build test" into main 2023-10-08 12:21:24 +00:00
Kangping Dong
1a1beee654 [mdns] exclude mDNS advertiser code from standalone build test
service-connectivity-mdns-standalone-build-test builds the mDNS
discovery and advertisement implementation against API level 21.
This stops the advertisement code from calling new NsdServiceInfo
public or private APIs which are required by Thread.

This commit removes the mDNS advertisement code from the standalone
build to loose the check given this will never be used by GMS Core.

Bug: 265095929
Test: verified that it can build with aosp/2608627
Change-Id: I32cfce7b994d51a4b4ec468e9f79ffc2be6635ff
2023-10-08 17:22:14 +08:00
Chalard Jean
ff7edd36eb Expose the netd mock in CSTest to allow verifying calls on it
Test: manual
Change-Id: Ib39dc4dbf534f14d94923bb0026f18e47edabba2
2023-10-07 15:11:40 +09:00
Chalard Jean
52afbf2634 Add missing copyright notices to tests
Test: comment-only change
Change-Id: I63bada891757d7e991cc7538c56e4fc50074ee5d
2023-10-07 15:09:21 +09:00
Paul Hu
87d128f43d Merge "Store transaction id in MdnsPacket" into main 2023-10-06 05:51:33 +00:00
Hansen Kurli
78b06ebe84 Make variables in testLegacyLockdownVpn() final.
Test: atest FrameworksNetTests
Change-Id: Ie852286275f0e377be582648f7766c077d9877e8
2023-10-04 16:50:05 +08:00
Hansen Kurli
b2764be9b6 Update testLegacyLockdownVpn to mock VPN.
Override more VPN methods to mock the VPN interaction of
testLegacyLockdownVpn instead of relying on the Vpn class.
This includes:
    1. Overriding startLegacyVpnPrivileged() and avoid creating
       a VpnRunner.
    2. Removing expectStartLegacyVpnRunner() since it is not
       used when startLegacyVpnPrivileged() is overridden.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Id55d8d6cd03b84bca815cd331eb0f7d584eaed5f
2023-10-04 16:47:10 +08:00
Hansen Kurli
acb5205558 Remove the fail case on IPv6 in testLockdownVpn
In testLegacyLockdownVpn, remove the fail check on IPv6 networks
and add coverage in VpnTest instead as this interaction relies
on the Vpn implementation, not ConnectivityService.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Ib24809ece2332c4c3d3e08c168e02ad859242eac
2023-10-04 16:45:45 +08:00
Hansen Kurli
35f6fef389 Remove LockdownVpnTracker from testLegacyLockdownVpn
The test coverage of LockdownVpnTracker has been moved to a
separate unit test file. testLegacyLockdownVpn now calls the Vpn
methods directly instead of creating a new LockdownVpnTracker.
Note this removes calls to expectStopVpnRunnerPrivileged since
stopVpnRunnerPrivileged is now directly called in the test so it
is already guaranteed to be called.

The expected calls/behavior of LockdownVpnTracker can be seen in
LockdownVpnTrackerTest.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Id9d26435bf62ffef954f6c7fa0558ce99540de1f
2023-10-04 16:44:09 +08:00
Treehugger Robot
c8a42f6a39 Merge "Disable the remaining VPN CTS tests on watches." into main 2023-10-03 16:39:31 +00:00
Chalard Jean
14499f0119 Prioritize non-slices over slices
For general internet access, a specialized slice is generally
not preferable to a non-specialized network.

Test: new test in this patch
Change-Id: I052ce923300566807999b2f20f5911181fb761dd
2023-10-03 21:30:49 +09:00
abdelrahmani
5bcbbc1ce9 Disable the remaining VPN CTS tests on watches.
- Watches don't support VPN apps.
- The HostsideVpnTests CTS tests are already skipped on watches.
- The tests for VpnManager VPNs do run on watches, but there isn't
  actually a way to start a VpnManager VPN on a watch because there is
  no way to display the consent dialog to the user.
- The VpnService CTS tests verify the VpnService API on watches
  bypassing the consent dialogs.
- Because there is no way to start a VPN app on a watch, there's no
  point requiring the VPN CTS tests to pass.

This CL disables the remaining VPN CTS tests on watches. This allows
watches to disable the VPN service, reducing startup time and memory
usage.

Bug: 286240194
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: Idb7110232ae7e45cafc265cd4f955c2a6b22361c
2023-10-02 06:29:46 +00:00
Maciej Żenczykowski
9f94648b7f Lower CLAT max MTU from 65536 to 1528.
Android's clat is for reaching the internet, which in general
never has an ipv4 L3 mtu higher than 1500.

(We could probably hit this on a jumboframe enabled IPv6-only
wifi network [ http://b/292057969#comment18 ] where RA claims
MTU of 9K [9170])

Bug: 292057969
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7a32455571458b8a3f1121ad980d54323b2ef06b
2023-09-30 14:23:51 +00:00
Chalard Jean
361dad3243 Use carrier service changed callbacks when flag is on
Test: FrameworksNetTests
      Note that carrierPrivilegeAuthenticatorTest is already
      an @Parameterized test with flag = on and off, so it
      already tests both.
Change-Id: I52fcfd3f21a13d7a39952ba828464ce6ef4085c2
2023-09-29 15:48:48 +09:00
Jean Chalard
1d600f4300 Merge changes Ifd7abd8a,I39cab8ff,I6b3270d6,Ia28c6abc,If47d7e23 into main
* changes:
  Move the MULTI_SIM_ACTION receiver inline
  Inline registerForCarrierChanges
  Make mThread a local
  Introduce a flag for using the carrier service changed callbacks.
  Have DevSdkIgnoreRunner support @Parameterized parameters
2023-09-29 06:46:08 +00:00
Jean Chalard
21599869f7 Merge "Add more necessary infra to CSTest" into main 2023-09-29 03:50:45 +00:00
Chalard Jean
090b1f586b Move the MULTI_SIM_ACTION receiver inline
This will be easier to read when this behavior is diverted
based on a flag

Test: FrameworksNetTests
Change-Id: Ifd7abd8ad82cb8307b1cd8535ac5fa82004404e6
2023-09-28 21:37:32 +09:00
Chalard Jean
84dfa9f104 Introduce a flag for using the carrier service changed callbacks.
Test: CarrierPrivilegeAuthenticatorTest
Change-Id: Ia28c6abca67866c1de953cb61953a0d2882cd7e2
2023-09-28 21:37:32 +09:00
Paul Hu
6df06daaec Store transaction id in MdnsPacket
The transaction id is a number that is used to identify a
specific query packet. But it's not necessary for probing
or announcing services, so the transaction id is not
currently used on advertising when creating a MdnsPacket or
decoding the response to a MdnsPacket. This means that it is not
possible to track which query packets have received
responses. Therefore, store the transaction id so that
it can be used for subsequent query packet changes.

Bug: 302269599
Test: atest FrameworksNetTests
Change-Id: I6734752b32b91678afb7df06e1fa51237cf70894
2023-09-27 18:20:28 +08:00
Andriy Naborskyy
d032dd42ea wear proxy behind portal
Do not avoid captive portal on wear proxy network; keep network agent
after detecting portal.

Bug: 291112432
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.ConnectivityServiceTest
Change-Id: I8f6669da62ebd76b6a46d2aec9b3ea563a08cb5e
2023-09-27 07:28:05 +00:00
Lorenzo Colitti
3b817cbad3 Nat464Xlat: rely on netd events being called on handler thread.
aosp/2724918 moved processing netd events for 464xlat to the
handler thread.

This CL makes 464xlat run the code that processes those events
inline. This simplifies the code and makes the ordering of events
more similar to what it was before.

Bug: 293965195
Fix: 302071735
Test: existing unit tests
Change-Id: I18b0d491aff94646b878a3d3488b5519fd42783c
2023-09-26 11:00:37 +00:00
Chalard Jean
073606fc8d Add more necessary infra to CSTest
- Ability to mock enabled changes, which is necessary for
  requestNetwork
- Ability to disconnect an agent

Test: in aosp/2761506
Change-Id: If2701f1fff29453e74a4b388758c6ee3a16a5734
2023-09-25 14:56:09 +09:00
Yuyang Huang
365cf0a393 Merge "Add newApi linter check for mDNS library" into main 2023-09-13 05:55:51 +00:00
Yuyang Huang
fc83170c70 Add newApi linter check for mDNS library
The mDNS library need to be backported to some internal library which
support minSdk 21. Therefore, updated the build rules to add the linter
check.

Bug: 296175311
Test: TH
Change-Id: Iae0bffa315dc6de2339a05f595b13480fa7385ae
2023-09-12 19:01:21 +09:00
Paul Hu
508a012b2e Correct isLegacy metric data
The isLegacy field of Nsd metrics should indicate whether the
data was collected from the old backend or not. However, it is
currently only dependent on the ENABLE_PLATFORM_MDNS_BACKEND
compat change value, which is incorrect. This is because the
NsdService always uses the new backend since Android U,
regardless of the compat change value. Therefore, the isLegacy
data should be obtained from each transaction.

Bug: 287546772
Bug: 299880473
Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I156abd656b90578d710696a69ccf7dfca97a2c9c
2023-09-12 01:20:00 +00:00
Chalard Jean
f95e2de35a Implement ConnectivityStateMetrics sample
Test: ConnectivitySampleMetricsTest
Change-Id: I0afdda023208c3f8620cb5b89add66448af596d7
2023-09-11 17:12:46 +09:00
Chalard Jean
0f5c4fe9cb Add base classes for common ConnectivityService tests.
This sets up what is necessary for an instrumented
ConnectivityService to run. Users of this class are
meant to inherit CSTest.

This is still relatively basic and does not have all the
instrumentation in ConnectivityServiceTest. Developers
looking to extend CSTest may find some instrumentation
missing ; when they add the missing instrumentation,
they should consider whether it should be generic for all
CSTests (and put it in base/), or whether it's local to
their own test suite. This should enable faster testing
as each CSTest children will only need to set up the
instrumentation it actually needs.

This patch also migrates a basic test to have a first user.

Bug: 272685721
Test: ConnectivityServiceTest
      CSBasicMethodsTest
Change-Id: I1c47f616af90629c9cb2a6ae89d992b19863e704
2023-09-11 16:46:27 +09:00
Treehugger Robot
8df4d76aa2 Merge "Address review followup comments for NetworkStats" into main 2023-09-08 20:11:03 +00:00
Yuyang Huang
169de9c8a1 Merge "Add Chicken bit for the mDNS offload feature" into main 2023-09-08 13:25:53 +00:00
Paul Hu
af511b5abe Merge "Disable cache flush bit in existing announcement" into main 2023-09-08 12:48:05 +00:00
Yuyang Huang
b96a071f51 Add Chicken bit for the mDNS offload feature
Bug: 297482971
Test: TH
Change-Id: I6f2cdd066d9047b113ff80211cf6d4c6fa605104
2023-09-08 17:42:26 +09:00