ClatdController - store ifindex in tracker
Test: atest netd_unit_test
Bug: 65674744
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I300dc05649d5046d45065dcc971397a0ff5dec65
diff --git a/server/ClatdController.cpp b/server/ClatdController.cpp
index aeaefef..b5988c8 100644
--- a/server/ClatdController.cpp
+++ b/server/ClatdController.cpp
@@ -21,6 +21,7 @@
#include <arpa/inet.h>
#include <errno.h>
+#include <net/if.h>
#include <netinet/in.h>
#include <spawn.h>
#include <sys/types.h>
@@ -186,6 +187,7 @@
snprintf(fwmarkString, sizeof(fwmarkString), "0x%x", fwmark.intValue);
snprintf(netIdString, sizeof(netIdString), "%u", netId);
+ ifIndex = if_nametoindex(interface.c_str());
strlcpy(iface, interface.c_str(), sizeof(iface));
// Pass in everything that clatd needs: interface, a netid to use for DNS lookups, a fwmark for
diff --git a/server/ClatdController.h b/server/ClatdController.h
index 9f25d67..d2eafd9 100644
--- a/server/ClatdController.h
+++ b/server/ClatdController.h
@@ -47,6 +47,7 @@
struct ClatdTracker {
const NetworkController* netCtrl = nullptr;
pid_t pid = -1;
+ unsigned ifIndex;
char iface[IFNAMSIZ];
Fwmark fwmark;
char fwmarkString[UINT32_STRLEN];