Fix cgroup bpf program direction
The bpfloader loaded the cgroup bpf program in wrong place and caused
the per uid/tag stats stored in the wrong place. This patch fixed the
program loading problem and also refactored the kernel program to make
all stats record function use the same implementation. Cleaned up the
bpf instruction set that is no longer used.
Test: the per uid stats sum up is consistent with per iface stats
Bug: 30950746
Change-Id: I92c0511855f224ef98c7d75a01c99c432796d3bf
diff --git a/bpfloader/xt_bpf_ingress_prog.c b/bpfloader/xt_bpf_ingress_prog.c
index dc823c3..5f10255 100644
--- a/bpfloader/xt_bpf_ingress_prog.c
+++ b/bpfloader/xt_bpf_ingress_prog.c
@@ -19,5 +19,7 @@
ELF_SEC(BPF_PROG_SEC_NAME)
int xt_bpf_ingress_prog(struct __sk_buff* skb) {
- return xt_bpf_count(skb, BPF_INGRESS);
+ uint32_t key = skb->ifindex;
+ bpf_update_stats(skb, IFACE_STATS_MAP, BPF_INGRESS, &key);
+ return BPF_PASS;
}