Commit Graph

1854 Commits

Author SHA1 Message Date
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
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
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
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
Chiachang Wang
5ee9dedb0f Verify that VPN name is set in VPN networks
Verify that the extra info for validation logs in the
NetworkInfo is set.

Bug: 297790570
Test: atest FrameworksNetTests
Change-Id: I5b77b3bab30154b7979cda003274cde0d834a5fb
2023-09-07 09:22:24 +00:00
Paul Hu
043bcd4537 Report more advertising metrics data
Report more advertising metrics data below when the service is
unregistered.
- Replied request count (sum across interfaces)
- Sent packet count (including announcements and probes)
- Number of conflicts during probing
- Nubmer of conflicts after probing

Bug: 287546772
Test: atest FrameworksNetTestCases NsdManagerTest
Merged-In: I50c54a35dc523422e3a7302c059bbbc38eac5631
Change-Id: I50c54a35dc523422e3a7302c059bbbc38eac5631
2023-09-06 11:26:53 +08:00
Yuyang Huang
a337d95cc4 Merge "Send rawOffloadPacket to OffloadEngine" into main 2023-09-06 00:04:00 +00:00
Paul Hu
88239ccb0a Disable cache flush bit in existing announcement
Per RFC6762#10.1, the cache flush bit should be false for
existing announcement. Otherwise, the record will be deleted
immediately when receiving this response.

Bug: 299054783
Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I8bf1a5b1914b49720862836abb543b232185f5f5
2023-09-05 17:54:55 +08:00
Motomu Utsumi
4e95ea0740 Merge "Delay frozen app sockets close until the cellular modem wakes up" into main 2023-09-05 09:11:01 +00:00
Yuyang Huang
31f6e2eccb Send rawOffloadPacket to OffloadEngine
Add the missing logic to send the rawOffloadPacket to OffloadEngine.

Bug: 297314970
Test: atest CtsNetTestCases FrameworksNetTestCases
Change-Id: I06d7a9bb84df72808eff4f0c9df60f7e60aa2a2c
2023-09-05 08:51:04 +00:00
Yuyang Huang
65f96123a2 Merge "Update permission check for offloadEngine registration" into main 2023-09-05 08:45:39 +00:00