Commit graph

109,281 commits

Message SHA1
Replace .toList() with .collect() am: 725078a6bd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3473841

Change-Id: I1c8117b31a8304e68c94f9ca0b45de944fe37ae5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Cole Faust   authored and   Automerger Merge Worker   commited 2025-02-03 17:17:16 -08:00
6586d080f6
Replace .toList() with .collect()
.toList() was only introduced to android in api level 34, which is newer than
this module's min_sdk_version. Replace it with .collect().

This was found while updating android lint.

Flag: EXEMPT refactor
Bug: 394096385
Test: Presubmits
Change-Id: I472bff7749aebb21bd8681ecf4235ce7a6cfc7de

Cole Faust   commited 2025-02-03 14:18:40 -08:00
725078a6bd
BpfHandler: reduce logging verbosity am: 0bcb13f41c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471822

Change-Id: Idff31da8e77055dff11df445d918749812ef874e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2025-01-31 14:32:40 -08:00
959dc32859
BpfHandler: reduce logging verbosity
most of these are spammy and/or not useful.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iab101ce7de076ef025a046d5e3e9007e091b271f

Maciej Żenczykowski   commited 2025-01-31 12:53:11 -08:00
0bcb13f41c
Merge "Prepare CtsTetheringTestLatestSdk for presubmit by adding it to postsubmit" into main am: 37bf450778
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471649

Change-Id: Ifd680631fbbd3ac471a37f0404e2d093ad86f44c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-01-31 02:30:28 -08:00
13ffa81b6d
Merge "Fix some comments around stopTetheringRequest" into main am: f09acc7281
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471270

Change-Id: I1dcfdea09ba07518d4785ad48d2ae2bf073b6110
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-01-31 02:30:15 -08:00
b7a64a7efe
Merge "Prepare CtsTetheringTestLatestSdk for presubmit by adding it to postsubmit" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-01-31 02:05:17 -08:00
37bf450778
Merge "Fix some comments around stopTetheringRequest" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-01-31 01:59:17 -08:00
f09acc7281
Merge "Add basic implementation of stopTetheringRequest" into main am: 6f57c93e30
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471168

Change-Id: Ie7d6c578f9471eab14a9504091dcd471fa4f839b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-01-31 01:20:07 -08:00
28cf32c4c5
Merge "Add basic implementation of stopTetheringRequest" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-01-31 00:59:58 -08:00
6f57c93e30
Prepare CtsTetheringTestLatestSdk for presubmit by adding it to postsubmit
This commit adds CtsTetheringTestLatestSdk to the postsubmit
configuration. This is a preparatory step towards moving the test to
presubmit, ensuring it runs regularly and catches issues earlier in the
development cycle.

Test: TH
Change-Id: I6932b0b660a675a20102d2683119f689557d8590

Yuyang Huang   commited 2025-01-31 17:51:21 +09:00
1325a02e96
Fix some comments around stopTetheringRequest
Bug: 216524590
Test: atest TetheringManagerTest
Change-Id: Iae0baa8ad7c199770666e2f78813cf0224ea1a9b

Quang Anh Luong   commited 2025-01-31 17:42:39 +09:00
75ac79db56
Add basic implementation of stopTetheringRequest
Add a basic implementation of stopTetheringRequest that simply stops
tethering for that specific type if it is active, or fail with
TETHER_ERROR_UNKNOWN_REQUEST if not. In the future, we will do fuzzy
matching to ensure the correct request is removed.

Bug: 216524590
Test: atest TetheringManagerTest#testStopTetheringRequest
Change-Id: Ib4a660aacdb83e645e39ceb61b7cda45bb24d89d

Quang Anh Luong   commited 2025-01-31 16:23:04 +09:00
696c164c2d
Merge "add kernel version comment for R/S pre-bpf" into main am: cb2125e666
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471808

Change-Id: If2731c031a2b422ba3cb45e80f7af831c1cd5ec4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2025-01-30 19:42:16 -08:00
e15d55c124
bpf_net_helpers: introduce bpf_get_netns_cookie() helper am: 259fe7e843
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471125

Change-Id: I6ee1f5e4a5ccc604ec8fff134af58882c061b460
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2025-01-30 19:42:04 -08:00
59512f0fac
Merge "add kernel version comment for R/S pre-bpf" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2025-01-30 19:14:23 -08:00
cb2125e666
bpf_net_helpers: introduce bpf_get_netns_cookie() helper
Linux Kernel documentation states:

* u64 bpf_get_netns_cookie(void *ctx)
Description
  Retrieve the cookie (generated by the kernel) of the network
  namespace the input *ctx* is associated with. The network
  namespace cookie remains stable for its lifetime and provides
  a global identifier that can be assumed unique. If *ctx* is
  NULL, then the helper returns the cookie for the initial
  network namespace. The cookie itself is very similar to that
  of **bpf_get_socket_cookie**\ () helper, but for network
  namespaces instead of sockets.
Return
  A 8-byte long opaque number.

This was introduced in Linux 5.7, see get_netns_cookie in
  https://elixir.bootlin.com/linux/v5.7/source/net/core/filter.c
vs
  https://elixir.bootlin.com/linux/v5.6/source/net/core/filter.c

But only for sock & sock_addr, while sock_ops & sk_msg were
added later (present in 6.12)

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Idccb7191552be8048a02fff2358e7d7898123dd9

Maciej Żenczykowski   authored and   Patrick Rohr   commited 2025-01-30 18:48:51 -08:00
259fe7e843
Merge "BpfHandler: add 25Q2+ netd map create and write test" into main am: 6825d9fa3e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471811

Change-Id: I679a33d1a4dcab38de38b509d98dc06381589383
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-01-30 16:21:05 -08:00
0ef873af13
bpf: define READ_ONCE and WRITE_ONCE am: 645b2d9755
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471115

Change-Id: I910dc1bfebcd2e89941f48dda59cf89f1a9625d3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2025-01-30 16:20:45 -08:00
25861cc156
Merge "BpfHandler: add 25Q2+ netd map create and write test" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-01-30 16:11:15 -08:00
6825d9fa3e
BpfHandler: add 25Q2+ netd map create and write test
Adding this to make sure we have 'unprivileged_bpf_disabled = 0'
This is currently set by NetBpfLoad, but if we remove that things currently work.

However with this change the device then fails to boot:
  $ adbz logcat -s -d *:* | egrep -i -C10 bpf
  I NetdUpdatable: libnetd_updatable_init: Initializing
  I NetdUpdatable: BPF programs are loaded
  I NetdUpdatable: initMaps successfully
  E NetdUpdatable: libnetd_updatable_init: Failed: (1) [Operation not permitted] : map create failed

This is because even though system/netd/server/netd.rc has:
  service netd /system/bin/netd
    class main
    capabilities CHOWN DAC_OVERRIDE DAC_READ_SEARCH FOWNER IPC_LOCK KILL NET_ADMIN NET_BIND_SERVICE NET_RAW SETUID SETGID
    user root
    group root net_admin

and we thus run as root/root with CAP_NET_ADMIN, but we do *NOT* have CAP_BPF nor CAP_SYS_ADMIN.
This means netd is considered 'unprivileged' from the point of view of that sysctl.

Creating maps from outside the bpfloader (ie. netd/system server/network stack)
is required for map-in-map.

While the sepolicy for netd.te map_create is in V, there is no real
need for this test on V atm, doing this to prevent *future* regressions.
A rollout purely to the not yet existing 25Q2+ is safer.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia39c74cfb1707e88b0aa534ddf42139b1698d5d6

Maciej Żenczykowski   commited 2025-01-30 14:58:07 -08:00
48f244ece4
bpf: define READ_ONCE and WRITE_ONCE
These are convenience macros which do
(const|volatile) cast for atomic operations.

I've run into a case where two 32-bit writes get optimized
by the compiler into a single 64-bit write, which then fails
verification.  WRITE_ONCE() avoids that by virtue of the volatile annotation.

Technically I think the same thing could happen on read,
so add READ_ONCE too.

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iade089aab3522916bd7b431d4064f89a21bc78b0

Maciej Żenczykowski   commited 2025-01-30 14:43:45 -08:00
645b2d9755
add kernel version comment for R/S pre-bpf
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifad1bb0928ad71be6ddacbe62cff4573323db521

Maciej Żenczykowski   commited 2025-01-30 12:36:13 -08:00
0a2340396f
Merge "Skip WiFi test in CtsWifiTestCases and CtsNetTestCases modules if feature not supported" into main am: 56d6ad9764
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3196975

Change-Id: I6da8bc5aafc03fad88a1c132cb746af36e5e99bd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-01-30 06:26:45 -08:00
dcb734ad81
Merge "Skip WiFi test in CtsWifiTestCases and CtsNetTestCases modules if feature not supported" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-01-30 05:56:27 -08:00
56d6ad9764
Merge changes from topic "log-placeholder-tethering-request" into main am: 3e0f6b37a2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471208

Change-Id: I80a32eea1a38a5a9ab1ec401209b22600372586f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Quang Luong   authored and   Automerger Merge Worker   commited 2025-01-30 01:16:47 -08:00
805af3e4e4
Merge changes from topic "log-placeholder-tethering-request" into main
* changes:
  Remove redundant requestedState from IpServer#enable
  Log tethering started with placeholder request
  no-op: Make TetheringRequest @NonNull in enableIpServing

Quang Luong   authored and   Gerrit Code Review   commited 2025-01-30 00:44:35 -08:00
3e0f6b37a2
Merge "ConnectivityManagerTest#testOpenConnection: skip Cuttlefish" into main am: 5f18c68810
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471188

Change-Id: I5a329ead2b50e929d5a5753c3fb9cc5b8791cb6d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-01-29 21:32:36 -08:00
c3a13cf7e0
Skip tests which need an IPv6 address on Cuttlefish. am: 7355ca14e5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3471189

Change-Id: I03b6eb35795bd468cc6a7c6996f929d9144908fc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2025-01-29 21:32:20 -08:00
b8e62e9857
Remove redundant requestedState from IpServer#enable
IpServer#enable is called with both a non-null TetheringRequest and the
requestedState, but the requestedState is derived from the
TetheringRequest's connectivity scope. Remove this requestedState arg
and simply have IpServer read the connectivity scope itself.

Bug: 216524590
Test: covered by existing tests
Change-Id: I73227f5053da3a2ab35563268fc416b6dd9b1801

Quang Anh Luong   commited 2025-01-30 14:30:51 +09:00
ffb503e86e
Log tethering started with placeholder request
Bug: 216524590
Test: build
Change-Id: I152505f83745f4d1f8148c72f15dcde990b8d7b9

Quang Anh Luong   commited 2025-01-30 14:30:51 +09:00
e1fd3c2daa
no-op: Make TetheringRequest @NonNull in enableIpServing
Currently the enableIpServing->tetherInternal call stack may have a
tethering request alongside a redundant tethering type and requested
state. The redundant arguments were necessary since there may be cases
where the active request is null (e.g. back-to-back start/stop, which
removes the active request before the link layer event enables ip
serving).

This change gets rid of the redundant arguments and makes the call stack
take a non-null TetheringRequest. In case the active request is not
found, we will create a placeholder request with just the type and
connectivity scope (i.e. requested state). This should be equivalent to
the old code of sending a null request (since none of the other fields
in TetheringRequest are used), making this a no-op change.

Bug: 216524590
Test: covered by existing tests
Change-Id: I5ac83c74f5bc4aec2fe85daa9477740749d95c63

Quang Anh Luong   commited 2025-01-30 14:30:49 +09:00
2b8a42d666
Merge "ConnectivityManagerTest#testOpenConnection: skip Cuttlefish" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-01-29 21:10:13 -08:00
5f18c68810
Skip tests which need an IPv6 address on Cuttlefish.
Avoids:

android.net.cts.DnsTest#testDnsWorks: FAILED (4.993s)

STACKTRACE:
java.lang.AssertionError: Default network did not provide IPv6 connectivity after 5000ms. Please connect to an IPv6-capable network.
lp={InterfaceName: wlan0 LinkAddresses: [ fe80::6c1f:76ff:fe50:2c84/64,192.168.99.115/25 ] DnsAddresses: [ /192.168.99.1 ] Domains: l
an MTU: 0 ServerAddress: /192.168.99.1 TcpBufferSizes: 524288,1048576,2097152,262144,524288,1048576 Routes: [ fe80::/64 -> :: wlan0 m
tu 0,192.168.99.0/25 -> 0.0.0.0 wlan0 mtu 0,0.0.0.0/0 -> 192.168.99.1 wlan0 mtu 0 ]}
  at org.junit.Assert.fail(Assert.java:89)
  at org.junit.Assert.assertTrue(Assert.java:42)
  at android.net.cts.DnsTest.ensureIpv6Connectivity(DnsTest.java:319)
  at android.net.cts.DnsTest.testDnsWorks(DnsTest.java:90)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4b94edae6d196ca02858702dec40ee2bad1db494

Maciej Żenczykowski   commited 2025-01-29 19:56:31 -08:00
7355ca14e5
ConnectivityManagerTest#testOpenConnection: skip Cuttlefish
due to:

android.net.cts.ConnectivityManagerTest#testOpenConnection: FAILED (277ms)

STACKTRACE:
java.lang.AssertionError: Same address '104.135.180.196' on two different networks (153, 143)
  at org.junit.Assert.fail(Assert.java:89)
  at org.junit.Assert.assertTrue(Assert.java:42)
  at org.junit.Assert.assertFalse(Assert.java:65)
  at android.net.cts.ConnectivityManagerTest.testOpenConnection(ConnectivityManagerTest.java:934)

This would possibly be fixed by cuttlefish having IPv6 connectivity, but it doesn't atm.

@RequiresDevice doesn't work right with atest.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5bd4189ed6297a2491dc0ab7b251ffd19d1ecb5d

Maciej Żenczykowski   commited 2025-01-29 19:54:48 -08:00
5d9885da86
Merge "Make it clear that legacyTether always uses IpServer.STATE_TETHERED." into main am: 36e7969920
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3470988

Change-Id: Id13c21fd34e935232db519cb85b0536003d1958b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-01-29 17:52:00 -08:00
4e029129eb
Merge "Make it clear that legacyTether always uses IpServer.STATE_TETHERED." into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-01-29 17:30:57 -08:00
36e7969920
Merge "Add coverage for StopTetheringCallback methods" into main am: 6bbe256bb7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3464383

Change-Id: Ica054f0bfe0e5394006db53b077d7555d6554496
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Quang Luong   authored and   Automerger Merge Worker   commited 2025-01-29 15:51:22 -08:00
3a441cbc8c
Merge "Add coverage for StopTetheringCallback methods" into main
Quang Luong   authored and   Gerrit Code Review   commited 2025-01-29 15:24:53 -08:00
6bbe256bb7
Merge changes Ib0c4a52e,Iff7d2981,Ie8af8b71,I7884faf8 into main am: 343429d013
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3465216

Change-Id: Ief1225eea63cdece2167f1980a519649c09fd8fb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Quang Luong   authored and   Automerger Merge Worker   commited 2025-01-29 14:13:26 -08:00
7af19f864b
Merge changes Ib0c4a52e,Iff7d2981,Ie8af8b71,I7884faf8 into main
* changes:
  Rename mActiveTetheringRequests to mPendingTetheringRequests
  Give the two variants of ensureIpServerStarted different names.
  Move the TetheringRequest further up the stack.
  Un-nest legacyTether by moving lambda contents to new method.

Quang Luong   authored and   Gerrit Code Review   commited 2025-01-29 13:48:17 -08:00
343429d013
Stop tracking left-over test interfaces am: d16138eeea
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3462422

Change-Id: Id420cfe88d5ac06a7abd1a5b06ff1b932e4743ce
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Patrick Rohr   authored and   Automerger Merge Worker   commited 2025-01-29 10:48:20 -08:00
7ef903ebc3
Stop tracking left-over test interfaces
When setIncludeTestInterfaces(false) is called, any RTM_DELLINK
callback for a testtap interface is ignored, since the interface is no
longer considered to be a valid ethernet interface.

Change setIncludeTestInterfaces to go through all interfaces, and stop
tracking the ones which are no longer valid. Otherwise, they will
stick around forever (and break subsequent tests).

Bug: 390722214
Test: TH
Change-Id: Ied73e86c0452831f4d6b00f67908c51201af8bbd

Patrick Rohr   commited 2025-01-29 07:34:27 -08:00
d16138eeea
Add coverage for StopTetheringCallback methods
Bug: 385014495
Bug: 385278741
Test: atest TetheringManagerTest
Change-Id: I176e3339a80a1efe5410092589f459fd7e94728a

Quang Anh Luong   commited 2025-01-29 17:42:00 +09:00
b16b6e6d2c
Make it clear that legacyTether always uses IpServer.STATE_TETHERED.
This is a no-op refactor

Bug: 216524590
Test: covered by existing tests
Change-Id: I2a3eb4a64cc9527793136b7ae6fb83d32923debd

Lorenzo Colitti   commited 2025-01-29 17:38:18 +09:00
dca881697c
Rename mActiveTetheringRequests to mPendingTetheringRequests
mActiveTetheringRequests is a misnomer because the requests aren't
actually active yet. Rename this to mPendingTetheringRequests since
they're pending a link layer event that the iface is ready to start IP
serving.

Bug: 216524590
Test: covered by existing tests
Change-Id: Ib0c4a52e0aa72fc27b67bce25187124b20082c05

Quang Anh Luong   authored and   Lorenzo Colitti   commited 2025-01-29 17:15:53 +09:00
caae4e7916
Give the two variants of ensureIpServerStarted different names.
The fact that the two overloads have the same name is confusing
because one of them fetches the type and one of them has it
passed in. This means it's not obvious whether they behave
identically or not.

This is a no-op refactor.

Bug: 216524590
Test: covered by existing tests
Change-Id: Iff7d2981cb5835831f00117166035d48b44a61a4

Lorenzo Colitti   commited 2025-01-29 17:11:37 +09:00
ac046ba684
Move the TetheringRequest further up the stack.
Currently, the active TetheringRequest (if any) is fetched at the
very bottom of the stack, just before enabling the IpServer.
Have the callers pass it in instead.

This CL is a no-op refactor. In particular, it ignores the fact
that the TetheringRequest can be null, and that the connectivity
scope in the request might not match the requested state, etc. -
it just documents the current behaviour (bugs included) and
leaves it unchanged. It exists only to make future changes
easier.

Bug: 216524590
Test: covered by existing tests
Change-Id: Ie8af8b718a9de1f1d5adde0ac589060dce112a27

Lorenzo Colitti   commited 2025-01-29 17:11:37 +09:00
7e43a1adfa
Un-nest legacyTether by moving lambda contents to new method.
This is a no-op refactor.

Bug: 216524590
Test: covered by existing tests
Change-Id: I7884faf8e0f187bb840ec80b8d6d86e3e4323553

Lorenzo Colitti   commited 2025-01-29 17:11:32 +09:00
6887c8d925
Merge changes from topic "serializablelambda" into main am: 544df81acf
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3463782

Change-Id: Idd769da9bba67d4a29b4a0d4ac60cd6416c8e1f0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Maciej Żenczykowski   authored and   Automerger Merge Worker   commited 2025-01-28 13:13:16 -08:00
e6968164ec