From: Vincent Bernat Date: Wed, 20 Sep 2017 22:25:01 +0000 (+0200) Subject: netlink: be more precise in how we handle link deletion of bridged interface X-Git-Tag: 0.9.9~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b9ecd2af832982552978c71291c1dfcac2e9158;p=thirdparty%2Flldpd.git netlink: be more precise in how we handle link deletion of bridged interface If link family is AF_BRIDGE, transform deletion into update of interface. Otherwise, skip the update. --- diff --git a/src/daemon/netlink.c b/src/daemon/netlink.c index e14ac9b9..36696139 100644 --- a/src/daemon/netlink.c +++ b/src/daemon/netlink.c @@ -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) {