]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
netlink: ignore IFLA_LINK if we previously received IFLA_LINK_NETNSID
authorVincent Bernat <vincent@bernat.ch>
Mon, 23 Sep 2019 19:35:14 +0000 (21:35 +0200)
committerVincent Bernat <vincent@bernat.ch>
Mon, 23 Sep 2019 19:42:21 +0000 (21:42 +0200)
Starting from 5.2 (commit feadc4b6cf42), IFLA_LINK appear after
IFLA_LINK_NETNSID. Handle this case correctly.

src/daemon/netlink.c

index c89e14902768fd3d7bb8d22811eff4ccfbdd840a..c21368779b09b281e90b970ed15b0a5a13442ed9 100644 (file)
@@ -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",