Commit Graph

10 Commits

Author SHA1 Message Date
Maciej Żenczykowski
901c71051e bpf_progs: use macros for kernel version
Generated via:
  for f in bpf_progs/{block,dscpPolicy,netd,offload,test}.c; do
    sed -i -r 's@KVER[(]([45]), ([0-9]+), 0[)]@KVER_\1_\2@g' "${f}"
  done

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8f211e47bf259fc75aa1caaaf82f41c1929ceab2
2023-10-06 15:54:39 -07:00
Maciej Żenczykowski
de1342a033 bpf_progs: disable BTF on <=U && user builds
This is to cut down bpfloader boot time.
Potential savings might be on the order of 30+% (300ms).

Loading BTF requires fork-execing the btfloader,
and currently BTF is only used to facilitate debugging.

Bug: 286369326
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifa5f0052135b9dc826b18ca4622784615ed9c3c8
2023-06-09 05:58:57 +00:00
Maciej Żenczykowski
7a03c187f5 remove inprocess tethering
It is just a constant source of bugs, with no real tests,
let's stop pretending this is a supported configuration.

The only tested configuration is out-of-process tethering
updatable apex.

Test: TreeHugger
Bug: 279942846
Change-Id: I4b659a3cd32b89a65549b56006b926a5ac755f7b
2023-04-28 20:11:14 +00:00
Maciej Żenczykowski
4e3321ed3b bpf_tethering.h -> offload.h
match header file with bpf program

Locations to change found via:
  https://source.corp.google.com/search?q=p:aosp-master%20(%5E%7C%5B%5E_%5D)bpf_tethering.h

Core reasoning for this will be to match the .h naming
that we'll have for netd.c and clatd.c once we get rid of bpf_shared.h

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4154659c7fb23a37f5316a5c804fb2606d842e9c
2022-12-08 13:04:45 +00:00
Maciej Żenczykowski
c8e40c149f flag test.o bpf program as being test only
Bug: 254543135
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8ee7b0a552510baabb7c29d94521291b8b526692
2022-10-21 00:02:35 +00:00
Maciej Żenczykowski
ccce4a3382 offload/test bpf: support InProcessTethering
InProcessTethering runs as system_server (uid/gid AID_SYSTEM)
instead of as the network_stack (uid/gid AID_NETWORK_STACK).

Additionally only the network_stack has access to the default
selinux context of /sys/fs/bpf/tethering, which is fs_bpf_tethering,
so we need to use 'fs_bpf_net_shared' instead.

Bug: 190523685
Bug: 236925089
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibb6ae255dcd8a8e8049be112055f60c3b2cf7df0
2022-07-18 09:05:32 -07:00
Maciej Żenczykowski
07d3013b0d enable btf for offload.o & test.o
The objdump -x visible changes between old and new versions of the
mainline shipped .o files are really very minimal: just the inclusion
of a new .BTF section and changes/removals of some 'l' entries from
the symbol table.  However, it turns out a change to symbol ordering
is incompatible with BpfLoader <v0.10 which doesn't know to skip
non-function symbols, and as such enabling btf requires a little
bit of gymnastics.

After:
  $ adbz shell ls -l /apex/com.android.tethering/etc/bpf/*.o
  -rw-r--r-- 1 system system 118352 1969-12-31 16:00 /apex/com.android.tethering/etc/bpf/offload.o
  -rw-r--r-- 1 system system 123424 1969-12-31 16:00 /apex/com.android.tethering/etc/bpf/offload@btf.o
  -rw-r--r-- 1 system system   2232 1969-12-31 16:00 /apex/com.android.tethering/etc/bpf/test.o
  -rw-r--r-- 1 system system   6376 1969-12-31 16:00 /apex/com.android.tethering/etc/bpf/test@btf.o

$ adbz shell logcat -d | egrep offload.*[.]o
07-15 13:10:43.358     0     0 D LibBpfLoader: Loading critical for tethering ELF object /apex/com.android.tethering/etc/bpf/offload.o with license Apache 2.0
07-15 13:10:43.359     0     0 I LibBpfLoader: BpfLoader version 0x00019 ignoring ELF object /apex/com.android.tethering/etc/bpf/offload.o with max ver 0x00019
07-15 13:10:43.359     0     0 I bpfloader: Loaded object: /apex/com.android.tethering/etc/bpf/offload.o
07-15 13:10:43.374     0     0 D LibBpfLoader: Loading critical for tethering ELF object /apex/com.android.tethering/etc/bpf/offload@btf.o with license Apache 2.0
07-15 13:10:43.375     0     0 I LibBpfLoader: BpfLoader version 0x00019 processing ELF object /apex/com.android.tethering/etc/bpf/offload@btf.o with ver [0x00019,0x10000)
07-15 13:10:43.452     0     0 D LibBpfLoader: map_fd found at 0 is 6 in /apex/com.android.tethering/etc/bpf/offload@btf.o
...

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id658818d1d42763358747523615b7918d312588e
2022-07-16 05:35:15 +00:00
Maciej Żenczykowski
f769952212 bpf programs: switch from integers to #define'd bpfloader versions
(per request from Lorenzo)

We do bump block/clatd/dscp_policy requirements from 0.12 to 0.13,
but this effectively doesn't matter:

- Beta2 is too old either way (pre-0.12)
- Beta3 is new enough (0.13)
- versions in between are simply obsolete / unused / not important
- bpfloader 0.12 won't boot right anyway due to lack of netd maps/programs
  (which cause a netd startup failure)

This allows us to have one less #define in the header files,
with a hard to write explanation about what exactly v0.12 is (or was).

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1ecf15f9d7abbb82ec6bd49848255fab6a41aed4
2022-05-24 16:11:09 -07:00
Tyler Wear
c23ffbdf7e BpfBitmap Test
Privileged test case for BpfBitmap.

Test: atest BpfBitmapTest
Bug: 179733303
Change-Id: I9c32d8843176815a725eccfd1f0400ec129cd94d
2022-02-15 22:19:58 +00:00
Ken Chen
bb57fa9eec [NETD-BPF#3] Relocate Tethering/bpf_progs and rename bpf_tethering_headers
The folder is currently used by tether offload only. Because we will
move netd.c and clatd.c to it, the folder should be moved to the upper
tier.

Also, rename bpf_tethering_headers to bpf_connectivity_headers so that
other connectivity code besides to tethering are justified to use it.

Bug: 202086915
Test: atest FrameworksNetTests
Change-Id: I95943c6e909f1fdca12604ef0c55d67c39ca686b
2021-11-20 18:31:08 +08:00