diff options
| author | Chenbo Feng <fengc@google.com> | 2018-03-19 11:51:54 -0700 |
|---|---|---|
| committer | Chenbo Feng <fengc@google.com> | 2018-03-19 16:48:44 -0700 |
| commit | a121e20ec1f3bd3ce05fb90da1eaba3bef5ed568 (patch) | |
| tree | dc9419346d8a0871d84266f9cc05aefa55f86b79 /server/BandwidthController.cpp | |
| parent | fd4ece7c67a6ab4149d4676b7694de71aca56b90 (diff) | |
Fixing the BandwidthController unit test
The BandwidthController unit test cannot directly use gCtrl->trafficCtrl
to check if the bpf stats feature is avaliable. Rewrite the
getBpfStatsStatus() function of BandwidthController so it is also
functioning when in BandwidthController unit tests.
Bug: 72111305
Test: ./netd_unit_test
Change-Id: Ie60ed384b7f8d42b8e1f3417949d46895bea6572
Diffstat (limited to 'server/BandwidthController.cpp')
| -rw-r--r-- | server/BandwidthController.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/server/BandwidthController.cpp b/server/BandwidthController.cpp index e79a595c..ffedaf67 100644 --- a/server/BandwidthController.cpp +++ b/server/BandwidthController.cpp @@ -207,10 +207,7 @@ static const uint32_t uidBillingMask = Fwmark::getUidBillingMask(); */ const std::vector<std::string> getBasicAccountingCommands() { - bool useBpf = android::net::gCtls->trafficCtrl.checkBpfStatsEnable(); - //TODO: remove this when xt_bpf kernel support is ready - useBpf = false; - + bool useBpf = BandwidthController::getBpfStatsStatus(); const std::vector<std::string> ipt_basic_accounting_commands = { "*filter", // Prevents IPSec double counting (ESP and UDP-encap-ESP respectively) @@ -269,6 +266,14 @@ std::vector<std::string> toStrVec(int num, char* strs[]) { } // namespace +bool BandwidthController::getBpfStatsStatus() { + bool useBpf = (access(XT_BPF_INGRESS_PROG_PATH, F_OK) != -1) && + (access(XT_BPF_EGRESS_PROG_PATH, F_OK) != -1); + // TODO: remove this when xt_bpf kernel support is ready + useBpf = false; + return useBpf; +} + BandwidthController::BandwidthController() { } |
