Commit graph android_system_bpf/Android.bp
Message SHA1
Merge "Use platform bpf_helpers.h and bpf_map_def.h for platform bpfloader" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-06-18 04:40:48 -07:00
16e017f20e
Add missing vendor_available: true property
Due to b/424439549, Soong wasn't enforcing that vendor modules could only link against
other vendor modules.  Add vendor_available to any modules that are being used by
vendor modules in order to allow re-enabling the error in Soong.

Bug: 424439549
Flag: EXEMPT build only fix
Test: builds
Change-Id: I3aff720d743bc63d4a9f13505b39c55fde90116d

Colin Cross   commited 2025-06-16 20:45:39 +00:00
6169de2adc
Use platform bpf_helpers.h and bpf_map_def.h for platform bpfloader
Platform BPF programs rely on platform bpf_helpers.h and bpf_map_def.h.
To ensure consistency and correctness, the loader must use these platform
headers instead of those from p/m/Connectivity.

Bug: 424341374
Test: TH
Change-Id: Id5f1bc8fdd29e54c28a3ec9e01f6a9292f6bb9e1

Motomu Utsumi   commited 2025-06-13 13:04:02 +09:00
1f5cd4b9a1
Add -Wshadow to bpf_cc_defaults
Test: m
Change-Id: I08899d0c1bbdb05c3a2ef7df4b0debe748c25d94

Motomu Utsumi   commited 2025-03-21 16:27:05 +09:00
c52a98dde5
Add cflags and tidy_checks to bpf_cc_defaults
Copied from netd_defaults

Test: m
Change-Id: I28fd3c6239c3abee4a53b6449d5b0c1e81c260b2

Motomu Utsumi   commited 2025-03-21 11:17:31 +09:00
588140f93a
Add -Wtautological-unsigned-zero-compare to bpf_cc_defaults
Test: m
Change-Id: I6b9ae323f08b62c5208a1f99975eb11f6d72a89e

Motomu Utsumi   commited 2025-03-21 11:02:18 +09:00
6a162d7dab
BPF: Create android_bpf_defs
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>

Neill Kapron   commited 2024-11-22 19:12:30 +00:00
644d336d2c
BPF: Add vmlinux.h
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/vmlinux
https://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>

Neill Kapron   commited 2024-09-17 22:13:54 +00:00
432d150808
BPF: rename bpf_defaults to bpf_cc_defaults
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>

Neill Kapron   commited 2024-09-13 18:01:02 +00:00
19a5ec2f66
Disable tidy DeprecatedOrUnsafeBufferHandling check
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

Chih-Hung Hsieh   commited 2023-01-09 10:58:19 -08:00
ef3f44b639
[LSC] Add LOCAL_LICENSE_KINDS to system/bpf
Added SPDX-license-identifier-Apache-2.0 to:
  Android.bp
  bpfloader/Android.bp
  libbpf_android/Android.bp
  progs/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Ia881b61da1755797085916aab5325375c82ed76e

Bob Badour   commited 2021-02-05 01:28:19 -08:00
dcbf8ca070
C++17 is the default now.
Test: builds
Change-Id: Ieb3cf0a0c035e1b2fcea4a5e80bb0c1df473349f

Elliott Hughes   commited 2018-12-03 09:36:31 -08:00
fc3c7690fe
Code style clean up
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

Chenbo Feng   commited 2018-11-28 11:31:36 -08:00
1f20ad3d78
Skip the bpf native tests on old devices
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

Chenbo Feng   commited 2018-11-21 12:11:55 -08:00
249e2f869e
Disable noisy clang-tidy warning for int and long types
These are hard to avoid when working with POSIX APIs:

  warning: consider replacing 'unsigned int' with 'uint32' [google-runtime-int]

Change-Id: I30047ff05ff680a9337671368e6b82ba88244f79

Bernie Innocenti   commited 2018-10-25 22:12:07 +09:00
b2515ff7ce
Fix the build problem with bpf project
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

Chenbo Feng   commited 2018-10-16 21:17:12 -07:00
4c9e9ecc57