add an ebpf offload tethering statistics map
Test: build, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1c3b2f2d61bd139f14548e7731bb14f897e450e4
diff --git a/bpf_progs/offload.c b/bpf_progs/offload.c
index 95765ff..7cec065 100644
--- a/bpf_progs/offload.c
+++ b/bpf_progs/offload.c
@@ -22,6 +22,9 @@
DEFINE_BPF_MAP(tether_ingress_map, HASH, TetherIngressKey, TetherIngressValue, 64)
+// Tethering stats, indexed by upstream interface.
+DEFINE_BPF_MAP(tether_stats_map, HASH, uint32_t, TetherStatsValue, 16)
+
SEC("schedcls/ingress/tether_ether")
int sched_cls_ingress_tether_ether(struct __sk_buff* skb) {
// TODO
diff --git a/libnetdbpf/include/netdbpf/bpf_shared.h b/libnetdbpf/include/netdbpf/bpf_shared.h
index a5e7a27..695362d 100644
--- a/libnetdbpf/include/netdbpf/bpf_shared.h
+++ b/libnetdbpf/include/netdbpf/bpf_shared.h
@@ -207,4 +207,15 @@
struct ethhdr macHeader; // includes dst/src mac and ethertype
} TetherIngressValue;
+#define TETHER_STATS_MAP_PATH BPF_PATH "/map_offload_tether_stats_map"
+
+typedef struct {
+ uint64_t rxPackets;
+ uint64_t rxBytes;
+ uint64_t rxErrors;
+ uint64_t txPackets;
+ uint64_t txBytes;
+ uint64_t txErrors;
+} TetherStatsValue;
+
#endif // NETDBPF_BPF_SHARED_H
diff --git a/server/TrafficController.cpp b/server/TrafficController.cpp
index d676ac5..d91407f 100644
--- a/server/TrafficController.cpp
+++ b/server/TrafficController.cpp
@@ -236,6 +236,8 @@
RETURN_IF_NOT_OK(changeOwnerAndMode(TETHER_INGRESS_MAP_PATH, AID_NETWORK_STACK,
"TetherIngressMap", S_IRGRP | S_IWGRP));
+ RETURN_IF_NOT_OK(changeOwnerAndMode(TETHER_STATS_MAP_PATH, AID_NETWORK_STACK, "TetherStatsMap",
+ S_IRGRP | S_IWGRP));
// The programs must be readable to process that modify iptables rules
RETURN_IF_NOT_OK(changeOwnerAndMode(XT_BPF_EGRESS_PROG_PATH, AID_NET_ADMIN,