bpf_progs/offload.c - reduce memory usage by shrinking maps
Now that stats are cleared as soon as we turn off tethering
we no longer need to have 1000 entries in the per-interface
stats and limit maps. In practice we'll usually have zero
(tethering inactive) or one (the active upstream tethering interface).
Test: atest
Bug: 150736748
Original-Change: https://android-review.googlesource.com/1328675
Merged-In: I22447efac365baef8aa212a5c4732fed5c4ff98e
Change-Id: I22447efac365baef8aa212a5c4732fed5c4ff98e
diff --git a/bpf_progs/offload.c b/bpf_progs/offload.c
index f3334b4..d13b4b9 100644
--- a/bpf_progs/offload.c
+++ b/bpf_progs/offload.c
@@ -28,13 +28,11 @@
AID_NETWORK_STACK)
// Tethering stats, indexed by upstream interface.
-DEFINE_BPF_MAP_GRW(tether_stats_map, HASH, uint32_t, TetherStatsValue, IFACE_STATS_MAP_SIZE,
- AID_NETWORK_STACK)
+DEFINE_BPF_MAP_GRW(tether_stats_map, HASH, uint32_t, 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, IFACE_STATS_MAP_SIZE,
- AID_NETWORK_STACK)
+DEFINE_BPF_MAP_GRW(tether_limit_map, HASH, uint32_t, uint64_t, 16, AID_NETWORK_STACK)
static inline __always_inline int do_forward(struct __sk_buff* skb, bool is_ethernet) {
int l2_header_size = is_ethernet ? sizeof(struct ethhdr) : 0;