From db2cff5cdf4fc1149754a344c11f8dae0a9d0b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Mon, 1 Mar 2021 21:22:49 -0800 Subject: [PATCH] bpf offload - add a new 'tether_xdp_devmap' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It will map device ifindex to itself (but note that internally in the kernel this is optimized into a map from ifindex to direct device pointer), but only for xdp transmit capable devices (other devices will not have an entry). This will allow the use of bpf_redirect_map() from xdp tethering programs. Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: I29684e6761727d1115e9b4d75486eccbca3d5e33 --- Tethering/bpf_progs/offload.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tethering/bpf_progs/offload.c b/Tethering/bpf_progs/offload.c index ea643431a6..bfa1e3a192 100644 --- a/Tethering/bpf_progs/offload.c +++ b/Tethering/bpf_progs/offload.c @@ -723,6 +723,9 @@ DEFINE_BPF_PROG_KVER_RANGE("schedcls/tether_upstream4_rawip$stub", AID_ROOT, AID // ----- XDP Support ----- +DEFINE_BPF_MAP_GRW(tether_xdp_devmap, DEVMAP_HASH, uint32_t, uint32_t, 64, + AID_NETWORK_STACK) + #define DEFINE_XDP_PROG(str, func) \ DEFINE_BPF_PROG_KVER(str, AID_ROOT, AID_NETWORK_STACK, func, KVER(5, 9, 0))(struct xdp_md *ctx)