TetherController - clear both ebpf tether offload maps on startup
This clears out any stale state from a potential previous run.
(also fix a bug... get...MapFd() return -errno on error)
Test: build, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4a452280a3754ef05964630809efb8cca2bbb833
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 16f272c..747174f 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -206,12 +206,14 @@
// Open BPF maps, ignoring errors because the device might not support BPF offload.
int fd = getTetherIngressMapFd();
- if (fd != -1) {
+ if (fd >= 0) {
mBpfIngressMap.reset(fd);
+ mBpfIngressMap.clear();
}
fd = getTetherStatsMapFd();
- if (fd != -1) {
+ if (fd >= 0) {
mBpfStatsMap.reset(fd);
+ mBpfStatsMap.clear();
}
}