Test: TreeHugger, manually installing tethering apex
(with and without dnsresolver apex) on pixel 6 running S
incl. 'atest bpf_existence_test'
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I63d4b84287e9c98dc0d2a517ac58d3f3ce9d7760
Maciej Żenczykowskicommited 2025-03-05 14:27:59 -08:00
Failure to jit means a buggy in kernel eBPF JIT implementation.
This cannot fail on a 64-bit kernel, because VINTF requires
kernel configuration option CONFIG_BPF_JIT_ALWAYS_ON.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I10cf7ff86bba6d3571ba919300024947446f1bb6
Maciej Żenczykowskicommited 2025-02-14 11:22:13 -08:00
This should always work on 4.14+
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I50fc17ff5b77f279cb741d6ef72e0519733ec881
Maciej Żenczykowskicommited 2025-02-14 11:18:18 -08:00
The function is not available in older kernels.
But when we do call it, fail on error - should not happen.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2695bf01762abcbc087a3bd67f1718e0e326576a
Maciej Żenczykowskicommited 2025-02-13 16:10:48 -08:00
for consistency with 3 other spots
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I726c314cbf70e3a9c09d4f95cf79109db38b59f7
Maciej Żenczykowskicommited 2025-02-13 16:05:07 -08:00
This intentionally does not block 32-bit userspace,
but it does mean existing 32-on-32 devices will need to
upgrade to 32-on-64 to upgrade to 25Q2+. Even Wear/TV.
This will allow us to unconditionally start using 64-bit
cli binaries for network admin tasks and avoid the entire
insanity that is 32-bit kernel net admin ABI of
iptables/netfilter & xfrm/ipsec.
Note: on at least x86 there's already code in netd that is outright incorrect if the kernel is not 64-bit.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9c18f82b38adeb223ffe3c6aebda50f057f3c818
Maciej Żenczykowskicommited 2025-02-10 21:54:34 -08:00
This reverts commit dcb2e7496c.
Reason for revert: will use negative size to imply no prealloc instead.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If1ce59acc592435537bce1d61857ba964bf8b6e6
Maciej Żenczykowskicommited 2025-01-20 12:10:04 -08:00
Note: this effectively (like the 6.6 check) does nothing atm, and is included purely for completeness.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9de5adffa0589cbf19fa4ddcb3cfe491f1600fde
Maciej Żenczykowskicommited 2024-12-11 07:14:12 -08:00
This unblocks building and testing for these devices on V only.
Networking may not work correctly, but at least the device will
boot.
Fix: 374252805
Test: cannot be tested due to lack of devices
Change-Id: I5be400d825bf7486454ff34e17123adac81a4447
Lorenzo Colitticommited 2024-12-04 09:59:33 +00:00
All 6 .c files under bpf/progs are flagged CRITICAL(),
and as such we can simplify this logic.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I884705e1f0fdb20c992499aa2c83d5953a24fd9e
Maciej Żenczykowskicommited 2024-09-18 23:46:16 +00:00
log_buf.size() was always BPF_LOAD_LOG_SZ and thus != 0
After changing ALOGD to ALOGI you now see (for example):
NetBpfLoad: BPF_PROG_LOAD call for /apex/com.android.tethering/etc/bpf/net_shared/block.o (bind4_block_port) returned 'processed 55 insns (limit 1000000) max_states_per_insn 0 total_states 4 peak_states 4 mark_read 1' fd: 6 (ok)
(ALOGV/ALOGD's are effectively silently dropped by the KernelLogger we use)
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4a296976ae3f1e2217c46d81ed48850fdfa95a3c
Maciej Żenczykowskicommited 2024-09-05 22:00:33 +00:00
(since this map relies on percpu access semantics,
and we don't even have userspace helpers to access PERCPU_ maps)
This will also be used by the upcoming satellite egress limiting logic.
See aosp/3235142
With this change we see:
$ adbz shell ls -lZ /sys/fs/bpf/net_shared/*_dscpPolicy_*
-rw-rw---- 1 root system u:object_r:fs_bpf_net_shared:s0 0 2024-09-04 17:01 /sys/fs/bpf/net_shared/map_dscpPolicy_ipv4_dscp_policies_map
-rw-rw---- 1 root system u:object_r:fs_bpf_net_shared:s0 0 2024-09-04 17:01 /sys/fs/bpf/net_shared/map_dscpPolicy_ipv6_dscp_policies_map
---------- 1 root root u:object_r:fs_bpf_loader:s0 0 2024-09-04 17:01 /sys/fs/bpf/net_shared/map_dscpPolicy_socket_policy_cache_map
-r--r----- 1 root system u:object_r:fs_bpf_net_shared:s0 0 2024-09-04 17:01 /sys/fs/bpf/net_shared/prog_dscpPolicy_schedcls_set_dscp_ether
Test: TreeHugger, atest CtsNetTestCases:android.net.cts.DscpPolicyTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I50a12ca4cd5587342f8aaf9df8cb28917f555252
Maciej Żenczykowskicommited 2024-09-04 17:41:47 -07:00
To shorten lines.
Now:
egrep 'base:' NetBpfLoad.cpp
only finds the 'using' statements.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8b125c420c106e4b9c2af0a4fa2e4892a08bb152
Maciej Żenczykowskicommited 2024-09-04 11:43:31 -07:00
Note that this is a no-op for everything before sdk=36+,
since V/sdk=35 only supports up to 6.6 LTS anyway.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I701045074dfb7b0c586536634e210318b5af364b
Maciej Żenczykowskicommited 2024-09-03 16:09:59 -07:00
This duplicates the previous check, but without the exceptions.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id83695689268baacd1112821fa3fd212c3aa0bb6
Maciej Żenczykowskicommited 2024-09-03 16:04:11 -07:00
(prep work to make next diff easier on the eyes)
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2a6a10cbdeace7e7b43d64bc1e0743216e4321e1
Maciej Żenczykowskicommited 2024-09-03 15:43:33 -07:00
(ALOGD can get entirely stripped out of the logs)
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I513d10acb9f1cc330b9cd5a4245f3af7e790a4d6
Maciej Żenczykowskicommited 2024-08-29 21:18:22 +00:00
BPF_PROG_LOAD can fail with various permission related
errors, and then it doesn't provide any extra debug details.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9f6f0bf30158828fe31045a11a1f4c015feeb61e
Maciej Żenczykowskicommited 2024-08-29 21:18:00 +00:00
We're reduced logging enough that it is no longer clear
which program failed to load.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8919a055f82d0c0e6e6818799463c606e853f70b
Maciej Żenczykowskicommited 2024-08-29 21:17:12 +00:00
This is entirely expected due to lack of implementation in <4.14.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifebe6843dc77b1b9a506c61239dcebe7262d0869
Maciej Żenczykowskicommited 2024-08-29 12:19:56 -07:00
Longer term we should fix the bpf_map_def.h to
actually set map_flags correctly.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4e7954ccd0afad4ca8d9cec179ad6efa20592609
Maciej Żenczykowskicommited 2024-08-29 18:10:28 +00:00
This allows changing the location of bpf programs easily
when building for the host to run on UML as a test.
Bug: 205608149
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I24816b6660581e74f277df39495a43027b77d2cf
Maciej Żenczykowskicommited 2024-08-26 17:29:52 -07:00
Some compilers warn/error and fail to build if it is not in proper order.
(specifically: triggers during build for host)
Bug: 205608149
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I84ddec9a2443939616fd78f522e8620680e1289e
Maciej Żenczykowskicommited 2024-08-26 17:29:47 -07:00
(particularly problematic on host builds where host headers are ancient...)
Bug: 205608149
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iae64b900464e7584ad657f18d8101993fd8c8e33
Maciej Żenczykowskicommited 2024-08-26 17:29:41 -07:00
These messages are quite spammy.
Since this is now all mainline code built/shipped together, they're basically all deterministic.
We print the map/program ids for all maps & programs we load which means it's pretty obvious what was skipped anyway.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id46d9be8f77bef0b4c86e3a76503570c43e43af4
Maciej Żenczykowskicommited 2024-08-22 23:43:27 +00:00
Generated via:
git mv staticlibs/native/bpf_headers bpf/headers
cd bpf/headers/include
git mv bpf/bpf_helpers.h .
git mv bpf/bpf_map_def.h .
manually fix up bpf/bpf_map_def.h include path
bpf_helpers.h is only used by bpf programs so the 'bpf/'
prefix is spurious.
bpf_map_def.h is only used by bpf programs and the two
bpfloaders, which effectively means the 'bpf/' prefix isn't
useful.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic3fc4e354a15821c27c23b7dbc019daad9f6ad85
Maciej Żenczykowskicommited 2024-08-21 13:18:59 -07:00
Step 2 of moving bpf related stuff into a common directory,
will ease development.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I95cab49ae03eb275982f43d2246085b06e66dc6d
Maciej Żenczykowskicommited 2024-08-20 19:51:41 -07:00