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
This commit is contained in:
Maciej Żenczykowski 2025-09-11 11:44:07 -07:00
commit db324dfbca

View file

@ -34,28 +34,18 @@ inline uint64_t ptr_to_u64(const void * const x) {
return (uint64_t)(uintptr_t)x;
}
#ifdef BPF_SUPPORT_CMD_FIXUP
static bool bpfCmdFixupIsNeeded = false;
#else
static constexpr bool bpfCmdFixupIsNeeded = false;
#endif
inline long bpfCmdFixup(enum bpf_cmd cmd) {
return cmd + (cmd >= BPF_PROG_TEST_RUN && bpfCmdFixupIsNeeded);
}
/* Note: bpf_attr is a union which might have a much larger size then the anonymous struct portion
* of it that we are using. The kernel's bpf() system call will perform a strict check to ensure
* all unused portions are zero. It will fail with E2BIG if we don't fully zero bpf_attr.
*/
inline int bpf(enum bpf_cmd cmd, const bpf_attr& attr) {
return syscall(__NR_bpf, bpfCmdFixup(cmd), &attr, sizeof(attr));
return syscall(__NR_bpf, cmd, &attr, sizeof(attr));
}
// this version is meant for use with cmd's which mutate the argument
inline int bpf(enum bpf_cmd cmd, bpf_attr *attr) {
return syscall(__NR_bpf, bpfCmdFixup(cmd), attr, sizeof(*attr));
return syscall(__NR_bpf, cmd, attr, sizeof(*attr));
}
inline int createMap(bpf_map_type map_type, uint32_t key_size, uint32_t value_size,