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/BpfLoader.cpp b/bpfloader/BpfLoader.cpp
index 9d75077..26fb99d 100644
--- a/bpfloader/BpfLoader.cpp
+++ b/bpfloader/BpfLoader.cpp
@@ -199,9 +199,9 @@
}
unique_fd fd;
- if (type == BPF_CGROUP_INET_EGRESS) {
+ if (type == BPF_CGROUP_INET_INGRESS) {
fd.reset(loadProg(INGRESS_PROG, mapPatterns));
- } else if (type == BPF_CGROUP_INET_INGRESS) {
+ } else if (type == BPF_CGROUP_INET_EGRESS) {
fd.reset(loadProg(EGRESS_PROG, mapPatterns));
} else if (!strcmp(name, "xt_bpf_ingress_prog")) {
fd.reset(loadProg(XT_BPF_INGRESS_PROG, mapPatterns));