add placeholder ipv4 ebpf tethering offload programs
Additionally better document tether stats/limit keys/value.
Test: atest, TreeHugger, the programs load
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1e1832fc4f5a6704e00ea99ca377988c52a82eb1
diff --git a/Tethering/bpf_progs/offload.c b/Tethering/bpf_progs/offload.c
index 5fdaa49..9d2aec4 100644
--- a/Tethering/bpf_progs/offload.c
+++ b/Tethering/bpf_progs/offload.c
@@ -24,18 +24,23 @@
#include "bpf_net_helpers.h"
#include "netdbpf/bpf_shared.h"
-DEFINE_BPF_MAP_GRW(tether_downstream6_map, HASH, TetherDownstream6Key, TetherDownstream6Value, 64,
- AID_NETWORK_STACK)
-
-DEFINE_BPF_MAP_GRW(tether_upstream6_map, HASH, TetherUpstream6Key, TetherUpstream6Value, 64,
- AID_NETWORK_STACK)
-
// Tethering stats, indexed by upstream interface.
-DEFINE_BPF_MAP_GRW(tether_stats_map, HASH, uint32_t, TetherStatsValue, 16, AID_NETWORK_STACK)
+DEFINE_BPF_MAP_GRW(tether_stats_map, HASH, TetherStatsKey, TetherStatsValue, 16, AID_NETWORK_STACK)
// Tethering data limit, indexed by upstream interface.
// (tethering allowed when stats[iif].rxBytes + stats[iif].txBytes < limit[iif])
-DEFINE_BPF_MAP_GRW(tether_limit_map, HASH, uint32_t, uint64_t, 16, AID_NETWORK_STACK)
+DEFINE_BPF_MAP_GRW(tether_limit_map, HASH, TetherLimitKey, TetherLimitValue, 16, AID_NETWORK_STACK)
+
+// ----- IPv6 Support -----
+
+DEFINE_BPF_MAP_GRW(tether_downstream6_map, HASH, TetherDownstream6Key, TetherDownstream6Value, 64,
+ AID_NETWORK_STACK)
+
+DEFINE_BPF_MAP_GRW(tether_downstream64_map, HASH, TetherDownstream64Key, TetherDownstream64Value,
+ 64, AID_NETWORK_STACK)
+
+DEFINE_BPF_MAP_GRW(tether_upstream6_map, HASH, TetherUpstream6Key, TetherUpstream6Value, 64,
+ AID_NETWORK_STACK)
static inline __always_inline int do_forward(struct __sk_buff* skb, const bool is_ethernet,
const bool downstream) {
@@ -256,5 +261,37 @@
return TC_ACT_OK;
}
+// ----- IPv4 Support -----
+
+DEFINE_BPF_MAP_GRW(tether_downstream4_map, HASH, TetherDownstream4Key, TetherDownstream4Value, 64,
+ AID_NETWORK_STACK)
+
+DEFINE_BPF_MAP_GRW(tether_upstream4_map, HASH, TetherUpstream4Key, TetherUpstream4Value, 64,
+ AID_NETWORK_STACK)
+
+DEFINE_BPF_PROG("schedcls/tether_downstream4_ether", AID_ROOT, AID_NETWORK_STACK,
+ sched_cls_tether_downstream4_ether)
+(struct __sk_buff* skb) {
+ return TC_ACT_OK;
+}
+
+DEFINE_BPF_PROG("schedcls/tether_downstream4_rawip", AID_ROOT, AID_NETWORK_STACK,
+ sched_cls_tether_downstream4_rawip)
+(struct __sk_buff* skb) {
+ return TC_ACT_OK;
+}
+
+DEFINE_BPF_PROG("schedcls/tether_upstream4_ether", AID_ROOT, AID_NETWORK_STACK,
+ sched_cls_tether_upstream4_ether)
+(struct __sk_buff* skb) {
+ return TC_ACT_OK;
+}
+
+DEFINE_BPF_PROG("schedcls/tether_upstream4_rawip", AID_ROOT, AID_NETWORK_STACK,
+ sched_cls_tether_upstream4_rawip)
+(struct __sk_buff* skb) {
+ return TC_ACT_OK;
+}
+
LICENSE("Apache 2.0");
CRITICAL("netd");