Commit Graph

10985 Commits

Author SHA1 Message Date
Junyu Lai
e5c0a0fe56 Merge changes If7cb1cbb,I1d09ac01 into main
* changes:
  Adds more data points for benchmarking tests
  Move test zip file to assets
2023-10-16 06:50:12 +00:00
Paul Hu
68e67f44c3 Merge "Add ServiceExpiredCallback" into main am: 1eeeb15f2e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2787872

Change-Id: I3ac1a65985a9e7608557803b2d36cd4b6a0410b8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-16 02:19:53 +00:00
Paul Hu
1eeeb15f2e Merge "Add ServiceExpiredCallback" into main 2023-10-16 01:41:49 +00:00
Anton Kulakov
fb9169d923 Merge changes from topic "revert-2777667-BKWNXIZQME" into main am: 18d14d3e78
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2786126

Change-Id: Ib00efdc8df8d72ceb1a83f0726ee3956b287a778
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-14 08:58:49 +00:00
Anton Kulakov
5306f666fb Revert "Add LocalNetworkConfig" am: 6eea22b18c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2786125

Change-Id: Ia711af732a95933636b99c3d7e44ae8170dcb67e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-14 08:58:46 +00:00
Anton Kulakov
cc409153b4 Revert "Tell netd about local networks"
Revert submission 2777667

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

Reverted changes: /q/submissionid:2777667

Bug: 305187495

Change-Id: Icb46558d17b56f9f6fd402f1489de9ed2b8f7644
2023-10-13 15:23:59 +00:00
Anton Kulakov
6eea22b18c Revert "Add LocalNetworkConfig"
Revert submission 2777667

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

Reverted changes: /q/submissionid:2777667

Bug: 305187495

Change-Id: Iae4ef936a4c111ae5668e539ce4cdbbb14c811f4
2023-10-13 15:18:55 +00:00
Jean Chalard
3f837cf542 Merge changes I3b6ee1db,I70e13303,I6fb7dfe4 into main am: a6190bd658
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2777667

Change-Id: I7c0aa8c8fff902b8585e5c09b1d571de70740f80
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-13 10:23:19 +00:00
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
Paul Hu
d4dcb4bee8 Add ServiceExpiredCallback
This is a no-op change and refactors the design for subsequent
TTL expiration check changes.
- Add a ServiceExpiredCallback to notify expired services.
- To simplify the design, pass the CacheKey to MdnsServiceCache
  methods instead.

Bug: 265787401
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I930a4f7baf9b8d3d0037dc6aefd717dbdd486520
2023-10-13 16:45:31 +08:00
Hansen Kurli
233ac9463b Mock Vpn.setUnderlyingNetworks()
Override Vpn.setUnderlyingNetworks() to do a direct call on the
network agent instead of relying on the Vpn class.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Ib7883f8a81a22317616cae79ce57a30afdd2bed4
2023-10-13 15:37:08 +08:00
Hansen Kurli
39654c33cf Mock Vpn.setLockdown()
Call setRequireVpnForUids directly to enable lockdown instead of
calling the real Vpn method.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: I91ec59f7542d145e9250a7e7a414593db3d99424
2023-10-13 15:30:43 +08: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
1307a04994 Merge changes I22d67a7e,Ida4a4bc7,Ie8522862,Id55d8d6c into main am: ccfc52145b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2750302

Change-Id: I19f2930de302d3267b947b2b83755d7a25252076
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-13 05:23:07 +00: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
8694130cac Merge changes Ic490fee6,If78047c3 into main am: 10353d5351
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2539630

Change-Id: I7a9c109e61759eca22722bc68b08c8f78f80ac94
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-12 11:39:09 +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
b79fb66be2 Merge "Stop the created handler threads on the tests" into main am: 0b5d785096
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2784088

Change-Id: I2e9a1ab99077c3e6dd3036b87f97239581a20f46
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-12 07:47:58 +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
Jean Chalard
de72505109 Merge changes Ibb8d33b7,Ie168fe1f,I9f699b63 into main am: 02193c0cce
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2775660

Change-Id: I08e845ac61b6e37e88eacc3f48964742da708b61
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-12 02:48:04 +00: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
d6aef6b6c3 Merge changes Ib24809ec,Id9d26435 into main am: 270813c4c5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2727558

Change-Id: Ic0fb2ca5c7aaebf9ac6597f1c19e71b7979339a8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-11 12:35:59 +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
cf7dbcae41 Prepare exposing Network{Request,Caps}.forbiddenCapabilities
This is useful going forward in particular because there will
be a default forbidden capability for LOCAL_NETWORKS. This
means it will be useful to be able to remove it.

It is also generally useful and we have been wanting to open
this API to the public, so this is a good opportunity to do so.

Test: new tests for NetworkRequest
      NetworkCapabilitiesTest already has tests because it
      already was @SystemApi
Change-Id: Ibb8d33b799f2d274326fd9cd0b05a2c33a18032a
2023-10-11 17:02:52 +09: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
ef86df81d1 Reword a comment for accuracy am: f70919fbec
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2780320

Change-Id: Iefc882167d6bedc60da0ceac4dc522280de3ee0a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-10 17:42:36 +00:00
Chalard Jean
263ccdc8e9 Allow for mocking an SDK in the tests am: eb66389d6a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2775659

Change-Id: I60d5476fa57a2e30233944e30270ed4e6b9239e7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-10 11:48:05 +00: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
e3bfadb824 Merge "Expose the netd mock in CSTest to allow verifying calls on it" into main am: 4dec273ab4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2775658

Change-Id: I7463e8b960aba0346eeaec399d3c31dc7a612a2c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-10 04:45:55 +00:00
Jean Chalard
3f1ef8721a Merge "Add missing copyright notices to tests" into main am: e339c6b780
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2775657

Change-Id: I05724882a4820db75cca16baf4280948f0d69be8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-10 04:45:37 +00: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
Krzysztof Kosiński
947c03644f Merge "Clean up obsolete aliases for Truth." into main am: 22d08770af
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2776858

Change-Id: Ic697196794b26f068ea61f1a743ac2891d6cf200
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-09 23:39:13 +00:00
Krzysztof Kosiński
22d08770af Merge "Clean up obsolete aliases for Truth." into main 2023-10-09 23:08:57 +00:00
Kangping Dong
b8deae76db Merge "[mdns] exclude mDNS advertiser code from standalone build test" into main am: 4a8977c452
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2760326

Change-Id: I754b410a99f0eb57436b7f925c2aa731a1714c2b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-08 13:00:38 +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
Maciej Żenczykowski
198eadb402 move BPF_CGROUP_INET*_BIND registration into BpfHandler am: 3cb494fd28
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2773186

Change-Id: I50f2dffd176e5a0767af313c067d7404ab277b7c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-07 01:09:36 +00:00
Krzysztof Kosiński
739ed22507 Clean up obsolete aliases for Truth.
Bug: 255714762
Test: presubmit
Change-Id: If91e9af5409fed9d5ccdd13749a0f562c545d589
2023-10-07 00:48:10 +00:00
Maciej Żenczykowski
3cb494fd28 move BPF_CGROUP_INET*_BIND registration into BpfHandler
(in preparation for moving it into netbpfload)

The programs themselves (in bpf_progs/block.c) required a 5.4+ kernel.

We relax this restriction to 4.19+ as we don't have any 5.4 device coverage
(while the pixel 4a 5G / 5 / 5a are all 4.19 devices).

I believe we could relax it further to 4.14+ but Pixel 4/4xl/4a that
would exercise those code paths are EOL and probably have poor to
non existent test coverage, and we cannot do anything for 4.9 T devices
anyway.

Note: on <4.19 kernels (ie. T devices running 4.9/4.14, U running 4.14)
this results in ConnectivityNativeService going from null to initialized
(as the bpf map will exist).

This doesn't hurt as the set/clear port interfaces are only ever
called by vendor code on devices where the kernel doesn't support
the older mechanism.  And even if you call them it will just set/clear
the bits in the bpf bitmap, they just won't actually affect anything.

We could flag the map itself as being 4.19+ as well, but I think
I prefer the no-op map to exist...

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1085addd22f4f3b709e1875049633832c5dac836
2023-10-06 14:31:20 -07:00