From 2b9ecd2af832982552978c71291c1dfcac2e9158 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 21 Sep 2017 00:25:01 +0200 Subject: [PATCH] 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. --- src/daemon/netlink.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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) { -- 2.39.5