From 40c967577d2b4df63e39da01b2a7d236bd29da7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Tue, 21 Jan 2025 16:23:52 -0800 Subject: [PATCH] bpf netd: introduce DEFINE_NETD_BPF_PROG_RANGES() macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (for simplification, more uses in coming commits) Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: Ie660ab98d2326d9eec6b5032c449ea5bf715a9b0 --- bpf/progs/netd.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/bpf/progs/netd.c b/bpf/progs/netd.c index 6f4c527a22..5510a20ac3 100644 --- a/bpf/progs/netd.c +++ b/bpf/progs/netd.c @@ -116,11 +116,14 @@ DEFINE_BPF_MAP_RO_NETD(data_saver_enabled_map, ARRAY, uint32_t, bool, // programs that need to be usable by netd, but not by netutils_wrappers // (this is because these are currently attached by the mainline provided libnetd_updatable .so // which is loaded into netd and thus runs as netd uid/gid/selinux context) -#define DEFINE_NETD_BPF_PROG_KVER_RANGE(SECTION_NAME, the_prog, minKV, maxKV) \ +#define DEFINE_NETD_BPF_PROG_RANGES(SECTION_NAME, the_prog, minKV, maxKV, min_loader, max_loader) \ DEFINE_BPF_PROG_EXT(SECTION_NAME, AID_ROOT, AID_ROOT, the_prog, \ - minKV, maxKV, BPFLOADER_MIN_VER, BPFLOADER_MAX_VER, MANDATORY, \ + minKV, maxKV, min_loader, max_loader, MANDATORY, \ "fs_bpf_netd_readonly", "", LOAD_ON_ENG, LOAD_ON_USER, LOAD_ON_USERDEBUG) +#define DEFINE_NETD_BPF_PROG_KVER_RANGE(SECTION_NAME, the_prog, minKV, maxKV) \ + DEFINE_NETD_BPF_PROG_RANGES(SECTION_NAME, the_prog, minKV, maxKV, BPFLOADER_MIN_VER, BPFLOADER_MAX_VER) + #define DEFINE_NETD_BPF_PROG_KVER(SECTION_NAME, the_prog, min_kv) \ DEFINE_NETD_BPF_PROG_KVER_RANGE(SECTION_NAME, the_prog, min_kv, KVER_INF) @@ -515,11 +518,9 @@ static __always_inline inline int bpf_traffic_account(struct __sk_buff* skb, } // Tracing on Android U+ 5.10+ -DEFINE_BPF_PROG_EXT("cgroupskb/ingress/stats$trace", AID_ROOT, AID_ROOT, - bpf_cgroup_ingress_trace, KVER_5_10, KVER_INF, - BPFLOADER_MAINLINE_U_VERSION, BPFLOADER_MAX_VER, MANDATORY, - "fs_bpf_netd_readonly", "", - LOAD_ON_ENG, LOAD_ON_USER, LOAD_ON_USERDEBUG) +DEFINE_NETD_BPF_PROG_RANGES("cgroupskb/ingress/stats$trace", + bpf_cgroup_ingress_trace, KVER_5_10, KVER_INF, + BPFLOADER_MAINLINE_U_VERSION, BPFLOADER_MAX_VER) (struct __sk_buff* skb) { return bpf_traffic_account(skb, INGRESS, TRACE_ON, KVER_5_10, SDK_LEVEL_U); } @@ -537,11 +538,9 @@ DEFINE_NETD_BPF_PROG_KVER_RANGE("cgroupskb/ingress/stats$4_14", } // Tracing on Android U+ 5.10+ -DEFINE_BPF_PROG_EXT("cgroupskb/egress/stats$trace", AID_ROOT, AID_ROOT, - bpf_cgroup_egress_trace, KVER_5_10, KVER_INF, - BPFLOADER_MAINLINE_U_VERSION, BPFLOADER_MAX_VER, MANDATORY, - "fs_bpf_netd_readonly", "", - LOAD_ON_ENG, LOAD_ON_USER, LOAD_ON_USERDEBUG) +DEFINE_NETD_BPF_PROG_RANGES("cgroupskb/egress/stats$trace", + bpf_cgroup_egress_trace, KVER_5_10, KVER_INF, + BPFLOADER_MAINLINE_U_VERSION, BPFLOADER_MAX_VER) (struct __sk_buff* skb) { return bpf_traffic_account(skb, EGRESS, TRACE_ON, KVER_5_10, SDK_LEVEL_U); }