Use xt_bpf module to record the iface stats

To make interface packet accounting more accurately and persistent, the
xt_bpf module is implemented to record the total packets and bytes
tx/rx through each interface. The netd will load the bpf program and
set up iptable rules for the xt_bpf module at boot time and the
framework service will use them to get per interface networks stats on
supported devices. Add logcat support to bpfloader program.

Test: iface stats show up in maps. Iptable rules show up after boot.
Bug: 72111305

Change-Id: Ib33d2b165b64e130999931302dd67891c35a12e9
diff --git a/server/TrafficController.h b/server/TrafficController.h
index 7fdc3b7..0991288 100644
--- a/server/TrafficController.h
+++ b/server/TrafficController.h
@@ -38,7 +38,8 @@
 constexpr const int UID_COUNTERSET_MAP_SIZE = 10000;
 constexpr const int UID_STATS_MAP_SIZE = 10000;
 constexpr const int TAG_STATS_MAP_SIZE = 10000;
-constexpr const int IFACE_INDEX_NAME_MAP_SIZE = 10000;
+constexpr const int IFACE_INDEX_NAME_MAP_SIZE = 1000;
+constexpr const int IFACE_STATS_MAP_SIZE = 1000;
 constexpr const int UID_OWNER_MAP_SIZE = 10000;
 
 constexpr const int COUNTERSETS_LIMIT = 2;
@@ -145,6 +146,12 @@
      */
     base::unique_fd mIfaceIndexNameMap;
 
+    /*
+     * mIfaceStataMap: Store per iface traffic stats gathered from xt_bpf
+     * filter.
+     */
+    base::unique_fd mIfaceStatsMap;
+
     std::unique_ptr<NetlinkListenerInterface> mSkDestroyListener;
 
     bool ebpfSupported;