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 Żenczykowskicommited 2025-09-13 03:28:18 -07:00
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 Żenczykowskicommited 2025-09-13 01:57:50 -07:00
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
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 Żenczykowskicommited 2025-09-12 12:07:08 -07:00
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 Żenczykowskicommited 2025-09-12 12:06:45 -07:00
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
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
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 Żenczykowskicommited 2025-09-12 11:16:29 -07:00
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 Żenczykowskicommited 2025-09-12 10:14:12 -07:00
(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 Żenczykowskicommited 2025-09-12 07:29:24 -07:00
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 Żenczykowskicommited 2025-09-12 07:12:57 -07:00
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 Żenczykowskicommited 2025-09-12 07:09:13 -07:00
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 Żenczykowskicommited 2025-09-12 04:04:39 -07:00
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
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
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
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
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
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
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
The implementation is similar to isNetworkStackFeatureNotChickenedOut.
Test: atest
Flag: EXEMPT BUGFIX
Change-Id: I65db78b4f707232c0fdadb580494cfa556d62295