From 0245565e056b7a919d92033eada4c090ebc436e9 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Wed, 26 Jun 2019 12:00:21 +0300 Subject: interfaces: ignore non-running interfaces Check for IFF_UP and IFF_RUNNING flags on the interface. --- agent/interfaces.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/agent/interfaces.c b/agent/interfaces.c index f8bb086..3bfae3e 100644 --- a/agent/interfaces.c +++ b/agent/interfaces.c @@ -266,6 +266,10 @@ nice_interfaces_get_local_ips (gboolean include_loopback) if ((ifa->ifa_flags & IFF_UP) == 0) continue; + /* no ip address from interface that isn't running */ + if ((ifa->ifa_flags & IFF_RUNNING) == 0) + continue; + if (ifa->ifa_addr == NULL) continue; @@ -360,6 +364,15 @@ nice_interfaces_get_local_ips (gboolean include_loopback) " Skipping...", ifr->ifr_name); continue; /* failed to get flags, skip it */ } + + /* no ip address from interface that is down */ + if ((ifr->ifr_flags & IFF_UP) == 0) + continue; + + /* no ip address from interface that isn't running */ + if ((ifr->ifr_flags & IFF_RUNNING) == 0) + continue; + sa = (struct sockaddr_in *) &ifr->ifr_addr; nice_debug ("Interface: %s", ifr->ifr_name); nice_debug ("IP Address: %s", inet_ntoa (sa->sin_addr)); -- cgit v1.2.1