add getClatEgressMapFd() with tests
Test: atest
Bug: 139396664
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic7d952ba32228107b35f97d8b89f9667270718be
diff --git a/server/ClatUtils.cpp b/server/ClatUtils.cpp
index ed7287a..c75fcdd 100644
--- a/server/ClatUtils.cpp
+++ b/server/ClatUtils.cpp
@@ -62,6 +62,11 @@
return ifr.ifr_hwaddr.sa_family;
}
+int getClatEgressMapFd(void) {
+ const int fd = bpf::bpfFdGet(CLAT_EGRESS_MAP_PATH, 0);
+ return (fd == -1) ? -errno : fd;
+}
+
int getClatIngressMapFd(void) {
const int fd = bpf::bpfFdGet(CLAT_INGRESS_MAP_PATH, 0);
return (fd == -1) ? -errno : fd;