These directories are not populated on real devices
and are not part of the test suite.
This change removes them from the BPF loader.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I719d0feb9ef1a6f0a1e41265af47916410590ac7
Maciej Żenczykowskicommited 2025-06-16 01:28:45 -07:00
C/C++ platform bpf loader is being replaced by rust version.
This test never had much value, and additional relies on
a sepolicy violation being allowed by su.
The bpf ring buf test is far better.
Test: TreeHugger
Flag: EXEMPT test code removal
Signed-off-by: Maciej Żenczykowski maze@google.com>
Change-Id: I448cc543aa9a0c161515ae2189020bf98db7bca3
Maciej Żenczykowskicommited 2025-05-22 14:10:18 -07:00
Before this CL, the kernel version check occurred after all programs
were loaded by `open_file.load()`.
This CL moves the check before `open_file.load()`. It calls
`prog.set_autoload(false)` for programs incompatible with the current
kernel, preventing their auto-load by libbpf.
Test: Verify the program is not loaded if the kver is out of range
Bug: 410982483
Change-Id: Ifacd9dd8696a7bb4fd186ad1faf01fba9f021c6d
Before this CL, the kernel version check occurred after all maps
were loaded by `open_file.load()`.
This CL moves the check before `open_file.load()`. It calls
`map.set_autocreate(false)` for maps incompatible with the current
kernel, preventing their auto-creation by libbpf.
Test: Verify the map is not loaded if the kver is out of range
Bug: 410982483
Change-Id: I7a102dd2ef4b24f87c6efa5a105848fddc08d501
libbpf creates an array map for the .rodata section to allow BPF
programs to access its data. However, the loader does not need
to pin this map as userspace processes do not require access to it.
This does not break existing code as the legacy bpfloader did not
create a map for .rodata.
Bug: 410982483
Test: TH
Change-Id: I036c93849731c25e8d1b6a2c1778ffc60935bbe2
Currently, the owner and group apply to each BPF object file.
However, each map and program can specify a different owner and group,
even if they are in the same BPF object file.
This is a no-op for existing timeInState.bpf
Bug: 410982483
Test: TH
Change-Id: I0fa2731385645e598b4d3bb7d27200dbb6d3a8ec
This is a no-op because maps and progs of timeInState are always loaded.
They have min_kver: KVER_NONE and max_kver: KVER_INF.
Bug: 410982483
Test: atest bpfloader_tests with next CL
Change-Id: I5db1909126fb3ca43939f39653f8a2334f130e94
This is a no-op because maps and progs of timeInState are pinned under
/sys/fs/bpf/ and this directory already exists.
Bug: 410982483
Test: timeInState.bpf loaded successfully
Change-Id: Ied42ebcbde5c8727f19c31b8dc9930dac2ef5f79
The "dir" field specifies the directory where the BPF file is located.
The "prefix" field specifies the subdirectory under
/sys/fs/bpf/ where maps and programs are pinned.
These fields are required for memevents and vendor bpf.
This CL is a no-op for the existing timeInState.bpf loading
Bug: 410982483
Test: timeInState.bpf loaded successfully
Change-Id: Ic509b19490b9561173f84ace10d68c7725f8055b
This flag has already been released, so the code path
for its disabled state can now be removed.
Test: TH
Bug: 359646531
Bug: 410982483
Change-Id: Ia211fe240e6687e00470a9fb9350a2a7ae089580
this has moved to mainline via apex
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I77e6ae3248ce1aa1ee20c9ab834516053cac5d16
Maciej Żenczykowskicommited 2025-03-10 18:24:05 -07:00
Loader for libbpf based programs. It successfully
loads timeInState.bpf and pins its maps and programs to bpffs.
Bug: 359646531
Test: atest libtimeinstate_test
Change-Id: I9eaba3a15ea3af2eff2cb819bff8925e781e3c2a
Signed-off-by: Neill Kapron <nkapron@google.com>
Add a logger to enable rust native logging to kmsg on errors (and
therefore also to the serial port). Because bpfloader runs early in the
init process, errors could cause the boot to fail and therefore we
require the messages to go to the serial port to debug.
Bug: 359646531
Test: manual/TH
Change-Id: If3c5963fd17dea101769b844b970c7e2d6dd93c9
Signed-off-by: Neill Kapron <nkapron@google.com>
With the addition of aosp/3294153, we no longer need the c logging
functionality exposed to rust, so remove them
Bug: 359646531
Test: Manual
Change-Id: Ia6f61263f3315fe7dd3533556d9a5fdd2726a2b3
Signed-off-by: Neill Kapron <nkapron@google.com>
This should hopefully cause test failures to be clean test failures instead of hitting abort() and bringing down the entire test framework.
Test: TreeHugger
Bug: 366103938
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I26b78c904102e581e2d1e7b259a80dd0a6f3e50e
Maciej Żenczykowskicommited 2024-09-17 00:04:20 +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.
Test: TH
Change-Id: Ia6e69a7ae447490ddc7bc3e08f2d07753bae0eac
Signed-off-by: Neill Kapron <nkapron@google.com>
Create new memevents subdirectory to contain bpf related files for
libmemevents. Memevents-bpf are used to listen to kernel tracepoints
(BPF_PROG_TYPE_TRACEPOINT), and skfilter bpf progrs to inject mock data
for testing purposes (BPF_PROG_TYPE_SOCKET_FILTER).
Test: Verified memevents-bpf files are loaded in new subdir
Bug: 330396528
Change-Id: I57f7738f6a9eb18293cf9c51e0d1da2b2c1ebfe4
Signed-off-by: Carlos Galo <carlosgalo@google.com>
For trunk stable development, we use a build time feature flag for the
libbpf functionality to be added to bpfloader. For now, simply stub it
out.
This approach will allow merging and testing of libbpf functionality
without changing the binaries produced with the feature disabled going
forward.
Bug: 359646531
Test: manual/treehugger
Change-Id: I230e81b5f23b49a17f3731e0c40e184cde1c49c1
Signed-off-by: Neill Kapron <nkapron@google.com>
Needs to be before program loading, this should eventually allow loading programs in parallel.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I95933a5ffbe2230c19d0f91c167e1256ea2f3713
Maciej Żenczykowskicommited 2024-08-13 20:04:18 +00:00
In preparation for adding libbpf support via libbpf-rs, replace the
existing cpp bpfloader with a rust application calling into the
libbpf_android bindings to the legacy code.
Test: treehugger
Change-Id: I79eff1fece3372727c700308ff9a35029d0e34d3
Signed-off-by: Neill Kapron <nkapron@google.com>
Add bindgen rules to create rust bindings for libbpf_android. This will
be used to provide the legacy bpf support in the new rust bpfloader.
Test: treehugger
Change-Id: I22f7b38d6ccb25d4d1f61d9f6e672ab6f6abe42e
Signed-off-by: Neill Kapron <nkapron@google.com>
Should make integration with BpfLoader written in rust easier.
While at it add simple wrappers around ALOG{V,D,I,W,E}(),
which may come in handy as bpfloader runs early enough that
logging must be to the kernel dmesg ringbuffer instead...
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia49c605bae63241b74d04e2e0f58fd089c23993d
Maciej Żenczykowskiauthored and Neill Kaproncommited 2024-08-07 21:20:02 +00:00