bpfloader: add support for connect4 / connect6 progs

These should be useful for producing onConnectEvent events from mainline
bpf code.

BPF_PROG_TYPE_CGROUP_SOCK_ADDR requires the attach type to be explicitly
specified at load time.

Test: builds
Bug: 270905383
Bug: 259000745
Change-Id: Ida57c6eb632b8bb406ee4cadf0a30e47d9c422ff
This commit is contained in:
Patrick Rohr 2023-03-28 15:36:11 -07:00 committed by Maciej Żenczykowski
parent 84bd7711b7
commit aa624f299b

View file

@ -30,13 +30,13 @@
#include <sys/wait.h>
#include <unistd.h>
// This is BpfLoader v0.34
// This is BpfLoader v0.35
// WARNING: If you ever hit cherrypick conflicts here you're doing it wrong:
// You are NOT allowed to cherrypick bpfloader related patches out of order.
// (indeed: cherrypicking is probably a bad idea and you should merge instead)
// Mainline supports ONLY the published versions of the bpfloader for each Android release.
#define BPFLOADER_VERSION_MAJOR 0u
#define BPFLOADER_VERSION_MINOR 34u
#define BPFLOADER_VERSION_MINOR 35u
#define BPFLOADER_VERSION ((BPFLOADER_VERSION_MAJOR << 16) | BPFLOADER_VERSION_MINOR)
#include "BpfSyscallWrappers.h"
@ -189,6 +189,8 @@ sectionType sectionNameTypes[] = {
{"bind6/", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, BPF_CGROUP_INET6_BIND},
{"cgroupskb/", BPF_PROG_TYPE_CGROUP_SKB, BPF_ATTACH_TYPE_UNSPEC},
{"cgroupsock/", BPF_PROG_TYPE_CGROUP_SOCK, BPF_ATTACH_TYPE_UNSPEC},
{"connect4/", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, BPF_CGROUP_INET4_CONNECT},
{"connect6/", BPF_PROG_TYPE_CGROUP_SOCK_ADDR, BPF_CGROUP_INET6_CONNECT},
{"kprobe/", BPF_PROG_TYPE_KPROBE, BPF_ATTACH_TYPE_UNSPEC},
{"perf_event/", BPF_PROG_TYPE_PERF_EVENT, BPF_ATTACH_TYPE_UNSPEC},
{"schedact/", BPF_PROG_TYPE_SCHED_ACT, BPF_ATTACH_TYPE_UNSPEC},