summaryrefslogtreecommitdiff
path: root/progs/include/bpf_map_def.h
AgeCommit message (Collapse)Author
2021-12-23[NETD-BPF#22] Move a few headers to frameworks/libs/netKen Chen
BPF headers used by both platform and mainline modules should be in frameworks/libs/net. Bug: 202086915 Test: build and boot Test: cd packages/modules/Connectivity/netd; atest Change-Id: Id9ac888d5519b2a8663232610d36386cabfe4e94
2021-11-18rename SEC() to SECTION()Maciej Żenczykowski
The only purpose of this is to break cut-and-paste of examples that use SEC() causing people to think things through, look at Android bpf program examples and use a better macro. In particular programs with SEC("license") / SEC("maps") need to be changed to use LICENSE("license") and the map helpers or the map section is wrong and cannot be correctly parsed by the bpfloader. Generated via: git grep 'SEC\(' | cut -d: -f1-2 | while read i; do mcedit $i; done and manually editting found locations Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Idb333967e054e096fe74f910a5f8aaf1d6c5dc81
2021-07-05bpf - struct bpf_map_def - add min/max kernel version.Maciej Żenczykowski
This is also bpfloader v0.2. Some newer map types (for example DEVMAP) are unusable on older kernel versions. Bug: 190519702 Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I085cc723ff1c19d8acc8972a391f894e16dd1875
2021-07-05bpf - add a bunch of static asserts on size/alignment of struct field typesMaciej Żenczykowski
It really turns out that till now we've just been lucky to not have ever used a 64-bit type. See also discussion on: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69560 (and other places on the internet) Bug: 190519702 Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ibe74a6f97bdbba490a7848060d07dc3efcee0e68
2021-07-02bpf - move to v0.1 .o struct formattingMaciej Żenczykowski
We cannot submit this as long as we want current mainline releases bpf .o objects to be loaded by images with bpfloader v0.0. Bug: 190519702 Test: atest, TreeHugger - existing bpf programs load examination of bpfloader logs Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I157458a4f798e455fb563fad569e20bfde5248fd
2021-07-02bpfloader - minor fixups asked for by reviewerMaciej Żenczykowski
As requested by Bernie on previous commit. Bug: 190519702 Test: atest, TreeHugger - existing bpf programs load examination of bpfloader logs Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I4f5181f371d31dcf52768217ffd2b1b5b772103d
2021-07-02bpf loader improvements for better long term compatibility with mainlineMaciej Żenczykowski
This is bpfLoader v0.1, previously we had no version number, the version immediately preceding this commit we'll call v0.0. Versions older than that are either pre-S and don't matter, since loading mainline eBpf code was only added in S, or are from early during the S development cycle (ie. pre-March 5th 2021 or earlier) and simply no longer supported (no need to maintain compatibility). Bug: 190519702 Test: atest, TreeHugger - existing bpf programs load examination of bpfloader logs Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I36fa5b917540be7ea3ecfddc5fe7834e9eb18d88
2021-03-04bpf_map_def.h - fix no longer correct commentMaciej Żenczykowski
This is due to changing how many bits are assigned to individual fragments, which was done to support kernel version 4.9.256. Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I7f556352beab009cd114e2241f3d7fe6d878a458
2020-06-17implement support for functions which may optionally fail to loadMaciej Żenczykowski
This is useful for critical functions with fallbacks, but may even be useful for non-critical functions, where a function in the middle of the file may fail to load, but you still want other (later) functions to be attempted. Critical applies to the entire .c file (or to be more correct to the entire resulting .o). Optional applies to a specific section of that .o (ie. a specific individual function). This new optional attribute is necessary to be able to declare a .c/.o file critical even if *some* of the individual functions might fail to load due to missing kernel patches. (Note: we currently have no way to specify a map as optional) Critical guarantees that all non-optional programs, and all maps, have been created, pinned, chowned, and chmoded successfully (or that they already existed). For an example of use see: system/netd/bpf_progs/offload.c (while at it also add retrieveProgram() and mapRetrieve{RW,RO,WO}() helpers to BpfUtils.h) Test: builds, atest, see paired netd change for extra details Bug: 150040815 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I50b292c061b05fc8f4b4b8574f128345c45c78db
2020-03-04Remove EXCLUDE_FS_CONFIG_STRUCTURESTom Cherry
This is no longer needed Bug: 149785767 Test: build Change-Id: Ic4c8f23dc5b9dbebfeee0820d007fd46919834b4
2020-02-19add support for marking ebpf programs as being only for some kernel versionsMaciej Żenczykowski
Some ebpf code cannot be loaded on too old kernels. Sometimes we want a different - more advanced - version of an ebpf program to be loaded on a newer kernel. Test: build, atest Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I9e93e7246951916e6d60544575337a7a19c82886
2020-02-18Pull AID_* constants from shared location.Maciej Żenczykowski
Test: build, atest Bug: 149434314 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Iadfc7fbbfcb561e7cfafaa5806939c9f69f43d59
2020-02-14bpfloader: add option to set owner & group for pinned programsConnor O'Brien
Unlike maps, BPF programs currently have no natural place to declare metadata like their desired owner & group. Add a bpf_prog_def struct to allow setting these, located in a new "progs" section, and update bpfloader to chown pinned programs appropriately based on this information. Add a #DEFINE_BPF_PROG macro to simplify adding this data for programs. The struct name is the name of the corresponding function with "_def" appended, which bpfloader uses to correlate a bpf_map_def with the correct program. Also have bpfloader set mode to 0440 for all programs, since only read access should ever be needed Bug: 149434314 Test: load a program that uses DEFINE_BPF_PROG and check that owner & group are set as expected Change-Id: I914c355f114368fe53de2c7f272d877463cba461 Signed-off-by: Connor O'Brien <connoro@google.com>
2020-02-14add bpf_map_def support for setting uid/gid/modeMaciej Żenczykowski
Test: build, atest, adb shell ls -lZ /sys/fs/bpf Bug: 149434314 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ie4001fbe16b4bc84fc8ec7138ae4928cd86f5ce7
2020-02-14bpfloader - add AID_* constants to bpf_map_def.hMaciej Żenczykowski
Test: build, atest Bug: 149434314 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I607f304a7e7bd76b8ce33489f9e239596f4d7398
2020-01-29refactor bpf_map_def into a single header fileMaciej Żenczykowski
Test: build, atest Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Iafd6016f4f24cc8fa263939c67e1a096aa91b125