summaryrefslogtreecommitdiff
path: root/libbpf_android
Commit message (Collapse)AuthorAgeFilesLines
* expose readSectionUint() for testingMaciej Żenczykowski2021-07-062-1/+4
| | | | | | | | | Bug: 190519702 Test: atest bpf_module_test, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Original-Change: https://android-review.googlesource.com/1756850 Merged-In: I772c918d162440de6cc492b2faeafe03340fca11 Change-Id: I772c918d162440de6cc492b2faeafe03340fca11
* bpf - struct bpf_map_def - add min/max kernel version.Maciej Żenczykowski2021-07-061-10/+26
| | | | | | | | | | | | | 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> Original-Change: https://android-review.googlesource.com/1756575 Merged-In: I085cc723ff1c19d8acc8972a391f894e16dd1875 Change-Id: I085cc723ff1c19d8acc8972a391f894e16dd1875
* bpfloader - minor fixups asked for by reviewerMaciej Żenczykowski2021-07-021-2/+2
| | | | | | | | | | | | 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> Original-Change: https://android-review.googlesource.com/1754722 Merged-In: I4f5181f371d31dcf52768217ffd2b1b5b772103d Change-Id: I4f5181f371d31dcf52768217ffd2b1b5b772103d
* bpf loader improvements for better long term compatibility with mainlineMaciej Żenczykowski2021-07-021-12/+146
| | | | | | | | | | | | | | | | | | 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> Original-Change: https://android-review.googlesource.com/1754794 Merged-In: I36fa5b917540be7ea3ecfddc5fe7834e9eb18d88 Change-Id: I36fa5b917540be7ea3ecfddc5fe7834e9eb18d88
* BpfUtils.h - add back SKIP_IF_BPF_NOT_SUPPORTED macroMaciej Żenczykowski2021-03-111-0/+16
| | | | | | | | Needs to be used by dns mainline module tests on R devices (Pixel 2). Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I2974a5368f4a9d744e30be9148aefac117d09acb
* bpfloader: auto-demote DEVMAP/DEVMAP_HASH map types on too old kernelsMaciej Żenczykowski2021-03-051-1/+22
| | | | | | | | | | | | | | | | | | Basically: <4.14: DEVMAP -> ARRAY <5.4: DEVMAP_HASH -> HASH See added comments for explanation of why, but basically: This allows our bpf program .o files to load maps on all kernel versions, even if those map types are not supported by the kernel. This avoids the need for code that conditionally creates maps based on kernel version. Any program that actually attempts to use one of these maps will fail to load, but programs are already loaded conditionally based on kernel version so this is not a problem. Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I1a1d73b68de3606423de078fddb224402621e154
* make failure on map creation returns -errnoMaciej Żenczykowski2021-03-021-2/+4
| | | | | | | | | | This slightly improves error logging. (also fd == 0 is not an error condition) Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I135e7405c508951fba632c634bc4e2d2161fc940
* KVER macro - support 4.9.256+ kernelMaciej Żenczykowski2021-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Instead of doing 16/8/8 bits for major/minor/subver macro, switch to 8/8/16 bits, since this gives plenty of space: - major versions are bumped every few years, so 256 last forever - minor versions are bumped every few months (~5-6 per year), so 256 lasts for decades, additionally Linus Torvalds doesn't like big numbers, and eventually bumps the major instead - sub versions are the problematic ones, because they're bumped on every LTS security release, however even at one release per day, 16 bits lasts for 180 years Note: before this change 4.9.256 was treated as equivalent to 4.10.0. Luckily all our tests were only ever (by chance) against the LTS release bases (ie. 4.9.0, 4.14.0, 4.19.0, 5.4.0) and thus we wouldn't have hit an actually failure until 4.9.(5*256) === 4.14.0 which would have caused the bpfloader to attempt to load bpf code requiring 4.14 on a 4.9 kernel, and resulted in failure of device to successfully boot. Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I0535ce081967af092f3342c0abfd05a1e5028eb6
* [LSC] Add LOCAL_LICENSE_KINDS to system/bpfBob Badour2021-02-051-0/+8
| | | | | | | | | | | | | | | | | 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
* BpfMap - fix a clang warning: misc-unconventional-assign-operatorMaciej Żenczykowski2021-01-231-2/+3
| | | | | | | | | | | //system/bpf/libbpf_android:libbpf_android_test clang-tidy BpfMapTest.cpp system/bpf/libbpf_android/include/bpf/BpfMap.h:138:5: warning: operator=() should return 'BpfMap&' [misc-unconventional-assign-operator] void operator=(BpfMap<Key, Value>&& other) noexcept { ^ Test: builds without warnings Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I0bb0d42f58bba58c7b9220f062453d827438e85a
* move waitForProgsLoaded() to header fileMaciej Żenczykowski2021-01-212-17/+12
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I2f0035f2622ca2a8c10d29caff912f3f895f2607
* eliminate LoaderUtils.hMaciej Żenczykowski2021-01-212-42/+18
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I662714ee4faa6485d2ba7bbcbc8e34c76e37b091
* header file cleanupMaciej Żenczykowski2021-01-213-14/+3
| | | | | | Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I03920e51bab3cb704f156ea9c62a0a38fd65a3a9
* add SKIP_IF_XDP_NOT_SUPPORTED macroMaciej Żenczykowski2021-01-201-0/+9
| | | | | | Test: builds, atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ia954983565250faff547e81a53ec0df5fc26827e
* remove isBpfSupported()Maciej Żenczykowski2021-01-191-4/+0
| | | | | | | Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ifb4b4ced25ac444fe913c6392c0c8d57b2d9c58e
* remove BpfLevel and getBpfSupportLevel in favour of isAtLeastKernelVersionMaciej Żenczykowski2021-01-192-37/+14
| | | | | | | Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I50dbed1843a8c2802e1b416281e193ae7d282a99
* put tethering bpf maps & programs in /sys/fs/bpf/tethering/...Maciej Żenczykowski2021-01-202-10/+14
| | | | | | | | | | This makes it harder for system and mainline bpf programs to conflict with each other, thus enabling easier mainline module updates. Test: builds and boots, atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ic1b69bb1ddc4a10bd4861dadbd6b97e2520c532d
* Merge changes Ic378d0e5,Ib3a8696aTreehugger Robot2021-01-202-22/+1
|\ | | | | | | | | | | * changes: remove unused enum value BpfLevel::NONE remove unused function BpfLevelToString()
| * remove unused enum value BpfLevel::NONEMaciej Żenczykowski2021-01-201-4/+1
| | | | | | | | | | | | | | Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ic378d0e5a579abf44985a3353a21885796c297bb
| * remove unused function BpfLevelToString()Maciej Żenczykowski2021-01-202-18/+0
| | | | | | | | | | | | | | Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ib3a8696a9653e5fbb022c98c26cfff623fadb3b4
* | Merge "remove unused macros SKIP_IF_BPF{,_NOT}_SUPPORTED"Treehugger Robot2021-01-201-13/+0
|\ \
| * | remove unused macros SKIP_IF_BPF{,_NOT}_SUPPORTEDMaciej Żenczykowski2021-01-201-13/+0
| |/ | | | | | | | | | | | | Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ic740b1102fcf735516123eee2c6a3d5caa0892f9
* / bpf is always supportedMaciej Żenczykowski2021-01-201-2/+0
|/ | | | | | | Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ifcc6ff2b2293b7585f20108ad849408ed9af4538
* libbpf_android/Loader.cpp - fix a clang warning ↵Maciej Żenczykowski2021-01-191-7/+2
| | | | | | | | | | | | | | (clang-analyzer-deadcode.DeadStores) //system/bpf/libbpf_android:libbpf_android clang-tidy Loader.cpp system/bpf/libbpf_android/Loader.cpp:133:5: warning: Value stored to 'entries' is never read [clang-analyzer-deadcode.DeadStores] entries = shTable.size(); ^ system/bpf/libbpf_android/Loader.cpp:133:5: note: Value stored to 'entries' is never read Test: builds without warnings Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I548976b59d44a51e992c9520e730fc9dae82fce2
* Merge "4.9 kernels must support eBPF (as of Android S)"Maciej Żenczykowski2021-01-141-17/+2
|\
| * 4.9 kernels must support eBPF (as of Android S)Maciej Żenczykowski2021-01-141-17/+2
| | | | | | | | | | | | | | | | | | | | so there is no longer a need to look at any properties or api levels. Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ia5479db807f5444e48251dff45fd42fff610d5ca
* | Merge "Use the module bpf_syscall_wrappers for BPF system calls"Maciej Żenczykowski2021-01-142-119/+3
|\ \ | |/ |/|
| * Use the module bpf_syscall_wrappers for BPF system callsHungming Chen2021-01-132-119/+3
| | | | | | | | | | | | | | | | Use the versioned header library of BPF system calls and remove the stubs. Test: atest BpfMapTest Change-Id: Ib178b02b7cfebaae7681609ae7c40a49cda47eeb
* | SKIP_IF_BPF_NOT_SUPPORTED is a no-opMaciej Żenczykowski2021-01-122-28/+0
|/ | | | | | | | | Android S requires devices to support eBPF. Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I62fb97f79103515f5a2fd531cfa36356d21a4a6f
* Merge "Add an sdk_version annotation to libbpf_android_headers."Treehugger Robot2021-01-081-0/+1
|\
| * Add an sdk_version annotation to libbpf_android_headers.Lorenzo Colitti2021-01-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | add support for xdp bpf program typeMaciej Żenczykowski2021-01-071-9/+10
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tested via: packages/modules/Connectivity/Tethering/Tethering/bpf_progs/offload.c: +DEFINE_BPF_PROG_KVER("xdp/test", AID_ROOT, AID_ROOT, + xdp_test, KVER(5, 10, 0)) +(struct xdp_md *ctx) { + return XDP_PASS; +} vsoc_x86:/ # ip link show dev lo 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 vsoc_x86:/ # ip link set dev lo xdp pinned /sys/fs/bpf/prog_offload_xdp_test vsoc_x86:/ # ip link show dev lo 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 xdpgeneric qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 prog/xdp id 3 tag 3b185187f1855c4c jited vsoc_x86:/ # ip link set dev lo xdp off vsoc_x86:/ # ip link show dev lo 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 Test: atest, TreeHugger Bug: 167540099 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I7472d6d8120344abde9ea0f44c59a46f30da77f1
* libbpf_android: Add native_bridge_supported to allow usage in libmeminfoSuren Baghdasaryan2020-12-101-0/+2
| | | | | | | | | | | | 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
* rename BPF_FD_TO_INT() macro to BPF_FD_TO_U32()Maciej Żenczykowski2020-11-301-10/+10
| | | | | | | | | Cause that's what it actually does... Bug: 173167302 Test: atest BpfMapTest Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I8445cc4fe68f24bb3b26a678b7731b0c518e80f9
* Fix BPF_FD_JUST_USE_INT macromarkchien2020-12-011-1/+1
| | | | | | Bug: 173167302 Test: atest BpfMapTest Change-Id: I70b58e23cc5b04a187de8d55ddc3f2b367718b88
* Allow to just use integer for bpf fdmarkchien2020-11-131-18/+25
| | | | | | | | | | | | Bug: 173167302 Test: bpf_module_test clatd_test libnetdbpf_test netd_integration_test netd_unit_test netdutils_test Change-Id: I2643222e1eb2c5686d7f64eac8d9c4666a235c69
* reduce error to warning - happens for valid progs-section-less programsMaciej Żenczykowski2020-08-051-1/+1
| | | | | | | | | | | | 07-21 01:39:43.946 26835 26835 E LibBpfLoader: No progs section could be found in elf object 07-21 01:39:43.951 26835 26835 I bpfloader: Loaded object: /system/etc/bpf/clatd.o 07-21 01:39:43.955 26835 26835 I bpfloader: Loaded object: /system/etc/bpf/offload.o 07-21 01:39:43.958 26835 26835 I bpfloader: Loaded object: /system/etc/bpf/time_in_state.o 07-21 01:39:43.967 26835 26835 I bpfloader: Loaded object: /system/etc/bpf/netd.o Test: build, atest Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ie8413509f76741a66a4b00f0131a58e7ebdbae3f
* waitForProgsLoaded() - reduce log spaminessMaciej Żenczykowski2020-06-171-3/+12
| | | | | | | | | | | | | | | | | | | | | | Logging every 5s isn't actually useful and it just gets the important stuff out of log buffers. Test: adb logcat -s 'bpfloader:D' 'BpfUtils:D' 'LibBpfLoader:D' ... 06-17 01:02:34.205 433 433 E bpfloader: --- DO NOT EXPECT SYSTEM TO BOOT SUCCESSFULLY --- 06-17 01:02:38.103 335 335 W LibBpfLoader: Waited 5s for bpf.progs_loaded, still waiting... 06-17 01:02:48.104 335 335 W LibBpfLoader: Waited 10s for bpf.progs_loaded, still waiting... 06-17 01:03:08.104 335 335 W LibBpfLoader: Waited 20s for bpf.progs_loaded, still waiting... 06-17 01:04:12.226 335 335 W LibBpfLoader: Waited 60s for bpf.progs_loaded, still waiting... 06-17 01:04:17.628 1324 1324 W LibBpfLoader: Waited 5s for bpf.progs_loaded, still waiting... 06-17 01:04:27.629 1324 1324 W LibBpfLoader: Waited 10s for bpf.progs_loaded, still waiting... 06-17 01:04:47.629 1324 1324 W LibBpfLoader: Waited 20s for bpf.progs_loaded, still waiting... 06-17 01:05:50.163 1324 1324 W LibBpfLoader: Waited 60s for bpf.progs_loaded, still waiting... 06-17 01:05:55.551 1741 1741 W LibBpfLoader: Waited 5s for bpf.progs_loaded, still waiting... Bug: 150040815 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I77b82bf44141df8ffab1d11d01a89c3927fbe827
* implement support for functions which may optionally fail to loadMaciej Żenczykowski2020-06-173-6/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Warn loudly and do not set bpf.progs_loaded property on critical bpf load ↵Maciej Żenczykowski2020-06-153-6/+10
| | | | | | | | | | | | | failure. Reasoning: critical load failures for netd bpf programs will just result in unpredictable behaviour later on. For example netd/systemserver crash loops. Test: builds Bug: 150040815 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Iefa01e60cd0a9a223e96411726a199bfb4857a5a
* allow tagging a bpf .o as criticalMaciej Żenczykowski2020-06-151-1/+8
| | | | | | | | | | | | | | | | This does not yet do anything with this information besides logging it. Test: builds $ adb logcat -s -d LibBpfLoader:D | egrep Loading 06-14 22:52:48.657 430 430 D LibBpfLoader: Loading critical for netd ELF object /system/etc/bpf/offload.o with license Apache 2.0 06-14 22:52:48.682 430 430 D LibBpfLoader: Loading optional ELF object /system/etc/bpf/time_in_state.o with license GPL 06-14 22:52:48.729 430 430 D LibBpfLoader: Loading critical for netd ELF object /system/etc/bpf/clatd.o with license Apache 2.0 06-14 22:52:48.767 430 430 D LibBpfLoader: Loading critical for netd ELF object /system/etc/bpf/netd.o with license Apache 2.0 06-14 22:53:26.052 2605 2605 D LibBpfLoader: Loading optional ELF object /data/local/tmp/32/kern.o with license Apache 2.0 06-14 22:54:26.070 2605 2605 D LibBpfLoader: Loading optional ELF object /data/local/tmp/32/kern.o with license Apache 2.0 Bug: 150040815 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ie07549528800d6d7c5ff7f12b859702113d7194e
* only set 'bpf.progs_loaded' property on eBPF capable devices...Maciej Żenczykowski2020-06-131-0/+2
| | | | | | | | | | | ... which also means waitForProgsLoaded() has to be a no-op on pre-bpf devices. This is more consistent: it's weird to have bpf.progs_loaded set on a 4.4 device. Test: builds, atest Bug: 150040815 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Iddabcf56c187ea518dd2e4d8db451b2f6902aa8e
* BpfMap.h - fix cert-oop54-cpp compiler warningMaciej Żenczykowski2020-04-241-2/+3
| | | | | | | | | | | | | | | | | | Fixes: system/bpf/libbpf_android/include/bpf/BpfMap.h:132:10: warning: operator=() does not handle self-assignment properly [cert-oop54-cpp] void operator=(const BpfMap<Key, Value>& other) { ^ Matches the self-assignment check from https://clang.llvm.org/extra/clang-tidy/checks/bugprone-unhandled-self-assignment.html This isn't needed here, since the code was already correct, but it does prevent a pointless newfd = dup(fd); close(fd); sequence. Test: builds Bug: 153035880 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ia57f95d4ab180783c97db7e6f8d929f822c8958d
* Merge "libbpf_android/Loader.cpp - fixes ↵Maciej Żenczykowski2020-04-241-1/+4
|\ | | | | | | performance-inefficient-string-concatenation warning"
| * libbpf_android/Loader.cpp - fixes ↵Maciej Żenczykowski2020-04-241-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | performance-inefficient-string-concatenation warning Fixes: system/bpf/libbpf_android/Loader.cpp:562:73: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation] string progPinLoc = string(BPF_FS_PATH) + "prog_" + fname + "_" + name; ^ Test: builds Bug: 153035880 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: If56405273b4904e632a4b3a465b79eecae4c1446
* | Merge "change to ro.kernel.ebpf.supported property"Maciej Żenczykowski2020-04-241-2/+2
|\ \ | |/ |/|
| * change to ro.kernel.ebpf.supported propertyMaciej Żenczykowski2020-04-231-2/+2
| | | | | | | | | | | | | | | | | | to match https://android-review.googlesource.com/c/platform/system/sepolicy/+/1292919 Test: builds Bug: 151753987 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I43d9fd9c162edde6d7274bcc96049bf00278f056
* | libbpf_android/Loader - fixes performance-faster-string-find warningMaciej Żenczykowski2020-04-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: system/bpf/libbpf_android/Loader.cpp:557:49: warning: 'find_last_of' called with a string literal consisting of a single character; consider using the more effective overload accepting a character [performance-faster-string-find] name = name.substr(0, name.find_last_of("$")); ^~~ '$' Test: builds Bug: 153035880 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Iea62a59380c155796a7fa2ac4ca3352f9236ba98
* | bpf loader - finish support for kernel version conditional loadingMaciej Żenczykowski2020-04-211-9/+18
|/ | | | | | | | | | | | | | | | | | | | | | | | | | bpf program section names must be unique to prevent programs from appending to each other, so instead the bpf loader will strip everything past the final $ symbol when actually pinning the program into the filesystem. While at it add a little bit more logging. Example on aosp cuttlefish 5.4.30 virtual device: D LibBpfLoader: bpf_prog_load lib call for /system/etc/bpf/offload.o (schedcls_ingress_tether_ether) returned fd: 8 (no error) D LibBpfLoader: cs[1].name:schedcls_ingress_tether_rawip$stub min_kver:0 .max_kver:40e00 (kvers:5041e) D LibBpfLoader: cs[2].name:schedcls_ingress_tether_rawip$4_14 min_kver:40e00 .max_kver:ffffffff (kvers:5041e) D LibBpfLoader: bpf_prog_load lib call for /system/etc/bpf/offload.o (schedcls_ingress_tether_rawip$4_14) returned fd: 9 (no error) I bpfloader: Attempted load object: /system/etc/bpf/offload.o, ret: Success $ adb shell ls -l /sys/fs/bpf | egrep offload -rw-rw---- 1 root network_stack 0 2020-04-22 01:27 map_offload_tether_ingress_map -rw-rw---- 1 root network_stack 0 2020-04-22 01:27 map_offload_tether_stats_map -r--r----- 1 root root 0 2020-04-22 01:27 prog_offload_schedcls_ingress_tether_ether -r--r----- 1 root root 0 2020-04-22 01:27 prog_offload_schedcls_ingress_tether_rawip Test: builds, atest, proper program loaded on 5.4.30 aosp cuttlefish Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Id3fcb8e2a6b0087f704e77726e9961efc6145739
* Increase BPF test memlock rlimit to 1GB to match the bpfloader.Maciej Żenczykowski2020-03-311-2/+2
| | | | | | | Test: builds, atest Bug: 152285563 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ia283a66d38acfa3884463490a7a8c80560f5580d