diff options
author | Thomas Haller <thaller@redhat.com> | 2015-09-14 15:05:00 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-09-14 16:41:01 +0200 |
commit | 61a05376ad886380be8e4211289341f7d13288f5 (patch) | |
tree | 1c2e6222926406259e58bf209d87e528367a1fdf | |
parent | 838bd00ddad77acba2811a1b8c3a165aa32e294a (diff) | |
download | NetworkManager-61a05376ad886380be8e4211289341f7d13288f5.tar.gz |
platform: refresh links when parent gets removed
When moving a link to another netns, it gets removed from
NMPlatform's view. Ensure that we reload all linked interfaces
which now might have an invisible parent.
-rw-r--r-- | src/platform/nm-linux-platform.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index c70e4be64c..a7e0bbd938 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1869,6 +1869,36 @@ cache_pre_hook (NMPCache *cache, const NMPObject *old, const NMPObject *new, NMP } } { + int ifindex = -1; + + /* removal of a link could be caused by moving the link to another netns. + * In this case, we potentially have to update other links that have this link as parent. */ + + if ( ops_type == NMP_CACHE_OPS_REMOVED + && old /* <-- nonsensical, make coverity happy */ + && old->_link.netlink.is_in_netlink) + ifindex = old->link.ifindex; + else if ( ops_type == NMP_CACHE_OPS_UPDATED + && old && new /* <-- nonsensical, make coverity happy */ + && !new->_link.netlink.is_in_netlink + && new->_link.netlink.is_in_netlink != old->_link.netlink.is_in_netlink) + ifindex = new->link.ifindex; + + if (ifindex > 0) { + const NMPlatformLink *const *links; + + links = cache_lookup_all_objects (NMPlatformLink, platform, NMP_OBJECT_TYPE_LINK, FALSE); + if (links) { + for (; *links; links++) { + const NMPlatformLink *l = (*links); + + if (l->parent == ifindex) + delayed_action_schedule (platform, DELAYED_ACTION_TYPE_REFRESH_LINK, GINT_TO_POINTER (l->ifindex)); + } + } + } + } + { /* if a link goes down, we must refresh routes */ if ( ops_type == NMP_CACHE_OPS_UPDATED && old && new /* <-- nonsensical, make coverity happy */ |