]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
netlink: ensure lower link doesn't change for an interface
authorVincent Bernat <vincent@bernat.im>
Sun, 13 Mar 2016 11:26:44 +0000 (12:26 +0100)
committerVincent Bernat <vincent@bernat.im>
Sun, 13 Mar 2016 11:26:44 +0000 (12:26 +0100)
The lower link of an interface is defined at its creation. It's not
possible for it to change. This is important to not try to change it
because the kernel won't send IFLA_LINK_NETNSID each time it sends
IFLA_LINK.

src/daemon/netlink.c

index e643ccb2a12fe13aa1c0b468a31a8af8652582eb..60e0ec5df8bac00dce2a098a023289026208ff99 100644 (file)
@@ -229,10 +229,14 @@ netlink_parse_link(struct nlmsghdr *msg,
                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);
                        break;
                case IFLA_LINK_NETNSID:
                        /* Is the lower interface into another namesapce? */
                        iff->lower_idx = -1;
+                       log_debug("netlink", "attribute IFLA_LINK_NETNSID received for %s",
+                           iff->name ? iff->name : "(unknown)");
                        break;
                case IFLA_MASTER:
                        /* Index of master interface */
@@ -349,6 +353,9 @@ netlink_merge(struct interfaces_device *old, struct interfaces_device *new)
                new->type = old->type;
        if (new->vlanid == 0)
                new->vlanid = old->vlanid;
+
+       /* It's not possible for lower link to change */
+       new->lower_idx = old->lower_idx;
 }
 
 /**