as this does not appear to be used anywhere anymore
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6905c6fdb4daf48df07e758481368d441637ad13
as this does not appear to be used anywhere anymore
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I95939b0b6c66f41f776ca31ea7178bb30241b81f
See 5.12+ kernel's include/uapi/linux/bpf.h
(note that since bpf is 64-bit, int and long are the same thing)
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib340a619645ad5ab8e41ff76cb7b51671f496bc5
Non platform ones (ie. shipped via mainline) already have
the value manually specified.
The goal here is to be able to do some bpf.o validity checking
in the bpfloader based on the bpfloader_min_ver.
Such validity checking really only makes sense for mainline
shipped bpf.o's which might need to load on older bpfloaders.
Hence we no longer want platform bpf.o's to have minver == 0.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9e2f670c48e30818689a42bc515eb49e86f3cbea
Sometimes you just want to change the setting for all maps and/or
programs in a specific .c file...
Bug: 190523685
Bug: 236925089
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3ba6b3a8dadf18c1436b21feb1ee03db446e6aba
BpfLoader v0.25+ support loading obj@ver.o files
as if they were obj.o. This allows different
versions of the .o per bpfloader version.
This is useful because BTF enabled bpf.o files
are incompatible with BpfLoader < 0.10.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2067b1c54c36842c0baa779f37a904b75b9dfb6d
Per request on:
https://googleplex-android-review.googlesource.com/c/platform/frameworks/libs/net/+/18992756
While we're at it let's temporarily remove the check in .reset(fd)
if (bpfGetFdMapFlags(mMapFd) != 0) abort(); // TODO: fix for BpfMapRO
We'll add it back when the code is in better shape,
and read-only vs read-write state of the map is something
we actually *know*.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id8d65bdc529872685b42656e638f22048fafb7f6
(split in two to facilitate manual testing)
Bug: 218408035
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifc00ed168231615819b88b232155e1fe6f9a8c71
Tested by making the map struct conditional on #define V18,
and only #defining that in the top line of netd.c,
this results in:
$ objdump -s -j size_of_bpf_map_def out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/net_shared/clatd.o
out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/net_shared/clatd.o: file format elf64-little
Contents of section size_of_bpf_map_def:
0000 30000000 00000000 0.......
$ objdump -s -j size_of_bpf_prog_def out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/net_shared/clatd.o
out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/net_shared/clatd.o: file format elf64-little
Contents of section size_of_bpf_prog_def:
0000 1c000000 00000000 ........
$ objdump -s -j size_of_bpf_map_def out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/netd_shared/netd.o
out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/netd_shared/netd.o: file format elf64-little
Contents of section size_of_bpf_map_def:
0000 74000000 00000000 t.......
$ objdump -s -j size_of_bpf_prog_def out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/netd_shared/netd.o
out/target/product/vsoc_x86_64/apex/com.android.tethering/etc/bpf/netd_shared/netd.o: file format elf64-little
Contents of section size_of_bpf_prog_def:
0000 5c000000 00000000 \.......
$ echo $[0x00000030] $[0x00000074]
48 116
$ echo $[0x0000001c] $[0x0000005c]
28 92
and it still successfully boots.
So the struct extension infrastructure works as desired.
Bug: 218408035
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8b55769e69dbf9580e844f2a50d48651fd9a0cff
while we're at it:
- replace 'unique_fd != -1' with unique_fd.ok() which is
a test for fd.get() >= 0 and is thus effectively equivalent
- make use of the fact that unique_fd.reset()
takes care to save errno.
(see impl. in //system/libbase/include/android-base/unique_fd.h )
Bug: 236285127
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6fb7bf28a2265ad84baa3c552b39c620cb3875fe
Really we need to fix the inheritance to make
BpfMapRO the parent class of BpfMap:
but that's a far more difficult thing to do,
so in the short term we punt like this.
This makes BpfMapRO a little bit more usable,
and allows a slow transition across the codebase...
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1c5112db70e9e523c113cba536fbe19422b4d3f3
this way is more obviously not calling dup_with_cloexec
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4e1ce3b0a42ccea638332ae451e291e025d57895
to replace less safe uses of BpfMap.reset(create(type, keysize, valuesize, entries, flags))
Meant to be used in tests only.
Bug:
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I869f1f935bcf5d00702c42bc46d6094ea552addc
not perfect due to this being in a header file, so multiple copies
potentially exist, but it's really simple, and works nearly as well.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id90c6933d57bc12f4dd640c8918fd0885c7474cf
BPF_ANNOTATE_KV_PAIR is used by libbpf to associate each map with its
BTF information. This is ignored for programs compiled without BTF
information.
Bug: 203823368
Test: build & boot; confirm all bpf progs load successfully
Test: compile time_in_state.o with -g; confirm BTF is loaded
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: I45f294945d48106d39d1d105ac4f49311459a19d
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: Ie6f257b022cdea6bab3389a9fa41791f893e54c3