BTF_KIND_VAR and BTF_KIND_DATASEC were introduced in 5.2.
It should be possible to enable BTF on 4.18 or above since libbpf can
load BTF.
Also, current code should work on 5.4 but this is untested.
For now, this CL enables BTF on 5.10 or above.
Test: boot on 4.9, 4.19, 5.10
Test: adb logcat | grep NetBpfLoad
Change-Id: I3da4970464afcf9a76b1f2645ed79c44750bcd6a
Since btf is declared in inner scope, btf is null in outer scope and BTF
was always disabled.
This CL also makes NetBpfLoad buildable with -Wshadow flag
Test: adb log | grep NetBpfLoad
Change-Id: I511f21a3620ccfdadd797786e087d0d142c816ed
One ALOG to record whether the map is created by btf or not.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5da3af67ba28b01ee4e7b08e61f1fedc24e2840f
Maciej Żenczykowskicommited 2025-03-18 23:01:20 -07:00
BPF_ANNOTATE_KV_PAIR is used to tell the bpf loader about the btf
key_type and value_type of a bpf map.
This CL adds a method to get key value type ids from
BPF_ANNOTATE_KV_PAIR
Bug: 403381101
Test: boot
Change-Id: If308d49b64b38f65991a0a8177e5072d54e2cdf6
Motomu Utsumiauthored and Maciej Żenczykowskicommited 2025-03-18 12:15:39 -07:00
size in btf_type of BTF_KIND_DATASEC is 0 at compilation time.
So bpf loader needs to update to actual size based on ELF's section
size.
Bug: 403381101
Test: boot
Change-Id: I78fb26a5b8eeb120044b5737667f472fac51d79f
Motomu Utsumiauthored and Maciej Żenczykowskicommited 2025-03-18 11:46:16 -07:00
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
This reverts commit 0e9b0e05c6.
Reason for revert: needs a .31rc specific version instead.
Will merge the required changes into the followup commit.
Change-Id: I01e9dfee4aaabc3ddab39da7519b7d9963b84124
Maciej Żenczykowskicommited 2025-03-04 21:54:09 -08:00
By itself this change is a no-op, as we don't actually *yet* start mdnsd_netbpfload.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic7665b3dd5716bd3bbdc96450a42e9b0c26441c9
Maciej Żenczykowskicommited 2025-03-04 14:21:46 -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
Note: this is a no-op for mainline as this file is built into platform,
and not into the tethering apex mainline module.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1e66831eb7a4b506b6fdde9b2bad65a1a36bbe76
Maciej Żenczykowskicommited 2024-09-23 21:27:37 +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
With the addition of defaults to the bpf soong module (see aosp/3249485
), the name `bpf_defaults` will be used to define defaults for bpf
program compilation. While there are separate soong namespaces for
module types and module names, rename the existing bpf_defaults
cc_defaults to bpf_cc_defaults for clarity.
While we're at it, add -Wextra, and cleanup unnecessary cflags in
clauses which use bpf_cc_defaults. Add -Wno-sign-compare to resolve
build issues in external test code.
Test: TH
Change-Id: Id0407f86ad50033a77a8679d465dc9412991d764
Signed-off-by: Neill Kapron <nkapron@google.com>
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