Ignore the interfaces defined in IGNORED_INTERFACES
In getInterfaces(), ignore the interfaces if it is in the environment
IGNORED_INTERFACES.
Tested: Verify the interfaces are ignored by phosphor-networkd if it's
defined in the environment configs.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I159e4e8613c7795d371beef0b1c1131586a5126d
diff --git a/util.cpp b/util.cpp
index ee76cc3..6cc42d1 100644
--- a/util.cpp
+++ b/util.cpp
@@ -391,12 +391,14 @@
AddrPtr ifaddrPtr(ifaddr);
ifaddr = nullptr;
+ const auto& ignoredInterfaces = internal::getIgnoredInterfaces();
for (ifaddrs* ifa = ifaddrPtr.get(); ifa != nullptr; ifa = ifa->ifa_next)
{
// walk interfaces
// if loopback ignore
- if (ifa->ifa_flags & IFF_LOOPBACK)
+ if (ifa->ifa_flags & IFF_LOOPBACK ||
+ ignoredInterfaces.find(ifa->ifa_name) != ignoredInterfaces.end())
{
continue;
}