Commit graph

1176 commits

Author SHA1 Message Date
Connor O'Brien
00fa9635f8 Make BpfLoadTest parameterized to support multiple test programs
This will enable testing both with & without BTF enabled once
necessary build changes are merged.

Test: libbpf_load_test passes
Bug: 203823368
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: Ifd89b6c0701791c216807e913d9a4803d9a4dd20
2022-01-21 18:24:21 -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
d568947cd7 [NETD-BPF#22] Move a few headers to frameworks/libs/net
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-12-23 09:50:01 +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
18af063372 [NETD-BPF#14] Move BPF map definition and utils to frameworks/libs/net/ am: b1d4888ec2
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1869329

Change-Id: Id05f96e6956be81adcce0c568bac678b8ea8cfaa
2021-12-04 13:27:08 +00:00
Ken Chen
798d0ae220 [NETD-BPF#13] Delete libbpf_android_test from system/bpf am: b81aef32e5
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1871536

Change-Id: If327280bc344a0cd980ae7b565fa7615c5d20e04
2021-12-04 13:27:07 +00: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
0f9e8af368 [NETD-BPF#10] Add WaitForProgsLoaded.h am: 5b0fbc192e
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1869328

Change-Id: I87ce9bbb4b16e08375e149a3bf418228ab8289ce
2021-12-03 10:15:14 +00:00
Ken Chen
eb3273cd75 Merge "[NETD_BPF#8] Move BpfUtils.cpp to BpfUtils.h" am: edfca8b548
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1869327

Change-Id: Ie5613d2a86e8b32866b3a4dd91a1d64e6d9b0ee9
2021-12-03 09:20:00 +00:00
Ken Chen
5b0fbc192e [NETD-BPF#10] Add WaitForProgsLoaded.h
Move waitForProgsLoaded() from libbpf_android.h to a single header file.
A transitional commit of separating headers, utilities from bfploader.

Bug: 202086915
Test: build; flash; cd system/netd; atest
Change-Id: Ief1bcd09e973f952c29859a7a8fba92c8626e32d
2021-12-03 08:16:24 +00:00
Ken Chen
edfca8b548 Merge "[NETD_BPF#8] Move BpfUtils.cpp to BpfUtils.h" 2021-12-03 08:15:06 +00:00
Paul Lawrence
f691bedf1d Support fuse prog types am: 9548f9fbed
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1894086

Change-Id: I87b30e592b2104c302aa09721b7683eed08f096b
2021-11-29 16:33:04 +00:00
Paul Lawrence
9548f9fbed Support fuse prog types
When fuse-bpf lands in the kernel, support reading its bpf program type
from /sys/fs/fuse/bpf_prog_type_fuse and load such programs.

This is to allow development of fuse-bpf to continue, and is needed
until such time as fuse-bpf is upstreamed and this value is fixed.

Bug: 202785178
Test: Along with change to bpfprogs, prog_fuse_media_fuse_media appears
in /sys/fs/bpf

Change-Id: I83636f25b0a0c678b3ee48c6450d9c8dc157387b
2021-11-23 00:28:12 +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
Maciej Żenczykowski
cb9d56d7f8 fix 'cgroupsockaddr' support am: 2b203138cb
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1897227

Change-Id: Ie824bebe88bd9edd4a958060a1aa0bdb7422fe78
2021-11-19 12:56:41 +00:00
Maciej Żenczykowski
2b203138cb fix 'cgroupsockaddr' support
... it does prefix matching - and first match wins.

By appending / to the strings this no longer matters.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I54f41fbccd2632334adb9d1ae4fcc44cd1b0141f
2021-11-19 11:18:57 +00:00
Maciej Żenczykowski
cd132dc1fc document how to debug bpfloader failures am: e49e0c60cd
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1896605

Change-Id: Ib243829d791547f7680ca0c78111616e6c6377c6
2021-11-19 01:33:46 +00:00
Maciej Żenczykowski
e49e0c60cd document how to debug bpfloader failures
Test: N/A
Bug: 204131517
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia6a8ca026f3ab403443e130dceb2aca0ce0f2343
2021-11-19 01:18:12 +00:00
Maciej Żenczykowski
c50acfa7b9 Merge "add mainline module support for targetting only newer bpfloader versions" am: 210d6be5ac
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1895608

Change-Id: I8cc973f23b777f39fa399db2ed345c066ee15d3f
2021-11-18 07:31:03 +00:00
Treehugger Robot
bab48348a4 Merge "rename SEC() to SECTION()" am: bc8df444d1
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1895607

Change-Id: I0f8bd3f270c5988e90c941c1cd3b507149a17a43
2021-11-18 07:30:54 +00:00
Maciej Żenczykowski
210d6be5ac Merge "add mainline module support for targetting only newer bpfloader versions" 2021-11-18 07:19:28 +00:00
Treehugger Robot
bc8df444d1 Merge "rename SEC() to SECTION()" 2021-11-18 07:18:54 +00:00
Maciej Żenczykowski
41661a10e3 add mainline module support for targetting only newer bpfloader versions
This will allow shipping .o's targetting only T and not S devices.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I651b4442625df9011ff7c5ad283943caae579565
2021-11-18 05:47:24 +00:00
Maciej Żenczykowski
3adb1d5569 rename SEC() to SECTION()
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-11-18 05:45:21 +00:00
Maciej Żenczykowski
d392956d00 Always use OWNERS from master branch. am: fbe8caf45a
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1895601

Change-Id: I6ef20684debb86f7c4b736193804ab01a8c78b6a
2021-11-18 05:42:29 +00:00
Maciej Żenczykowski
fbe8caf45a Always use OWNERS from master branch.
Since you cannot include yourself we need an extra level of indirection,
to make sure that OWNERS remains current even in historical branches.

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie3a4903cd4b115eddb60c75b00534e9a4fdcedda
2021-11-17 10:51:28 -08:00
Maciej Żenczykowski
4273296e72 BpfUtils.h - switch to GTEST_SKIP in all 4 SKIP macros am: 5460527c74
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1888239

Change-Id: Icd8bffdbfbc141d21d269d9ccc993b620d7bfbf9
2021-11-12 09:26:36 +00:00
Maciej Żenczykowski
5460527c74 BpfUtils.h - switch to GTEST_SKIP in all 4 SKIP macros
Test: TreeHugger, atest libbpf_android_test netd_unit_test netd_integration_test
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3acb47a432378f257418f81b26516e18d6ff3780
2021-11-11 11:54:02 -08:00
Maciej Żenczykowski
04a70b8dda bpfloader.rc: set /proc/sys/kernel/unprivileged_bpf_disabled to 0 am: fa03239a81
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1887534

Change-Id: If324aa1068a44e4338d0989317759a10e952b812
2021-11-11 12:32:52 +00:00
Maciej Żenczykowski
fa03239a81 bpfloader.rc: set /proc/sys/kernel/unprivileged_bpf_disabled to 0
Needed to not have to carry
  https://android-review.googlesource.com/c/kernel/common/+/1886896
for 5.16-rc1+ kernels

We set this before the bpfloader even executes so it will always be
ready before anyone has a chance to use it.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I418a534d6550c5b57286e261e6988d2debdf237f
2021-11-11 01:53:39 +00:00
Tyler Wear
e8ac9034f9 Add Bpf Prog Type for CGROUP_SOCK_ADDR am: 25c028576d
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1870862

Change-Id: I18370168df9ff122e42c3cb18f8e05b6d609b40e
2021-10-27 03:47:27 +00:00
Tyler Wear
25c028576d Add Bpf Prog Type for CGROUP_SOCK_ADDR
When loading a BPF program check for CGROUP_SOCK_ADDR
program type.

Bug: 179733303
Change-Id: I0464052065ec6f77a639a12a8dd343b7bf6f6ef8
2021-10-26 16:54:35 -07:00
Stephane Lee
54ac637fcf Increase the log size for larger bpf programs am: eb61b739ae
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1867988

Change-Id: I75c3dceddbd35615445eff444d4c0bda60614cbb
2021-10-25 04:18:36 +00:00
Stephane Lee
eb61b739ae Increase the log size for larger bpf programs
Test: Build passes, bpf program loads without an out of space error
Bug: 203462310
Change-Id: I5f67021a530223467662f341cdfffc4816781078
2021-10-22 19:07:05 -07:00
Treehugger Robot
54ee2ca342 Merge "bpfloader: add schedact support" am: bf05d42ef4
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1853438

Change-Id: I3e8126c9340ec719d1b37c482031664d30b4d17e
2021-10-14 02:22:32 +00:00
Treehugger Robot
bf05d42ef4 Merge "bpfloader: add schedact support" 2021-10-14 02:06:12 +00:00
Patrick Rohr
b28bf2aa53 bpfloader: add schedact support
This also bumps the bpfloader version to 0.3 to signify support
for loading schedact (ie. tc scheduler action) programs.

Test: load netd.o
Change-Id: Ic3fdc80d3f6ea2b42a4f1d6829b1ff12dd4d52c0
2021-10-13 19:28:53 +00:00
Pirama Arumuga Nainar
ee9072f58e Cleanup unused dependency to libprocessgroup am: e8d6df1231
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1815076

Change-Id: I2250ddd495b6dc05b5161e0739f6f3fefc69f63d
2021-08-31 20:59:11 +00: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
Dmitri Plotnikov
e93ed7e867 Add support for testing of eBPF programs am: bb05a5c138 am: f0e77da7be
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1507724

Change-Id: Ib6e1c04a3ff1b9dd5d4cdc5b6877ce99399481fa
2021-07-16 03:00:15 +00:00
Dmitri Plotnikov
f0e77da7be Add support for testing of eBPF programs am: bb05a5c138
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1507724

Change-Id: I1d386f72940ce6e271970bc3d2e862a98bac0556
2021-07-16 02:41:52 +00:00
Dmitri Plotnikov
bb05a5c138 Add support for testing of eBPF programs
Bug: 171262763
Test: this is just a header file
Change-Id: Id25846f91d2da698717a9cc0d8d9091022dd7233
2021-07-15 17:06:15 -07:00
Maciej Żenczykowski
475ac08ee8 [automerger skipped] expose readSectionUint() for testing am: c1f8ca3060 -s ours
am skip reason: Merged-In I772c918d162440de6cc492b2faeafe03340fca11 with SHA-1 7ed94efeda is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/bpf/+/15212804

Change-Id: I6812cfa7767b4954ba5e7b35ddd87caf1fe3de72
2021-07-06 12:37:25 +00:00
Maciej Żenczykowski
fbe33e1b4c [automerger skipped] bpf - struct bpf_map_def - add min/max kernel version. am: 2a51516a63 -s ours
am skip reason: Merged-In I085cc723ff1c19d8acc8972a391f894e16dd1875 with SHA-1 36c53ba91e is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/bpf/+/15212803

Change-Id: I2f61b1be0d81117e7facde4a7b9ca50f161b9e66
2021-07-06 12:37:24 +00:00
Maciej Żenczykowski
c1f8ca3060 expose readSectionUint() for testing
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
2021-07-06 10:50:12 +00:00
Maciej Żenczykowski
2a51516a63 bpf - struct bpf_map_def - add min/max kernel version.
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
2021-07-06 10:49:52 +00:00
Maciej Żenczykowski
f71ce9b4c9 expose readSectionUint() for testing am: 7ed94efeda am: 0f24b26b6c
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1756850

Change-Id: Ibd6d7fb84b583ef5a9a15e7ccc28ae79173f3f76
2021-07-06 10:37:12 +00:00
Maciej Żenczykowski
6f2b6ca0ca bpf - struct bpf_map_def - add min/max kernel version. am: 36c53ba91e am: f1421cd47f
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1756575

Change-Id: I75a99d681d7e82cb46f4350e29bf4ce1992636d1
2021-07-06 10:37:11 +00:00