Commit Graph

1938 Commits

Author SHA1 Message Date
Paul Hu
f286ed5be1 Include A/AAAA records in probing packet
Per RFC6762#8.1, a host can simultaneously probe for uniqueness
of its "A" record and all its SRV records [RFC6763] in the same
query message. Add a flag to include the A/AAAA records in the
probing packet if necessary.

Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I365a938a6c481df755a0598b175069b94905fa3b
2023-10-05 14:14:56 +08: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
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
Yuyang Huang
8e6fbc8c1a Update permission check for offloadEngine registration
For an app to register itself as an offloadEngine, it must have either
of the following permissions: NETWORK_STACK,
PERMISSION_MAINLINE_NETWORK_STACK, NETWORK_SETTINGS,
REGISTER_NSD_OFFLOAD_ENGINE.

Bug: 294777050
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: I19fe9b996a02b1ae23116c02a1b8406d93b3ecf1
2023-09-05 14:53:51 +09:00
Junyu Lai
35c69c7986 Address review followup comments for NetworkStats
This change includes:
1. Mark groupedBy*() deprecated and throw after android U.
2. Modify map() to mapKeysNotNull().
3. rename clearInterfaces to withoutInterfaces and refactoring.
4. Modify tests accordingly.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.NetworkStatsTest
Fix: 296149902
Fix: 296150018
Change-Id: I5d97422ba957a212c0c5fbc1eee3f8b174343348
2023-09-04 18:01:14 +08:00
Motomu Utsumi
188bfd36da Delay frozen app sockets close until the cellular modem wakes up
Closing TCP sockets sends RST packets. If the cellular modem is idle,
sending RST packets will wake the modem up and consume battery.

This CL adds delay_destroy_frozen_sockets_version flag.
When this flag and destroy_frozen_sockets_version is enabled,
ConnectivityService delays closing socket until the cellular modem wakes up.
Pending frozen sockets are closed also when cellular network becomes no
longer the default network.

This CL also adds flag status and pending uids to the dump.

Bug: 284900338
Test: FrameworksNetTests
Change-Id: I2562568390dda36d02f72afb3a96f824788964c0
2023-09-04 18:04:31 +09:00
Chalard Jean
2eb2f7998d Address flake in testNetworkCallbackMaximum
These flake occasionally because registering a request increases
the current request count synchronously while unregistering
decreases it asynchronously, meaning if the test has time to
call register 100 times before unregister can run it will
wrongfully flake.
This could be addressed in production code but as comments in
the change explain, this isn't worth the complexity. Hence
just have a pinpoint fix in the test. See aosp/2707373 for
what a fix in the production code would look like.

Test: manual
Bug: 289530922
Change-Id: Iad9a725eda91406f820abe4706bca0a4756352a4
2023-08-30 15:19:50 +09:00
Chiachang Wang
29178c8906 Merge "Verify reevaluation triggered when VPN validation fails" into main 2023-08-30 03:12:42 +00:00
Chiachang Wang
3e1edc231f Verify reevaluation triggered when VPN validation fails
Update tests to verify that the underlying network reevaluation
is triggered when VPN validation status switches to unvalidated.

Bug: 296183603
Test: atest FrameworksNetTests
Change-Id: I80934cce6e7f2d56039bdd6ad63c6f7173a597cb
2023-08-30 03:08:56 +00:00
Junyu Lai
50a7ecccf1 Merge "Split BpfNetMaps constants and utilities into standalone classes" into main 2023-08-29 10:44:51 +00:00
Junyu Lai
29b7b6385a Split BpfNetMaps constants and utilities into standalone classes
This is a no-op refactoring that splits constants and utility
methods into standalone classes which will be shared with
a bpf reader class in subsequent CLs.

NO_IFTTT=No-op refactoring

Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.StructTest

Bug: 297836825
Change-Id: I6d7ea044e43180ae001573009a166be74ebe6a5d
2023-08-29 08:20:10 +00:00
Chiachang Wang
69cd0aa5a0 Merge "Verify VPN underlying network is set as soon as it tries to use it" into main 2023-08-28 10:18:23 +00:00
Jean Chalard
940e330f5d Merge "Request enterprise networks" into main 2023-08-28 09:20:34 +00:00
Chiachang Wang
845a91cc31 Verify VPN underlying network is set as soon as it tries to use it
Bug: 289606688
Test: atest FrameworksNetTests
Change-Id: Ib35a63ac5f68599c646afad5cad68c1753fb732f
2023-08-28 08:00:20 +00:00
Paul Hu
1b5d601d0c Merge changes I47b91c0c,I630c0e49 into main
* changes:
  Report sent query count
  Report service info callback metrics data
2023-08-25 14:46:39 +00:00
Motomu Utsumi
5324475f6e Add some tests back which were removed for fixing kotlin nullable errors
Followup CL for aosp/2700076

Bug: 296972712
Test: build with aosp/2688146
Change-Id: I617b330c42a99e4c839adac2ea614756b5955ce9
2023-08-24 11:25:21 +09:00
Paul Hu
bad6fe9835 Report sent query count
Report the sent query count when the discovery is stopped.

Bug: 287546772
Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I47b91c0c530eee2f00920ee5ea99e8d7b6e2e9ee
2023-08-22 17:26:27 +08:00
Paul Hu
ddce5919af Report service info callback metrics data
Bug: 287546772
Test: atest FrameworksNetTestCases
Change-Id: I630c0e4921f7acf42bf29812d9790ee5a894d60b
2023-08-22 15:25:37 +08:00
Colin Cross
d5038a042c Merge "Fix kotlin nullable errors in Connectivity tests" into main 2023-08-22 04:13:01 +00:00