Rework bpf part of traffic controller
Refine the implementaion of Traffic Controller eBPF module. Fixed
several typos and code style. Use unique_fd to replace all the fd
involved. Move the bpf helper function to a seperate library so
system server can also use it from jni code. Change the map file
permission so system_server can also read it. Rework the delete tag
data helper function to make it work properly. Pin the bpf program as
file so netd can check if cgroup program is attached or not when
restart.
Test: -m CtsNetTestCases -t android.net.cts.TrafficStatsTest
Bug: 30950746
Change-Id: I50fd6a091faab261880afa8e27ebb316871eb4aa
diff --git a/server/Controllers.cpp b/server/Controllers.cpp
index 8b02f60..b0b1925 100644
--- a/server/Controllers.cpp
+++ b/server/Controllers.cpp
@@ -265,16 +265,17 @@
void Controllers::init() {
initIptablesRules();
- int ret = trafficCtrl.start();
- if (ret) {
- ALOGE("failed to start trafficcontroller: (%s)", strerror(-ret));
- }
Stopwatch s;
+ netdutils::Status tcStatus = trafficCtrl.start();
+ if (!isOk(tcStatus)) {
+ ALOGE("failed to start trafficcontroller: (%s)", toString(tcStatus).c_str());
+ }
+ ALOGI("initializing traffic control: %.1fms", s.getTimeAndReset());
+
bandwidthCtrl.enableBandwidthControl(false);
ALOGI("Disabling bandwidth control: %.1fms", s.getTimeAndReset());
- ret = RouteController::Init(NetworkController::LOCAL_NET_ID);
- if (ret) {
+ if (int ret = RouteController::Init(NetworkController::LOCAL_NET_ID)) {
ALOGE("failed to initialize RouteController (%s)", strerror(-ret));
}
ALOGI("Initializing RouteController: %.1fms", s.getTimeAndReset());