No longer get app uid bandwidth stats for the clat daemon

Test: atest
Bug: 150738490
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibe2de1b04e5ff342d87aa47236c635b47f7ea11b
Merged-In: Ibe2de1b04e5ff342d87aa47236c635b47f7ea11b
diff --git a/server/BandwidthController.cpp b/server/BandwidthController.cpp
index d746027..e1ce56f 100644
--- a/server/BandwidthController.cpp
+++ b/server/BandwidthController.cpp
@@ -229,8 +229,12 @@
             "-A bw_OUTPUT -j bw_global_alert",
             // Prevents IPSec double counting (Tunnel mode and Transport mode,
             // respectively)
-            ("-A bw_OUTPUT -o " IPSEC_IFACE_PREFIX "+ -j RETURN"),
-            "-A bw_OUTPUT -m policy --pol ipsec --dir out -j RETURN",
+            useBpf ? "" : "-A bw_OUTPUT -o " IPSEC_IFACE_PREFIX "+ -j RETURN",
+            useBpf ? "" : "-A bw_OUTPUT -m policy --pol ipsec --dir out -j RETURN",
+            // Don't count clat traffic, as it has already been counted (and subject to
+            // costly / happy_box / data_saver / penalty_box etc. based on the real UID)
+            // on the stacked interface.
+            useBpf ? "" : "-A bw_OUTPUT -m owner --uid-owner clat -j RETURN",
             // This is egress application UID xt_qtaguid (pre-ebpf) accounting,
             // for bpf this is handled out of cgroup hooks instead.
             useBpf ? "" : "-A bw_OUTPUT -m owner --socket-exists",