Commit graph android_packages_modules_Co.../bpf
Message SHA1
NetBpfLoad: Relax 5.10 kernel requirement
5.4 still works, so allow it for now.

Change-Id: Iea2407e323d5a99495630f877a119259ec82b643

Michael Bestas   commited 2026-01-05 19:40:50 +00:00
8e92e094e9
Android 16.0.0 release 4
-----BEGIN PGP SIGNATURE-----
 
 iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCaS5huQAKCRDorT+BmrEO
 eIsnAJ9kJ9OjiHpwigt9XwjTrGcbD1hQ0QCfSw2VHyS9TLyzt7DZsQ3AYU+WVVA=
 =/SH/
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN SSH SIGNATURE-----
 U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgPpdpjxPACTIhnlvYz0GM4BR7FJ
 +rYv3jMbfxNKD3JvcAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5
 AAAAQHUBff/oLA1TO7KbbZDsBJZmFVcXgFmG+2K3aaKq9F0tiaT1kiNeHdjXpaLI07p344
 TExz9CBvFVft81pJyRBwY=
 -----END SSH SIGNATURE-----

Merge tag 'android-16.0.0_r4' into staging/lineage-23.2_merge-android-16.0.0_r4

Android 16.0.0 release 4

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCaS5huQAKCRDorT+BmrEO
# eIsnAJ9kJ9OjiHpwigt9XwjTrGcbD1hQ0QCfSw2VHyS9TLyzt7DZsQ3AYU+WVVA=
# =/SH/
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Dec  2 05:49:13 2025 EET
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [ultimate]

# By Yan Yan (203) and others
# Via Automerger Merge Worker (1173) and others
* tag 'android-16.0.0_r4': (1057 commits)
  Use string for CREATE_APP_SPECIFIC_NETWORK permission
  bpf: move MSS calculation under CE check to avoid overhead
  BpfNetworkStats: use `atomic` for ifindex cache when possible
  NetBpfLoad: remove pointless 0 write.
  bpf: remove obsolete isAtLeastR/Sv2/25Q3
  NetBpfLoad: use global `api_level_full` directly in NetBpfLoad
  Log validated underlying network count that's available for VCN underlying network selection
  BpfUtils: fix sdk level detection logic for 25Q3+
  Add RTMGRP_IPV6_IFINFO
  bpf: remove BPFLOADER_MAINLINE_U_QPR3_VERSION
  bpf: move BPFLOADER_MAINLINE_S_VERSION into bpf_map_def.h
  Reduce log level for BluetoothSocket errors
  Bump the min sdk of Tethering
  BpfNetworkStats: apparently RiscV isn't actually a 64-bit architecture.
  KernelUtils.h: isAtLeastKernelVersion(x,y,z) - default 'z' to 0
  bpf_existence_test - update for tcp acc ecn
  bpf: tcpAccECN: eliminate header file and move more fully into netd
  BpfMap: shorten error strings to enable SSO (on 64-bit)
  BpfNetworkStats: enforce that IfaceValue access is lock-free
  NetBpfLoad: use libbpf based on mainline beta flag, part 2
  ...

 Conflicts:
	bpf/headers/include/bpf/KernelUtils.h
	bpf/progs/netd.h

Change-Id: I76a7aadc1405c6621e17f3d1b6b87640d84f5794

Michael Bestas   commited 2025-12-09 22:59:06 +02:00
42374b293f
Android 16.0.0 Release 3 (BP3A.250905.014)
-----BEGIN PGP SIGNATURE-----
 
 iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCaRO/HAAKCRDorT+BmrEO
 eOs9AJ9Yzz2HpDR3pyRIXhvl4k7bNABGvgCeMg5sU16s0CkFIDbZmOsSo4fswZQ=
 =1o5/
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN SSH SIGNATURE-----
 U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgPpdpjxPACTIhnlvYz0GM4BR7FJ
 +rYv3jMbfxNKD3JvcAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5
 AAAAQIRFF5B6T8EGhzDN+1dhvomEkctFjdVr5DZnhgnEIvcCEuzO36RzY3DBG9AIL+EejJ
 Z1zz7uAapzWUsyFpbYAQM=
 -----END SSH SIGNATURE-----

Merge tag 'android-16.0.0_r3' into staging/lineage-23.0_merge-android-16.0.0_r3

Android 16.0.0 Release 3 (BP3A.250905.014)

# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCaRO/HAAKCRDorT+BmrEO
# eOs9AJ9Yzz2HpDR3pyRIXhvl4k7bNABGvgCeMg5sU16s0CkFIDbZmOsSo4fswZQ=
# =1o5/
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Nov 12 00:56:28 2025 EET
# gpg:                using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [ultimate]

# By Patrick Rohr (91) and others
# Via Android (Google) Code Review (233) and others
* tag 'android-16.0.0_r3': (377 commits)
  Fix netbpfload version info.
  NetBpfLoad: add self-check for bpfGetNext{Prog,Map}Id()
  Add NetworkTemplate get/set transport type methods
  Pass EthernetPort to EthernetNetworkFactory#updateInterfaceLinkState
  Pass EthernetPort to updateInterfaceState
  Remove spurious VisibleForTesting and change visibility to public
  Pass EthernetPort to EthernetNetworkFactory#removeInterface
  Pass EthernetPort to removeInterface
  Pass EthernetPort to stopTrackingInterface
  Add getEthernetPorts and use it in getAllInterfaces
  Rename getClientModeInterfaces to getClientModeInterfacesSorted
  Rename getAvailableInterfaces to getInterfacesSorted
  Pass EthernetPort into NetworkInterfaceState
  Pass EthernetPort into EthernetNetworkFactory#addInterface
  Use multicast socket for group membership
  Test refactoring of DefaultNetworkRematchMetrics
  Fix SatisfiedTime initialization
  DHCPv6 addr reg: parse IA Address option.
  Pass EthernetPort to addInterface
  Change tethering interface to EthernetPort
  ...

 Conflicts:
	bpf/progs/netd.c
	service/src/com/android/server/ConnectivityService.java
	staticlibs/testutils/host/python/apf_test_base.py
	tests/cts/multidevices/apfv4_test.py
	tests/cts/multidevices/apfv6_test.py
	tests/cts/multidevices/run_tests.py
	tests/unit/java/com/android/server/connectivityservice/CSNetworkAgentTest.kt

Change-Id: Ifedf92aee90cbcc55ef8f9652de8b5faff1c30d9

Michael Bestas   commited 2025-11-14 10:29:02 +02:00
c7f07b6a13
bpf: move MSS calculation under CE check to avoid overhead
Currently, the MSS-based packet count calculation is performed for
every packet, regardless of whether the IP ECN field indicates CE
(congestion experienced). Since the computed value is only used
when CE is set, this results in unnecessary per-packet processing.

Move the MSS calculation inside the ip_ecn == 0b11 condition so
that it is only executed when a CE mark is actually present. This
reduces overhead on the fast path while preserving correct CE
accounting.

No functional change in CE handling, only an optimization in
execution flow.

Test: TreeHugger
Flag: EXEMPT PURE_REFACTOR
Signed-off-by: Sandeep <irlanki.s@samsung.corp-partner.google.com>
Change-Id: I5cae40f914473d9f914c826d50dd91c93e047ccc

Sandeep   authored and   Maciej Żenczykowski   commited 2025-09-15 02:07:44 -07:00
c2c6ce1966
Merge "bpf: remove obsolete isAtLeastR/Sv2/25Q3" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-13 05:06:29 -07:00
8095d6f081
Merge "NetBpfLoad: use global api_level_full directly in NetBpfLoad" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-09-13 05:06:06 -07:00
8ad4118d66
NetBpfLoad: remove pointless 0 write.
BPF array maps are zero initialized.

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

Maciej Żenczykowski   commited 2025-09-13 03:52:34 -07:00
b47900b7c5
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
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
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
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 "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
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
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
BpfMap.h: disable two ALOGE-s
They really don't add much to the picture.
The information is already in the exception.

Test: TreeHugger
Flag: EXEMPT mainline, logging
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I91b54814af20e02df11b8d035fa0ee1740cf644a

Maciej Żenczykowski   commited 2025-09-11 13:01:08 -07:00
0c239209a7
BpfMap: lower min allowed batch size
Vendor/OEM reports of some of their code failing to build due
to larger key/value sizes.

I'd make this check mainline only, but I can't seem to find
a way to actually make that (reliably) work.

So let's just lower the minimum from 256 to 64 - this should
I think still be enough for significant performance benefits
from using bulk operations.  Indeed probably even 10 would be
enough for that.

Bug: 442996907
Test: TreeHugger
Flag: EXEMPT mainline/trivial
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I69d53293dd5bb2174af7c814f531a08eba590310

Maciej Żenczykowski   commited 2025-09-11 13:01:08 -07:00
1476ec1141
NetBpfLoad: eliminate 'bpfCmdFixupIsNeeded'
It turns out this doesn't work anyway:

Both our Java and C++ higher level map opening logic on 4.14+
kernels will check key/value sizes match, which will fail due to
the kernel uapi mismatch.

(Note: that the fixup was only ever applied/enabled inside of
the NetBpfLoad process itself, not in any later .so/Java/JNI)

This removes the fixup and simply chooses to not even attempt to
load bpf.  This will result in the mainline bpf provided
maps and programs simply not existing.  This would/will cause
a failure of 'bpf_existence_test' - but who cares, so long
as things keep on booting.

We need to transition to libbpf, and clearly making this work
isn't worth the considerable effort it would be, since S ebpf
functionality (ie. tethering offload) hasn't worked on the
affected devices in years.

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

Maciej Żenczykowski   commited 2025-09-11 13:01:01 -07:00
db324dfbca
NetBpfLoad: move dir creation ahead of kernel uapi check
Test: TreeHugger
Flag: EXEMPT mainline/refactor
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I395d6f9abe0c0cbd8af662b1c94be16eeac4060b

Maciej Żenczykowski   commited 2025-09-11 12:04:56 -07:00
9611f93131
NetBpfLoad: reduce log spam
by joining two log lines into one with effectively the same info

(the kernel version is already printed during startup)

Test: TreeHugger
Flag: EXEMPT mainline / logging
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ide066edf2d54ffd6a61fdcb115a249bff80cdff9

Maciej Żenczykowski   commited 2025-09-11 11:34:49 -07:00
ff505eaaea
NetBpfLoad: Fail boot if BTF load fails on 4.19+
libbpf ignores BTF load error but this causes boot failure only when BTF
is required for some reasons (e.g. SK_STORAGE).
This CL makes boot fails regardless of the necessity of BTF on 4.19+
kernel

Test: boot kernel on 4.14, 4.19, 5.10, 6.1
Flag: EXEMPT mainline
Change-Id: I0af1e7eedcbea803c22c064ff157700a01307691

Motomu Utsumi   commited 2025-09-04 04:59:00 -07:00
8f3cfccf27
tcpAccECN: Move static const variables to file scope
The symbol name of a static const variable defined within a function
includes a '.' and old kernel BTF ferifier rejects it.
"""
08-29 15:11:27.825     0     0 W         : c3   1287 NetBpfLoad: [377] STRUCT _rodata size=64 vlen=3
08-29 15:11:27.825     0     0 W         : c3   1287 NetBpfLoad: 	tcp_option type_id=343 bits_offset=0
08-29 15:11:27.825     0     0 W         : c3   1287 NetBpfLoad: 	schedcls_ingress_accecn_eth_.new_cnt type_id=346 bits_offset=128 Invalid name
"""

This verifier limitation was relaxed in later kernels by
https://lore.kernel.org/bpf/20230615145607.3469985-1-revest@chromium.org/

Test: Boot on 4.19 kernel && logcat
Bug: 440448408
Bug: 442710894
Flag: EXEMPT tcpAccECN program is not used
Change-Id: If3c993bb6abb1ff8688932d682d909d335f84ca2

Motomu Utsumi   authored and   Maciej Żenczykowski   commited 2025-09-04 04:50:13 -07:00
937c57a2f8
tcpAccECN: Fix counter order in tcp option
Counter order in AccECN options is the following

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Kind = 174   |  Length = 11  |          EE1B field           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| EE1B (cont'd) |           ECEB field                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                  EE0B field                   |             Order 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Test: TH
Bug: 440448408
Flag: EXEMPT tcpAccECN program is not attached
Change-Id: I7d76d40f7499e44c89c8241919a0d3c416b0ce00

Motomu Utsumi   commited 2025-08-29 16:27:29 +09:00
2977062223
tcpAccECN: Fix to increment ceb counter
Before this CL, if the ip_ecn is 0b11, program returns without updating
byte_count->ceb

Test: TH
Bug: 440448408
Flag: EXEMPT tcpAccECN program is not used
Change-Id: I37aeddcb6807c43787b4f3ca0db26f47ffe190df

Motomu Utsumi   commited 2025-08-28 17:49:54 +09:00
de403d30e4
bpf/progs/tcpAccECN.c: use static const for another local constant
Likely not needed for kernel verifier happiness,
since even 1 'static' constant prevents .rodata from being
entirely empty/automatic and thus BTF-less.

Trivial follow up to go/ag/35341088

Bug: 441356399
Bug: 441436401
Test: TreeHugger
Flag: EXEMPT mainline/bug fix
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I396d1a4f2d47225707348f7c7dc3548cbba125a0

Maciej Żenczykowski   commited 2025-08-27 23:01:24 -07:00
4203f5008e
bpf/progs/tcpAccECN.c: use static const for local constants
loading BTF fails on 5.10 for tcpAccECN due to https://lore.kernel.org/bpf/20210119153519.3901963-1-yhs@fb.com

We're hitting the same problem on 5.10:
  ...
  NetBpfLoad: [381] DATASEC .rodata size=40 vlen=0 vlen == 0
  ...
  NetBpfLoad: libbpf: Error loading .BTF into kernel: -22. BTF is optional, ignoring.
  NetBpfLoad: libbpf: map 'sk_storage': failed to create: Invalid argument(-22)
  NetBpfLoad: libbpf: failed to load object '/apex/com.android.tethering/etc/bpf/mainline/netd.o'
  NetBpfLoad: Failed to load object: /apex/com.android.tethering/etc/bpf/mainline/netd.o, libbpf: 1
  NetBpfLoad: === CRITICAL FAILURE LOADING BPF PROGRAMS ===

so BTF fails, but SK_STORAGE *requires* BTF.

This is a kernel BTF verified failure fixed in later kernels.

step 1. Adjust the bpf helper definitions to more closely match kernel uabi in include/uapi/linux/bpf.h:
 * long bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *bpf_sock, int argval)
 * long bpf_reserve_hdr_opt(struct bpf_sock_ops *skops, u32 len, u64 flags)
 * long bpf_store_hdr_opt(struct bpf_sock_ops *skops, const void *from, u32 len, u64 flags)

(some for consistency, but what matters is the 'const' addition)

Dump current .rodata via:
  adb pull /apex/com.android.tethering/etc/bpf/mainline/netd.o && llvm-objdump -s -j .rodata netd.o
  m netd.o && llvm-objdump -s -j .rodata /android/out/soong/.intermediates/packages/modules/Connectivity/bpf/progs/netd.o/android_common/obj/unstripped/packages/modules/Connectivity/bpf/progs/netd.o

.../netd.o:  file format elf64-bpf
Contents of section .rodata:
 0000 ae0b0000 00000000 00000000 00000000  ................
 0010 00000000 00000000 01000000 00000000  ................
 0020 01000000 00000000                    ........

which lines up with:

  #define CUSTOM_TCP_OPTION_KIND 174  // 0xAE
  #define CUSTOM_TCP_OPTION_SIZE 11   // 0x0B
  #define TCPHDR_SYN 0x02

            struct {
                __u8 kind;
                __u8 length;
                __u8 data[CUSTOM_TCP_OPTION_SIZE - 2];
            } __attribute__((packed)) tcp_option = {
                .kind = CUSTOM_TCP_OPTION_KIND,    // 0xAE
                .length = CUSTOM_TCP_OPTION_SIZE,  // 0x0B
                .data = {0},                       // 9 bytes
            };                                     // 5 byte alignment pad

and

  typedef struct{
    uint64_t ceb;
    uint64_t e0b;
    uint64_t e1b;
  } EcnByteCounters;
  STRUCT_SIZE(EcnByteCounters, 8 * 3);  <-- 24 bytes

  {
                        EcnByteCounters new_cnt = {
                            .ceb = 0,
                            .e0b = 1,
                            .e1b = 1,
                        };
                        bpf_l4s_accecn_byte_map_update_elem(&flow_key, &new_cnt, 0);
  }

Which matches the final 24 bytes.

So we convert those to 'static const' which hopefully will get them debug info.
(following the comment in the last line of the above linked patch)

Bug: 441356399
Bug: 441436401
Test: TreeHugger
Flag: EXEMPT mainline/bug fix
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7d871c54ecccf2abc7834fde3c63c073cad29004

Maciej Żenczykowski   commited 2025-08-27 14:35:43 -07:00
157e8cd78b
tcpAccECN: increase min required kernel to 6.1
Appear to be failing on pixel 7 U (which is 5.10)

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

Maciej Żenczykowski   commited 2025-08-27 13:06:28 -07:00
74d3460f5d
Merge "bpf_existence_test: remove support for Android R" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-27 04:22:27 -07:00
717a18c65c
Merge "bpf: build tcpAccECN into netd.o" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-26 13:00:18 -07:00
b21ed8fb38
Merge "netbpfload.35rc: grant capability SYSLOG if available" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-26 11:32:13 -07:00
439770c5e2
bpf: build tcpAccECN into netd.o
Note that currently bpfloader is *still* always <25Q4 (and thus <26Q2).

With this change:
  $ adb shell find /sys/fs/bpf/ | egrep -i tcp
is empty.

With the 26Q2 changed to 25Q3 it is not:
  $ adbz shell find /sys/fs/bpf/ | egrep -i tcp
  /sys/fs/bpf/netd_shared/prog_tcpAccECN_schedcls_egress_accecn_rawip
  /sys/fs/bpf/netd_shared/prog_tcpAccECN_schedcls_ingress_accecn_rawip
  /sys/fs/bpf/netd_shared/prog_tcpAccECN_schedcls_egress_accecn_eth
  /sys/fs/bpf/netd_shared/prog_tcpAccECN_schedcls_ingress_accecn_eth
  /sys/fs/bpf/netd_shared/prog_tcpAccECN_sockops_accecn_option
  /sys/fs/bpf/netd_shared/map_tcpAccECN_l4s_accecn_mss_map
  /sys/fs/bpf/netd_shared/map_tcpAccECN_l4s_accecn_byte_map
  /sys/fs/bpf/netd_shared/map_tcpAccECN_l4s_accecn_ce_map

Test: TreeHugger
Flag: EXEMPT mainline / noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1c95a51e0774a2840fc906a2128ed5d71097dab6

Maciej Żenczykowski   commited 2025-08-26 09:59:20 -07:00
23057f4db5
bpf_existence_test: remove support for Android R
As of M-2025-11 mainline is only being pushed to S+

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

Maciej Żenczykowski   commited 2025-08-26 09:56:45 -07:00
1780108641
tcpAccECN: Add to the dependency of the tethering apex
This CL also sorts bpf targets in Android.bp

Test: m
Bug: 440448408
Flag: EXEMPT tcpAccECN is not used
Change-Id: I4a662870333f3da02d4d6cfcb3fca8c0af452d34

Motomu Utsumi   commited 2025-08-26 10:21:53 +09:00
95ab63a373
Merge "NetBpfLoad: use macro for mainline beta flag" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:54:37 -07:00
c528cbf687
Merge "tcpAccECN: remove duplicated definitions of load_word and load_half" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:52:10 -07:00
bfd1b36ea0
Merge "tcpAccECN: add build target" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:51:00 -07:00
96694e36ca
Merge "tcpAccECN: update DEFINE_BPF_PROG to follow the current syntax" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:50:16 -07:00
0562b55916
Merge "tcpAccECN: remove CRITICAL" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:49:28 -07:00
e77c943066
Merge "tcpAccECN: define required macros" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:49:01 -07:00
c36345cfdf
Merge "tcpAccECN: remove carriage returns" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:48:05 -07:00
23215028c4
Merge "NetBpfLoad: Add default map flag for BPF_MAP_TYPE_LRU_HASH" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:47:16 -07:00
2de52a3d0b
NetBpfLoad: use macro for mainline beta flag
Flag: com.android.tethering.readonly.flags.use_libbpf
Bug: 428792764
Test: Enable/Disable flag, boot, adb shell logcat
Change-Id: I40e6124f6c96cf09ce50f38d786f15847ec6f69d

Motomu Utsumi   commited 2025-08-25 20:54:37 +09:00
aa8717db44
bpf: Allow overriding kernel version
This allows devices pretend they are on a different kernel version in
order to support different bpf features in case kernel backports are in
place.

Test: set ro.bpf.kver_override=5.4.186 in product.prop on sm8150 device
      based on 4.14 kernel with 5.4 bpf backported, boot
Change-Id: I50357ee832b01b11e499278244f77244c904e3e9

Michael Bestas   commited 2025-08-25 13:02:51 +03:00
75e4580fc6
Firewall: More apps/uids again
Bumping again. See I293f99ec498e4ccac98c39f298ba01ba554f2e33.
Reasons are all the same. MEMLOCK_RLIMIT is not a concern anymore
because libbpf will automatically increase it if needed for kernels
not using cgroup accounting.

Issue: calyxos#1249
Change-Id: I0ce50383e210e936696d4294b63342e700081313

Tommy Webb   authored and   Michael Bestas   commited 2025-08-25 13:02:44 +03:00
bd083ca393