ebpf tethering - add a map to store data limit, part 2
This is higher level glue code, including dump support.
Tested: builds
Bug: 150736748
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9777d38d319a0b9db265aa339b7e903c49b8a4df
Merged-In: I9777d38d319a0b9db265aa339b7e903c49b8a4df
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 09eb1ec..6f2ee09 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -221,6 +221,11 @@
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 @@
} // 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 @@
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) {