Commit graph

114,472 commits

Message SHA1
bpf: remove obsolete isAtLeastR/Sv2/25Q3
We no longer support mainline on R,
hence checks for R are not required.

We don't want any S vs Sv2 and 25Q2 vs 25Q3 differentiation.

Test: TreeHugger
Flag: EXEMPT PURE_REFACTOR
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I746b404520ccb12fddf02c6956d7cf1824f21bbd

Maciej Żenczykowski   commited 2025-09-13 03:28:18 -07:00
8e730ec9e0
NetBpfLoad: use global api_level_full directly in NetBpfLoad
This change removes the `bpfloader_ver` parameter from several internal functions and replaces its usage with the global `api_level_full` variable, simplifying function signatures.

Test: TreeHugger
Flag: EXEMPT PURE_REFACTOR
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6165e525d7aa49fbd7d12be0c3ea85015cfc6f3d

Maciej Żenczykowski   commited 2025-09-13 01:57:50 -07:00
68744c4a9a
Merge "Add RTMGRP_IPV6_IFINFO" into main
Xiao Ma   authored and   Android (Google) Code Review   commited 2025-09-12 21:07:08 -07:00
17d48b01af
Merge "[connectivity] support specifying flags in TestableNetworkCallback" into main
Kangping Dong   authored and   Android (Google) Code Review   commited 2025-09-12 18:49:30 -07:00
25a44360f5
Merge "Log validated underlying network count that's available for VCN underlying network selection" into main
Hnin Naing   authored and   Android (Google) Code Review   commited 2025-09-12 17:52:04 -07:00
264f2de492
Merge "BpfUtils: fix sdk level detection logic for 25Q3+" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-12 17:04:28 -07:00
c231a533ba
Log validated underlying network count that's available for VCN underlying network selection
Flag: EXEMPT METRICS
Test: atest FrameworksVcnTests, CtsVcnTestCases
Bug: 288600040
Change-Id: Ia1b51aa64388bc5c167f3a1081d8683d98fe0bef

Hnin Naing   commited 2025-09-12 22:50:11 +00:00
4ab80490ae
BpfUtils: fix sdk level detection logic for 25Q3+
Test: TreeHugger
Flag: EXEMPT BUGFIX
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I52ee176dc84e9c0e3e1bffd480841f1f1247eaa3

Maciej Żenczykowski   commited 2025-09-12 15:13:46 -07:00
942ea04d1f
Merge "Bump the min sdk of Tethering" into main
Pedro Loureiro   authored and   Android (Google) Code Review   commited 2025-09-12 15:01:57 -07:00
b528f1634b
Merge "Reduce log level for BluetoothSocket errors" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-09-12 14:07:35 -07:00
f0f91a110a
Merge changes from topics "redact-netcaps", "redact-specifier", "specifier-metrics" into main
* changes:
  [connectivity] rename createWithLocationInfoSanitizedIfNecessaryWhenParceled
  [connectivity] use new redact(RedactionType) for output NetworkSpecifier
  [connectivity] move redaction to createWithLocationInfoSanitizedIfNecessaryWhenParceled
  [connectivity] add permission check on requested NetworkSpecifier
  [connectivity] redact NeworkSpecifier in NetworkCapabilities
  [connectivity] add NetworkCapabilities.RedactionHelper
  [Thread] add REDACT_FOR_THREAD_NETWORK_PRIVILEGED

Kangping Dong   authored and   Android (Google) Code Review   commited 2025-09-12 13:26:22 -07:00
a133acc106
Add RTMGRP_IPV6_IFINFO
This is needed to receive IF_RA_MANAGED and IF_RA_OTHERCONF
notifications from netlink.

See inet6_ifinfo_notify() in addrconf.c.

Test: TH
Flag: NONE yes
Change-Id: I525eef4eb305c08aa2480e91321ea5fd514d4d65

Patrick Rohr   commited 2025-09-12 12:32:56 -07:00
715ef661e4
Merge changes I1ab48e0e,Ie12638a3,I2de4d067 into main
* changes:
  bpf: remove BPFLOADER_MAINLINE_U_QPR3_VERSION
  bpf: move BPFLOADER_MAINLINE_S_VERSION into bpf_map_def.h
  KernelUtils.h: isAtLeastKernelVersion(x,y,z) - default 'z' to 0

Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-12 12:07:19 -07:00
5a45c8dc80
bpf: remove BPFLOADER_MAINLINE_U_QPR3_VERSION
This is not used, and it seems unlikely we would ever
want to differentiate based on this.

Test: TreeHugger
Flag: EXEMPT PURE_REFACTOR
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1ab48e0e4dc7a8979a34509ebc3d901a0bce3840

Maciej Żenczykowski   commited 2025-09-12 12:07:08 -07:00
867eb61b9f
bpf: move BPFLOADER_MAINLINE_S_VERSION into bpf_map_def.h
also while at it renumber things so that in the future
we can autoderive the version from full api level.

Test: TreeHugger
Flag: EXEMPT PURE_REFACTOR
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie12638a3dcbde9db3e50d1736efa37154b22341c

Maciej Żenczykowski   commited 2025-09-12 12:06:45 -07:00
01640f15a4
Reduce log level for BluetoothSocket errors
This exception is also logged when the other side disconnects gracefully
(because there is no way to distinguish this case using the Bluetooth
APIs). This change reduces the log level to a warning because it is
almost always a red herring.

Test: TH
Flag: NONE yes
Change-Id: I94f20be91ff8481fdd1a50fbbc27200c57885426

Patrick Rohr   commited 2025-09-12 12:02:08 -07:00
81a472014a
Bump the min sdk of Tethering
This is required because we are bumping the min sdk of NetworkStack
which this depends on.

Test: build locally + aapt2 dump badging

Bug: 444168252

Flag: build.RELEASE_DEPRECATE_MAINLINE_R_SUPPORT
Change-Id: Idbff03cdcca9955a4759c19866895f755abedaaf

Pedro Loureiro   commited 2025-09-12 18:34:18 +00:00
48eb28f7ee
BpfNetworkStats: apparently RiscV isn't actually a 64-bit architecture.
I'll follow up with some sort of VTS test to block
RiscV until the compiler/language/libraries etc
can support something like CMPXCHG16B or ldp

Bug: 444697997
Flag: EXEMPT BUGFIX
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I553cffe3c4181842c38baf37258262e7b43b9ca4

Maciej Żenczykowski   commited 2025-09-12 11:16:29 -07:00
c2667777e1
KernelUtils.h: isAtLeastKernelVersion(x,y,z) - default 'z' to 0
This seems to be the most common usecase.

Test: TreeHugger
Flag: EXEMPT PURE_REFACTOR
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2de4d067b2f20680539cbddb31555864bcf957b1

Maciej Żenczykowski   commited 2025-09-12 10:14:12 -07:00
ee24054e2b
Merge "bpf_existence_test - update for tcp acc ecn" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-12 10:13:41 -07:00
8d04b03a69
Merge "BpfNetworkStats: enforce that IfaceValue access is lock-free" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-12 10:12:48 -07:00
b3edb33500
Merge "bpf: tcpAccECN: eliminate header file and move more fully into netd" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-09-12 10:03:39 -07:00
cb44b89e11
bpf_existence_test - update for tcp acc ecn
(also tested with a hack to make isAtLeast26Q2 true)

Test: TreeHugger
Flag: EXEMPT TEST_ONLY
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id1ef5b03cdc27b6d74d6b5bd76692186809e9658

Maciej Żenczykowski   commited 2025-09-12 07:29:24 -07:00
82d68064e1
bpf: tcpAccECN: eliminate header file and move more fully into netd
Test: TreeHugger
Flag: EXEMPT PURE_REFACTOR
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3a7a819e1958d7035aa9a046595ada45dce3be21

Maciej Żenczykowski   commited 2025-09-12 07:28:25 -07:00
0e9577bfc5
BpfMap: shorten error strings to enable SSO (on 64-bit)
This should be a performance improvement, as it avoids both memory
allocation (Short String Optimization fits the strings on the heap)
and string formatting.

Additionally should prevent us from triggering an abort()
on OOM as reported on the linked bug:

F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000000 (read)
F DEBUG   : Cause: null pointer dereference
F DEBUG   : backtrace:
F DEBUG   :       #00 pc 0000000000000000  <unknown>
F DEBUG   :       #01 pc 000000000001d008  /apex/com.android.tethering/lib64/libbase.so (fmt::v11::vformat(fmt::v11::basic_string_view<char>, fmt::v11::basic_format_args<fmt::v11::context>)+76) (BuildId: d200bca0044b833c9a13a387041b398a)
F DEBUG   :       #02 pc 0000000000007108  /apex/com.android.tethering/lib64/libcom.android.tethering.dns_helper.so (android::bpf::BpfMapRO<unsigned int, UidOwnerValue>::readValue(unsigned int) const+152) (BuildId: b20b032f10bd31bb44f969cef38dcd99)
F DEBUG   :       #03 pc 0000000000006ac8  /apex/com.android.tethering/lib64/libcom.android.tethering.dns_helper.so (android::net::DnsBpfHelper::isUidNetworkingBlocked(unsigned int, bool)+748) (BuildId: b20b032f10bd31bb44f969cef38dcd99)
F DEBUG   :       #04 pc 0000000000008328  /apex/com.android.tethering/lib64/libcom.android.tethering.dns_helper.so (ADnsHelper_isUidNetworkingBlocked.cfi+60) (BuildId: b20b032f10bd31bb44f969cef38dcd99)
F DEBUG   :       #05 pc 00000000001c43b0  /apex/com.android.resolv/lib64/libnetd_resolv.so (android::net::DnsProxyListener::GetAddrInfoHandler::run()+284) (BuildId: 9f306d9e52c85087c00931289aa2d7cd)
F DEBUG   :       #06 pc 00000000001bc888  /apex/com.android.resolv/lib64/libnetd_resolv.so (void* android::netdutils::runAndDelete<android::net::DnsProxyListener::Handler>(void*) (.cfi)+332) (BuildId: 9f306d9e52c85087c00931289aa2d7cd)
F DEBUG   :       #07 pc 0000000000085580  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*) (.__uniq.67847048707805468364044055584648682506)+232) (BuildId: 9ea0fa19fb5cc316f79c79f922c5a7dc)
F DEBUG   :       #08 pc 0000000000078248  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 9ea0fa19fb5cc316f79c79f922c5a7dc)

Bug: 441416613
Test: TreeHugger
Flag: EXEMPT BUGFIX
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibdae61b0ec67fd77f0be096ff934c8d424ae1e49

Maciej Żenczykowski   commited 2025-09-12 07:12:57 -07:00
8f637b873c
Merge "NetBpfLoad: use libbpf based on mainline beta flag, part 2" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-12 07:10:35 -07:00
4666361ca8
Merge "BpfRingbuf.h: add using-s" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-12 07:09:52 -07:00
c3f84096de
BpfNetworkStats: enforce that IfaceValue access is lock-free
Limited to non-32-bit due to build failures on:
  cf_gwear_x86-trunk_staging-userdebug
  eos-trunk_staging-userdebug
  seluna-next-userdebug
  seluna-trunk_staging-userdebug
  test_suites_x86_64-trunk_staging
  test_suites_x86_64-trunk_staging
  test_suites_x86_64-trunk_staging_coverage

This is unfortunate, as it likely means those platforms are
inefficient and possibly even buggy.

Test: TreeHugger
Flag: EXEMPT TEST_ONLY
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibf7eaa0707b0ec2e8eb9ac8ee9de8af20b94683b

Maciej Żenczykowski   commited 2025-09-12 07:09:13 -07:00
ef23cee4d7
NetBpfLoad: use libbpf based on mainline beta flag, part 2
Disable shared version of libtetheringflags
  - since the flags are readonly there is no real content to this,
    and it should be statically linked for compile/link time optimization
    (which should basically optimize the entire library out)

Use C++ magic to compile time verify the macro and flag are in sync.

The way this works:

constexpr auto useLibBpf = COM_ANDROID_TETHERING_READONLY_FLAGS_USE_LIBBPF;

^ this basically requires the macro to resolve to true/false, so that 'auto' resolves to 'const bool'

static_assert(std::is_same<decltype(useLibBpf), const bool>::value, "useLibBpf must be a boolean.");

^ which we check here

static_assert(useLibBpf == com::android::tethering::readonly:🎏:use_libbpf(), "useLibBpf flag mismatch");

^ and this then requires the macro and flag to be identical *and* compile time known

Test: TreeHugger
Flag: EXEMPT PURE_REFACTOR
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id5cd8c7d91b424765d6f469806434b3e9587f074

Maciej Żenczykowski   commited 2025-09-12 04:04:39 -07:00
1c59188cf0
BpfRingbuf.h: add using-s
Test: TreeHugger
Flag: EXEMPT PURE_REFACTOR
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie58548451ad21860dbd62776a6e3c4c124c57e00

Maciej Żenczykowski   commited 2025-09-12 03:35:11 -07:00
b9c34ae252
Merge "Add isCaptivePortalLoginFeatureNotChickenedOut" into main
Yuyang Huang   authored and   Android (Google) Code Review   commited 2025-09-12 00:51:14 -07:00
cb1a167e4d
[connectivity] support specifying flags in TestableNetworkCallback
This is to allow specifying redaction flags in NetworkCallback for tests
which requires the location permissions. The change is not used in this
CL but its Child CL ag/34224157

Bug: 374037595
Flag: EXEMPT PURE_REFACTOR

Change-Id: I143f8877ec62ff50ce4073727aad24e252a2af66

Kangping Dong   commited 2025-09-12 15:06:00 +08:00
95b78f8e6b
[connectivity] rename createWithLocationInfoSanitizedIfNecessaryWhenParceled
It's already redacting more sensitive information other than just
location info.

This is a follow up CL for https://googleplex-android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/34224156/comment/98b93666_a824d7bc/

Bug: 374037595
Flag: EXEMPT PURE_REFACTOR
Change-Id: I6524c4f9ee9b5273e4ab421f54ae3115dea2cc8a

Kangping Dong   commited 2025-09-12 15:06:00 +08:00
6fd0624452
[connectivity] use new redact(RedactionType) for output NetworkSpecifier
This commit replace the existing usage of NetworkSpecifier#redact() to
the new NetworkSpecifier#redact(RedactionType) API.

This doesn't change the existing behavior because redact() is still
called for NetworkSpecifiers which doesn't oevrride
getApplicableRedactions() method.

Bug: 374037595
Flag: NONE can't use simply flag guarding because the code needs to
      maintain compatibility across different mainline and platform versions

Change-Id: I30d7257b8e5880218b315ade60d2d77fed1f89fb

Kangping Dong   commited 2025-09-12 15:06:00 +08:00
997c5651d0
[connectivity] move redaction to createWithLocationInfoSanitizedIfNecessaryWhenParceled
This commit has almost no behavior changes, because:

1. usage of networkCapabilitiesRestrictedForCallerPermissions is
   either wrapped by
   createWithLocationInfoSanitizedIfNecessaryWhenParceled or
   getNetworkCapabilitiesInternal.
2. All usages of getNetworkCapabilitiesInternal is either wrapped by
   createWithLocationInfoSanitizedIfNecessaryWhenParceled or the
   redacted info in the return value is not used by its caller
3. The only exception for getNetworkCapabilitiesInternal is that it is
   used in simulateDataStall() which checks the underlying network but
   underlying network in the NetworkCapabilities can be redacted by
   networkCapabilitiesRestrictedForCallerPermissions. Removing redaction
   from getNetworkCapabilitiesInternal() will loose the current permission
   requirement but this is wanted as the existing implementation has
   stricter permission requirements than the API signature declares and
   this CL fixes it

Bug: 374037595
Flag: NONE no behavior change but only bug fix
Change-Id: I80491d26ed7d11cb3fe1850ef7be9ae7600d5dd5

Kangping Dong   commited 2025-09-12 15:06:00 +08:00
b9c6df36de
[connectivity] add permission check on requested NetworkSpecifier
This commit adds permission check for new NetworkSpecifier subclasses
which override the new redact(long) method. It throws SecurityException
if the caller doesn't hold the permissions to use the sensitive info in
the NetworkSpecifier class.

Bug: 374037595
Flag: NONE can't use simply flag guarding because the code needs to
maintain compatibility across different mainline and platform versions

Change-Id: Ife8efab3e99adf41d7522fedbde3b4ec80045c77

Kangping Dong   commited 2025-09-12 15:06:00 +08:00
d2c9202a9b
[connectivity] redact NeworkSpecifier in NetworkCapabilities
The existing NetworkCapabilities class redacts only TransportInfo and
leaves NetworkSpecifier as it is. This is counter-intuitive and the
specifier should be redacted along with TransportInfo as well.

Bug 374037595
Flag: NONE this has no behavior change for all existing
      NetworkSpecifier subclasses because they are not overriding the
      new NetworkSpecifier redaction methods

Change-Id: I73c880add1604afc8b56190647305a54e89e8e53

Kangping Dong   commited 2025-09-12 15:06:00 +08:00
5fd72324ce
[connectivity] add NetworkCapabilities.RedactionHelper
Add a new hidden inner class NetworkCapabilities.RedactionHelper for
accessing conditionally available NetworkSpecifier methods via
reflection.

Reflection is necessary because NetworkSpecifier is platform code. So
it's possible for a mainline update to define a
getApplicableRedactions() or redact(long) method in a subclass of
NetworkSpecifier (e.g., EthernetNetworkSpecifier), and then to run
that mainline module on an Android release where the
NetworkSpecifier base class does not have those methods. On such a
device, ConnectivityService must still call those methods if they
exist, otherwise it would fail to redact information that needs to
be redacted. Another way to do this would be for ConnectivityService
to just call the method and catch NoSuchMethodError, but this code
runs fairly often and constructing exceptions is expensive.

This class is not used in this CL but will be used for NetworkSpecifier
redaction in ag/34242202 and ag/34242203

Bug 374037595
Flag: NONE new code nerver used

Change-Id: I8f88c6bb105ebf8d485e18cd214bebf2abe67e63

Kangping Dong   commited 2025-09-12 15:05:55 +08:00
89c94195a0
Merge changes I496a03a2,I91b54814 into main
* changes:
  BpfMap: add ERROR_FROM_ERRNO macro helper
  BpfMap.h: disable two ALOGE-s

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-09-11 23:16:57 -07:00
d35ee46373
Merge "CCT VPN bypass for Android U and below" into main
Yuyang Huang   authored and   Android (Google) Code Review   commited 2025-09-11 22:20:35 -07:00
9dbdaeaf70
CCT VPN bypass for Android U and below
Implements logic to allow CCT to bypass VPN on Android U (API 34) and
older. On these Android versions, netd's VPN bypass APIs
(networkSetProtectAllow/Deny) operate globally.

Test: TH
Flag: NONE legacy flag protected
Change-Id: I3650c3823d65504046d74cd60485d9cc890937d8

Yuyang Huang   commited 2025-09-12 12:00:35 +09:00
7daab8cc60
Merge "Parse IFLA_INET6_FLAGS attr from the RTM_NEWLINK message." into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-09-11 18:53:12 -07:00
0c8a65ff9a
Add isCaptivePortalLoginFeatureNotChickenedOut
The implementation is similar to isNetworkStackFeatureNotChickenedOut.

Test: atest
Flag: EXEMPT BUGFIX
Change-Id: I65db78b4f707232c0fdadb580494cfa556d62295

Remi NGUYEN VAN   commited 2025-09-12 10:19:44 +09:00
9be6957f37
Merge "Refactor: Introduce Builder for RtNetlinkNeighborMessage" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-09-11 16:08:54 -07:00
5ed9c20ef1
Merge changes I56b28021,I69d53293 into main
* changes:
  BpfMap: remove @CriticalNative from nativeSynchronizeKernelRCU()
  BpfMap: lower min allowed batch size

Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-11 14:25:37 -07:00
88308548f5
Merge "NetBpfLoad: eliminate 'bpfCmdFixupIsNeeded'" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-11 14:24:28 -07:00
fed669c16c
Merge "NetBpfLoad: move dir creation ahead of kernel uapi check" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-11 14:22:40 -07:00
2a0a6309c6
Merge "NetBpfLoad: reduce log spam" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-11 14:22:09 -07:00
9bf528adeb
Merge "HACK: fix/disable a broken test." into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-11 14:21:29 -07:00
8ac3c80708
BpfMap: add ERROR_FROM_ERRNO macro helper
Test: TreeHugger
Flag: EXEMPT mainline, refactor, logging
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I496a03a2b590f0c171cb96cb4c64a430929ec3c5

Maciej Żenczykowski   commited 2025-09-11 13:01:08 -07:00
38304c4550