Create a new header lib to assist with the transition between bpf and
libbpf.
Bug: 359646531
Test: Manual/TH
Change-Id: I6b57d22ce56851f751c2e77af32b15b2b789fb25
Signed-off-by: Neill Kapron <nkapron@google.com>
Generated from aosp_kernel-common-android15_6.6 build 12345991
Tagged as android15-6.6-2024-08-r7
These vmlinux.h files are used for bpf programs leveraging CO-RE to
access internal kernel data structures. They do not need to track the
target kernel perfectly, but if fields are added to an internal kernel
data structure, they must be regenerated before these fields are used.
Similarly, the BPF programs which use vmlinux.h should be compiled
against a vmlinux.h file which is generated from the vmlinux of the same
architecture. On Android, this is not a problem for arm64 or x86_64
architectures, as the 64bit system userspace matches the 64bit kernel.
However, for 32 bit Android userspace, either arm or x86, we currently
have no way to determine at build time if the kernel we will be running
on will be 32bit or 64bit. For this reason, we default to 32bit
userspace running on 64bit kernel, and therefore loading libbpf programs
will be disabled at runtime for systems with 32bit kernels.
In the future, it would be good to create the infrastructure to
periodically update this to a version with the latest tracking kernel.
vmlinux.h files are manually generated using the following command:
bpftool btf dump file <path/to/vmlinux> format c > vmlinux.h
The vmlinux artifact can be downloaded through this process:
Navigate to
https://source.android.com/docs/core/architecture/kernel/gki-android15-6_6-release-builds#launch-releases
and identify the link to the latest release kernel artifacts, in this
case android15-6.6-2024-08-r7 is linked to
https://ci.android.com/builds/submitted/12345991/kernel_aarch64/latest
Appending '/vmlinux' to the end will take you directly to the artifact
download for aarch64.
Change the 'kernel_aarch64' path to 'kernel_x86_64' to download the
x86_64 vmlinux file.
The final download paths for the vmlinux files used in this change are:
https://ci.android.com/builds/submitted/12345991/kernel_aarch64/latest/vmlinuxhttps://ci.android.com/builds/submitted/12345991/kernel_x86_64/latest/vmlinux
Internally, this can be done with:
/google/data/ro/projects/android/fetch_artifact --bid 12345991 --target kernel_aarch64 'vmlinux'
/google/data/ro/projects/android/fetch_artifact --bid 12345991 --target kernel_x86_64 'vmlinux'
Using bpftool v7.3.0 with libbpf v1.3 with llvm, skeletons enabled:
cd system/bpf/imclude/vmlinux/arm64/
<cp aarch64 vmlinux file here>
bpftool btf dump file vmlinux format c > vmlinux.h
rm vmlinux
cd ../x86_64
<cp x86_64 vmlinux file here>
bpftool btf dump file vmlinux format c > vmlinux.h
rm vmlinux
For future automation use, the following command may be useful in
identifying the latest kernel release tag:
git -c 'versionsort.suffix=-' ls-remote --tags --refs \
https://android.googlesource.com/kernel/common/ android15-6.6-202\* \
| tail --lines=1
Test: Manual / TH
Bug: 359646531
Change-Id: I59946a6ea1a724b5ed9c2d8edff061236702c32d
Signed-off-by: Neill Kapron <nkapron@google.com>
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.
Test: TH
Change-Id: Ia6e69a7ae447490ddc7bc3e08f2d07753bae0eac
Signed-off-by: Neill Kapron <nkapron@google.com>
This check is disabled in global default,
see build/soong/cc/config/tidy.go.
This bpf_defaults is used to compile an external/bcc module.
Unless all such warnings can be fixed in the external/bcc source,
we should not enable this check locally.
Test: presubmit; make tidy-external-bcc_subset
Change-Id: I97f6dd944dfb21fed664175c5c7eec02c10ebe4c
Apply the git clang format on the bpf project to make sure the existing
code compliance with the standard.
Test: project compiles and bpfMapTest pass.
Bug: 112334572
Change-Id: I4774aa2a197be2c671f6fb307c1fc9b71edfeeec
For older devices that doesn't have bpf support, skip the bpf native
tests so we don't get false alarms. Fixed some compiler warning and
added the clang-format check.
Test: ./libnetdbpf_test/libnetdbpf_test
Bug: 119526856
Change-Id: Icb73a8ee9b9dff9a0da28b96578e1245f1f3724f
These are hard to avoid when working with POSIX APIs:
warning: consider replacing 'unsigned int' with 'uint32' [google-runtime-int]
Change-Id: I30047ff05ff680a9337671368e6b82ba88244f79
Add the necessary Android.bp file and fix the compile error for the new
bpf project.
Fix the run time restart false alarm in bpf loader.
Bug: 112334572
Test: device boot and dumpsys netd show eBPF object okay, runtime
restart netd and no bpfloader error showed in logcat.
Change-Id: Iae193bda45e50b7d22479086d6403e3c4fb185c4