diff options
| author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-05-13 09:41:28 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-05-13 09:41:28 +0000 |
| commit | 8e21d78cc61d0e39b7968f001a59ebb3c7ab1d40 (patch) | |
| tree | 21b9dc910e9db4d8fc736dd37ac55b8665cefc95 /server/TetherController.cpp | |
| parent | 77a055372ea8cab07e3fa761be76989a5b2a81be (diff) | |
| parent | e3da2378d8b4278464155e8b69a2f6ebf7ee36de (diff) | |
Merge changes I9777d38d,I665c14d8
* changes:
ebpf tethering - add a map to store data limit, part 2
ebpf tethering - add a map to store data limit, part 1
Diffstat (limited to 'server/TetherController.cpp')
| -rw-r--r-- | server/TetherController.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/server/TetherController.cpp b/server/TetherController.cpp index 09eb1ecb..6f2ee099 100644 --- a/server/TetherController.cpp +++ b/server/TetherController.cpp @@ -221,6 +221,11 @@ void TetherController::maybeInitMaps() { mBpfStatsMap.reset(fd); mBpfStatsMap.clear(); } + fd = getTetherLimitMapFd(); + if (fd >= 0) { + mBpfLimitMap.reset(fd); + mBpfLimitMap.clear(); + } } const std::set<std::string>& TetherController::getIpfwdRequesterList() const { @@ -1129,7 +1134,7 @@ std::string l2ToString(const uint8_t* addr, size_t len) { } // namespace void TetherController::dumpBpf(DumpWriter& dw) { - if (!mBpfIngressMap.isValid() || !mBpfStatsMap.isValid()) { + if (!mBpfIngressMap.isValid() || !mBpfStatsMap.isValid() || !mBpfLimitMap.isValid()) { dw.println("BPF not supported"); return; } @@ -1170,6 +1175,21 @@ void TetherController::dumpBpf(DumpWriter& dw) { dw.println("Error printing BPF stats map: %s", ret.error().message().c_str()); } dw.decIndent(); + + dw.println("BPF limit: iif -> bytes"); + const auto printLimitMap = [&dw](const uint32_t& key, const uint64_t& value, + const BpfMap<uint32_t, uint64_t>&) { + dw.println("%u -> %" PRIu64, key, value); + + return Result<void>(); + }; + + dw.incIndent(); + ret = mBpfLimitMap.iterateWithValue(printLimitMap); + if (!ret.ok()) { + dw.println("Error printing BPF limit map: %s", ret.error().message().c_str()); + } + dw.decIndent(); } void TetherController::dump(DumpWriter& dw) { |
