]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
netlink: be more precise in how we handle link deletion of bridged interface
authorVincent Bernat <vincent@bernat.im>
Wed, 20 Sep 2017 22:25:01 +0000 (00:25 +0200)
committerVincent Bernat <vincent@bernat.im>
Wed, 20 Sep 2017 22:26:47 +0000 (00:26 +0200)
If link family is AF_BRIDGE, transform deletion into update of
interface. Otherwise, skip the update.

src/daemon/netlink.c

index e14ac9b981eaaa8b56311dc4ab1892d09256c4c2..36696139c23c1eb1e1418277362edc2ca9d7d2bb 100644 (file)
@@ -322,6 +322,17 @@ netlink_parse_link(struct nlmsghdr *msg,
                iff->flags &= ~IFF_SLAVE;
        }
 
+       if (ifi->ifi_family == AF_BRIDGE && msg->nlmsg_type == RTM_DELLINK && iff->upper_idx != -1) {
+               log_debug("netlink", "removal of %s from bridge %d",
+                   iff->name, iff->upper_idx);
+               msg->nlmsg_type = RTM_NEWLINK;
+               iff->upper_idx = -1;
+       } else if (ifi->ifi_family != 0) {
+               log_debug("netlink", "skip non-generic message update %d at index %d",
+                   ifi->ifi_type, ifi->ifi_index);
+               return -1;
+       }
+
        log_debug("netlink", "parsed link %d (%s, flags: %d)",
            iff->index, iff->name, iff->flags);
        return 0;
@@ -550,14 +561,6 @@ retry:
                                        TAILQ_FOREACH(ifdold, ifs, next) {
                                                if (ifdold->index == ifdnew->index) break;
                                        }
-                                       if (msg->nlmsg_type == RTM_DELLINK && ifdnew->upper_idx != -1) {
-                                               /* This happens for bridges */
-                                               log_debug("netlink",
-                                                   "removal request for %s, but has a master, convert it",
-                                                   ifdnew->name);
-                                               ifdnew->upper_idx = -1;
-                                               msg->nlmsg_type = RTM_NEWLINK;
-                                       }
 
                                        if (msg->nlmsg_type == RTM_NEWLINK) {
                                                if (ifdold == NULL) {