]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
interfaces-bsd: do not consider an interface when it is down
authorVincent Bernat <vincent@bernat.ch>
Sun, 29 Aug 2021 19:57:07 +0000 (21:57 +0200)
committerVincent Bernat <vincent@bernat.ch>
Mon, 30 Aug 2021 05:26:20 +0000 (07:26 +0200)
At least on OpenBSD, an interface can be oper down while
`IFF_RUNNING`. Check the link state and removes the `IFF_RUNNING` flag
in this case. Something similar may work with FreeBSD and NetBSD, but
it may not be needed. It does not work with MacOS.

Fix #474

src/daemon/interfaces-bsd.c

index f21bad1a6f4ecb0dd38d7c5f957915b662755c2e..c8baefbb5c5063590c3e6442b1ea58456d422181 100644 (file)
@@ -433,6 +433,15 @@ ifbsd_extract(struct lldpd *cfg,
                    "grabbing information on interface %s",
                    ifaddr->ifa_name);
                device = ifbsd_extract_device(cfg, ifaddr);
+#if defined HOST_OS_OPENBSD
+               /* On OpenBSD, the interface can have IFF_RUNNING but be down. */
+               {
+                       struct if_data *ifdata;
+                       ifdata = ifaddr->ifa_data;
+                       if (!LINK_STATE_IS_UP(ifdata->ifi_link_state))
+                               device->flags &= ~IFF_RUNNING;
+               }
+#endif
                if (device)
                        TAILQ_INSERT_TAIL(interfaces, device, next);
                break;