From: Vincent Bernat Date: Mon, 23 Sep 2019 19:35:14 +0000 (+0200) Subject: netlink: ignore IFLA_LINK if we previously received IFLA_LINK_NETNSID X-Git-Tag: 1.0.5~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5a85fbc934334c629a0d4cce5a8983e442f5a0df;p=thirdparty%2Flldpd.git netlink: ignore IFLA_LINK if we previously received IFLA_LINK_NETNSID Starting from 5.2 (commit feadc4b6cf42), IFLA_LINK appear after IFLA_LINK_NETNSID. Handle this case correctly. --- diff --git a/src/daemon/netlink.c b/src/daemon/netlink.c index c89e1490..c2136877 100644 --- a/src/daemon/netlink.c +++ b/src/daemon/netlink.c @@ -283,13 +283,18 @@ netlink_parse_link(struct nlmsghdr *msg, break; case IFLA_LINK: /* Index of "lower" interface */ - iff->lower_idx = *(int*)RTA_DATA(attribute); - log_debug("netlink", "attribute IFLA_LINK for %s: %d", - iff->name ? iff->name : "(unknown)", iff->lower_idx); + if (iff->lower_idx == -1) { + iff->lower_idx = *(int*)RTA_DATA(attribute); + log_debug("netlink", "attribute IFLA_LINK for %s: %d", + iff->name ? iff->name : "(unknown)", iff->lower_idx); + } else { + log_debug("netlink", "attribute IFLA_LINK for %s: %d (ignored)", + iff->name ? iff->name : "(unknown)", iff->lower_idx); + } break; case IFLA_LINK_NETNSID: /* Is the lower interface into another namesapce? */ - iff->lower_idx = -1; + iff->lower_idx = -2; log_debug("netlink", "attribute IFLA_LINK_NETNSID received for %s", iff->name ? iff->name : "(unknown)"); break; @@ -321,6 +326,8 @@ netlink_parse_link(struct nlmsghdr *msg, * and we don't want to miss it. */ iff->flags &= ~IFF_SLAVE; } + if (iff->lower_idx == -2) + iff->lower_idx = -1; if (ifi->ifi_family == AF_BRIDGE && msg->nlmsg_type == RTM_DELLINK && iff->upper_idx != -1) { log_debug("netlink", "removal of %s from bridge %d", @@ -688,8 +695,11 @@ end: if (iface2->lower_idx == iface1->index) { iface1->lower = NULL; log_debug("netlink", - "link loop detected between %s and %s", - iface1->name, iface2->name); + "link loop detected between %s(%d) and %s(%d)", + iface1->name, + iface1->index, + iface2->name, + iface2->index); } else { log_debug("netlink", "lower interface for %s is %s",