ClatdController - dump(In|E)gress - use BpfMap fields instead of creating new ones
Test: build, atest, 'dumpsys netd' on test device
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9f54958502a3c76daca6adf65feb19bbdff638dc
diff --git a/server/ClatdController.cpp b/server/ClatdController.cpp
index 1bf9d38..0b62fb4 100644
--- a/server/ClatdController.cpp
+++ b/server/ClatdController.cpp
@@ -694,9 +694,7 @@
}
void ClatdController::dumpEgress(DumpWriter& dw) {
- int mapFd = getClatEgressMapFd();
- if (mapFd < 0) return; // if unsupported just don't dump anything
- BpfMap<ClatEgressKey, ClatEgressValue> configMap(mapFd);
+ if (!mClatEgressMap.isValid()) return; // if unsupported just don't dump anything
ScopedIndent bpfIndent(dw);
dw.println("BPF egress map: iif(iface) v4Addr -> v6Addr nat64Prefix oif(iface)");
@@ -720,16 +718,14 @@
pfx96Str, value.oif, oifStr, value.oifIsEthernet ? "ether" : "rawip");
return Result<void>();
};
- auto res = configMap.iterateWithValue(printClatMap);
+ auto res = mClatEgressMap.iterateWithValue(printClatMap);
if (!res) {
dw.println("Error printing BPF map: %s", res.error().message().c_str());
}
}
void ClatdController::dumpIngress(DumpWriter& dw) {
- int mapFd = getClatIngressMapFd();
- if (mapFd < 0) return; // if unsupported just don't dump anything
- BpfMap<ClatIngressKey, ClatIngressValue> configMap(mapFd);
+ if (!mClatIngressMap.isValid()) return; // if unsupported just don't dump anything
ScopedIndent bpfIndent(dw);
dw.println("BPF ingress map: iif(iface) nat64Prefix v6Addr -> v4Addr oif(iface)");
@@ -753,7 +749,7 @@
value.oif, oifStr);
return Result<void>();
};
- auto res = configMap.iterateWithValue(printClatMap);
+ auto res = mClatIngressMap.iterateWithValue(printClatMap);
if (!res) {
dw.println("Error printing BPF map: %s", res.error().message().c_str());
}