bpf: Add interface index to BPF devmap
Add upstream and downstream interface index to BPF map and rename the
BPF map name from xdp_devmap to dev.
$ adb shell dumpsys tethering
Device map:
ifindex (iface) -> ifindex (iface)
21 (21) -> 21 (21)
25 (25) -> 25 (25)
12 (rmnet_data2) -> 12 (rmnet_data2)
$ adb shell ip addr
12: rmnet_data2 ..
21: wlan1 ..
25: rndis0 ..
$ adb shell ls /sys/fs/bpf/tethering
map_offload_tether_dev_map
Test: atest TetheringCoverageTests
Change-Id: Ic49965f3374d9e196ee672ec2f0e9e08f3847deb
diff --git a/Tethering/bpf_progs/offload.c b/Tethering/bpf_progs/offload.c
index 36f6783..6ff370c 100644
--- a/Tethering/bpf_progs/offload.c
+++ b/Tethering/bpf_progs/offload.c
@@ -767,8 +767,7 @@
// ----- XDP Support -----
-DEFINE_BPF_MAP_GRW(tether_xdp_devmap, DEVMAP_HASH, uint32_t, uint32_t, 64,
- AID_NETWORK_STACK)
+DEFINE_BPF_MAP_GRW(tether_dev_map, DEVMAP_HASH, uint32_t, uint32_t, 64, AID_NETWORK_STACK)
static inline __always_inline int do_xdp_forward6(struct xdp_md *ctx, const bool is_ethernet,
const bool downstream) {