Commit graph

30 commits

Author SHA1 Message Date
Ryan Zuklie
ce89f50035 Add option to skip map/prog based on build type
This feature allows skipping a program or map based on the type of the
build. This allows things like userdebug-only programs.

Bug: 246985031
Test: added test program and watched it skipped on userdebug
Change-Id: I981e3447b40751926cbfd1692e13772ec582d3d4
2022-12-19 14:39:31 -08:00
Connor O'Brien
3141d5e2c0 libbpf_android: remove native_bridge_supported from Android.bp
This is a holdover from when libmeminfo depended on libbpf_android, a
dependency which has since been removed. Deleting it allows
libbpf_android to use libvintf, which will be used to identify a
device's kernel branch for BPF attach point enforcement.

Test: build
Change-Id: I73747e04c2a843652859e4fb753bd5afdedba1cd
Signed-off-by: Connor O'Brien <connoro@google.com>
2022-12-03 12:16:31 +00:00
Ken Chen
8693c789d3 Rename bpf_load_tp_prog.o and bpf_load_tp_prog_btf.o
Underscore character may cause bpf prog/map naming collision. For
example, x.o with map y_z and x_y.o with map z both result in x_y_z
prog/map name, which should be prevented during compile-time.

aosp/2147825 will prohibit underscore character in bpf source name
(source name derives the obj name). Existing bpf modules with underscore
characters in source name need to be updated accordingly.

Bug: 236706995
Test: atest libbpf_load_test
Change-Id: I037ccfedc4d2e48688ee47f575c73998ce1c2c4b
2022-07-10 18:31:18 +08:00
Maciej Żenczykowski
07f02b5177 remove libbpf_android_headers target
target just doesn't make sense any more,
since any user of the headers, which only declare lib provided functions,
also needs the library itself

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I135972468771070b9eab57efe082271f174e8ab3
2022-02-08 10:53:56 -08:00
Connor O'Brien
74a02dd975 Run libbpf_load_test in presubmit
Now that libbpf_load_test's bpf programs can be pushed to device
automatically, add a TEST_MAPPING file running it in presubmit for
changes to the libbpf_android subdirectory.

Test: atest --test-mapping system/bpf
Bug: 203823368
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: Ieef1144e87f5ffdabc277c29ac66aae56c7b7420
2022-01-28 12:26:28 -08:00
Connor O'Brien
509131481d libbpf_load_test: use "data" instead of "required" for test progs
atest appears not to know how to push dependencies listed with the
"required" property, but it will push "data" modules to the same
folder as the test itself. Update Android.bp to use data instead, and
change BpfLoadTest.cpp to reflect the new location of the test
programs.

Test: atest libbpf_load_test
Bug: 203823368
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: Iabec3662e2c03f4ab19e5cdce859e4238767519d
2022-01-28 12:26:16 -08:00
Connor O'Brien
0056fdce27 Test loading both with & without BTF
Add path to a test program with BTF info included to test bpfloader
handles both situations correctly

Test: libbpf_load_test
Bug: 203823368
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: Ibe63cdc2ee59199b687d4006efadb201d4a17f3c
2022-01-24 20:10:56 -08:00
Connor O'Brien
52863b6ba6 Update Loader.cpp for updated bcc
bpf_create_map and bpf_prog_load have been renamed, so update those
calls. bcc now depends on upstream libbpf and has deleted its
redundant implementations of bpf_obj_pin and bpf_obj_get, so add
upstream libbpf as a dependency.

Test: m libbpf_android
Bug: 203823368
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: I324cab44227b0e2f73873f37a28d640ab2373204
2022-01-18 09:26:17 -08:00
Ken Chen
fb045621be Rename bpf_map_utils to bpf_headers
Use a generic name so that it can contain more bpf related headers.

Bug: 202086915
Test: build
Change-Id: I36d93cbc77723464df84023752915e1e79e623df
2021-12-21 15:36:25 +08:00
Connor O'Brien
474eb0baa0 Rename libbpf to libbpf_bcc
This is to prevent a name collision with "upstream"
libbpf (external/libbpf) which is built using the same name.

Bug: 203823368
Test: build cuttlefish
Test: m libbpf_load_test
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: I9bb798a9b5d832511bed471f01575bba14a1a9d3
2021-12-16 13:16:05 -08:00
Ken Chen
b1d4888ec2 [NETD-BPF#14] Move BPF map definition and utils to frameworks/libs/net/
Move BPF map definition and utilities to a common place that easy to be
referenced from both mainline module and platform code.

Bug: 202086915
Test: m; flash; boot
Test: cd system/netd/ && atest
Test: cd packages/modules/Connectivity && atest
Test: m gpuservice_unittest libtimeinstate_test bpf_module_test
      CtsAppOpsTestCases libbpf_load_test VtsBootconfigTest
      vts_test_binary_bpf_module bpf_benchmark libbpf_load_test
      libbpf_android_test
Change-Id: Ib15cf78c2da97bff835fb406c866676eec77c013
2021-12-04 03:42:55 +00:00
Ken Chen
b81aef32e5 [NETD-BPF#13] Delete libbpf_android_test from system/bpf
The test will be moved to frameworks/libs/net along with header files.

Bug: 202086915
Test: m
Merged-In: I1de9c1f443f8bf90ef341e4867866093e62f427d
Change-Id: I1de9c1f443f8bf90ef341e4867866093e62f427d
2021-12-04 02:30:36 +00:00
Ken Chen
02c2536103 [NETD_BPF#8] Move BpfUtils.cpp to BpfUtils.h
Functions in BpfUtils.cpp are trivial, they can be static inlined
in BpfUtils.h.

Bug: 202086915
Test: m; flash; boot; cd system/netd && atest
Test: m gpuservice_unittest libtimeinstate_test bpf_module_test
      CtsAppOpsTestCases libmeminfo_test VtsBootconfigTest
      vts_test_binary_bpf_module
Change-Id: Ie1ece23b6fc9a4db5fc95930209a10da1e528cb5
2021-11-21 10:59:39 +08:00
Pirama Arumuga Nainar
e8d6df1231 Cleanup unused dependency to libprocessgroup
Bug: http://b/197965342

Dependence on libprocessgroup was removed in aosp/947297

Test: presubmit
Change-Id: I802efee3500e25006b55e0f35cb8650fd1aa2033
2021-08-31 19:59:20 +00:00
Bob Badour
dcbf8ca070 [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
2021-02-05 01:28:19 -08:00
Hungming Chen
a46f217d73 Use the module bpf_syscall_wrappers for BPF system calls
Use the versioned header library of BPF system calls and remove the
stubs.

Test: atest BpfMapTest
Change-Id: Ib178b02b7cfebaae7681609ae7c40a49cda47eeb
2021-01-13 14:34:41 +08:00
Lorenzo Colitti
8cc4f91fca Add an sdk_version annotation to libbpf_android_headers.
This will be used by the tethering module when running on S, so
it needs to have an sdk_version. Because this target does not
depend on anything, there is no need to change any other code.

Because this is only needed by the tethering module, which
shipped in R, pick the R SDK version, 30. That ensures we do not
need to support it on releases older than when it is needed.

Test: m
Bug: 173167302
Change-Id: I15c1e943d0c30aceebcb8288e78a5a8135ee7fd1
2021-01-08 13:18:10 +09:00
Suren Baghdasaryan
6597d87a67 libbpf_android: Add native_bridge_supported to allow usage in libmeminfo
libmeminfo needs to use BPF to read GPU usage reported by kernel
drivers, therefore a new dependency between libmeminfo and
libbpf_android is added. After this addition, native_bridge_supported
is required to successfully build cuttlefish targets.

Bug: 171261987
Test: build libmeminfo accessing BPF map
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I12e0613b13fb1206e204b5e85b4ea9a4d33e0cc9
2020-12-10 10:47:03 -08:00
Steven Moreland
e7cd2a72d0 libbpf_android: remove libnetdutils dep
Remove libnetdutils dependency because bpf is being used for things other
than networking these days, and we don't want to make libnetdutils
vendor-available in the future. libbase provides an alternative type now.

Bug: 140330870
Test: atest libbpf_android_test netd_integration_test netd_unit_test
    libnetdbpf_test bpf_module_test
Change-Id: I72ae8cd7f58a49bfc7dcb914a332a4c4bad5dea5
2020-01-21 10:47:33 -08:00
Steven Moreland
b572378120 TEST_MAPPING += libbpf_android_test
Note, this does not add libbpf_load_test as well because this test
requires adding a bpf program to the system image.

Bug: N/A
Test: `atest --test-mapping .`
Change-Id: I770ec4876e1cb93a526e99bcb5a234f964f46971
2020-01-15 08:28:44 +00:00
Maciej Żenczykowski
0cb8b5ca7a Merge "libbpf_load_test: fix map location" 2020-01-15 02:29:18 +00:00
Steven Moreland
cdeb9203af libbpf_load_test: fix map location
This test had bitrot.

Bug: N/A
Test: `atest libbpf_load_test`
Change-Id: I3480286e225d8dfbd0badd7bbb7cb77ff29ab0ea
2020-01-14 11:37:49 -08:00
Steven Moreland
4891e61341 libbpf_android: waitForProgsLoaded
Creating a function for this rather than having people copy/paste a loop
there.

It's very intentional that there is no timeout here. If bpfloader is
down, there is a serious problem, and we shouldn't let code move forward
in a state where it may not have been tested.

Bug: 140330870
Test: boot & use bpf/netd
Change-Id: I358d1fcf77ad5406e294dd57307bc411e2c8ad6a
2020-01-10 15:37:53 -08:00
Maciej Żenczykowski
1a4659c1ba libbpf_android_test - add 'require_root: true'
Bug: 141272654
Bug: 141307514
Test: now passes
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I29f89838743aa4bab3bf7cc643891e33da5fffdf
2019-09-19 14:41:56 -07:00
Zhijun He
855cf18f8b Revert "libprocessgroup users use libcutils"
This reverts commit f0336cb586.

Reason for revert: breaks all camera use cases

Bug: 135568875

Exempt-From-Owner-Approval: revert, no build cop

Change-Id: Ie228b8dd167d4788c3cf570d0ff531e88a06a170
2019-06-19 04:50:36 +00:00
Steven Moreland
f0336cb586 libprocessgroup users use libcutils
libprocessgroup symbols are being moved into libcutils in order to
optimize linking/memory usage. libprocessgroup will no longer be
required in the future (however removing references to it will come
separately).

Bug: 135145426
Test: boot
Change-Id: Ie268ddbdb5a8b2eb254c956c8262aed8405752fa
2019-06-18 16:25:28 +00:00
Joel Fernandes
4845288a6e Add tests for BPF loader
Bug: 112334572
Change-Id: I4457ee9ea3044c5c9ecb6ebfd5ad4f5a2c11dce5
Signed-off-by: Joel Fernandes <joelaf@google.com>
2019-02-04 15:28:52 -05:00
Suren Baghdasaryan
9217ccba51 Remove hardcoded cgroup v2 path
Replace hardcoded cgroup v2 root path with new libprocessgroup API calls.

Bug: 111307099
Test: builds, boots

Change-Id: Ic9c47b52702767f9934f65d04bb91ab303b1d06e
Merged-In: Ic9c47b52702767f9934f65d04bb91ab303b1d06e
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-02-02 16:58:40 +00:00
Joel Fernandes
d76a2004a6 Initial checkin for relocatable ELF loader and link with bcc
* Wrote a relocatable ELF loader from scratch. The loader library loads
all objects in /system/etc/bpf/, parses and fixes up eBPF instructions
based on relocation information, creates maps and programs and pins
them. A single API call without arguments is made which results in this
operation. The API has all the information it needs from the filesystem
and the ELF objects, so there is no configuration stored in the code
calling the loader API essentially making it zero conf. Initially this
will be used by time_in_state statistics collection using tracepoints.
In the future, netd's eBPF C code should be rewritten to use this
infrastructure and the old ELF loader can be gotten rid off. This is the
first step.

* Link libbpf with libbpf_android which will come from the external/ bcc
project. This will be used for tracepoint and perf eBPF support. In the
future it can be used for other things as kernel eBPF support advances.

This patch will be merged only after bcc is cloned into external/ to
prevent build breakage.

Bug: 112334572
Change-Id: Ic0fd9504e18031132d40bb627c5e44058d59c9f8
Signed-off-by: Joel Fernandes <joelaf@google.com>
2018-12-17 22:27:56 +00:00
Chenbo Feng
79a4da2d1e Rename libbpf to libbpf_android
Rename the bpf support library in android to libbpf_android to make
it compatible with external bcc project. Fix the Android.bp file to
prevent build break.

Bug: 112334572
Test: No build breakage.
Change-Id: I24ae8aaf8ca8afdded5e46d21f0deec68d6030da
2018-11-08 11:32:31 -08:00
Renamed from libbpf/Android.bp (Browse further)