diff options
author | Thomas Haller <thaller@redhat.com> | 2015-09-18 11:27:40 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-09-18 11:31:37 +0200 |
commit | e8f5005d3dfe363a48569cafd262c59708e7ed21 (patch) | |
tree | 9ceb86611e519ffbe4b5b49d88996a04923e665a | |
parent | 3543cbdfc28cf5f0ab611c0345a115881be59d66 (diff) | |
parent | 91c00072f2fd23e90a840a7c466c3ed95217eb68 (diff) | |
download | NetworkManager-e8f5005d3dfe363a48569cafd262c59708e7ed21.tar.gz |
platform: merge branch 'th/platform-refresh-link-bgo754996'
https://bugzilla.gnome.org/show_bug.cgi?id=754996
(cherry picked from commit 54afd0400bf940b87c973418fd3a7ef605f1c458)
-rw-r--r-- | src/platform/nm-linux-platform.c | 76 |
1 files changed, 69 insertions, 7 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index eee740355c..b9ccaeb3e5 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1622,7 +1622,7 @@ delayed_action_handle_one (NMPlatform *platform) user_data = priv->delayed_action.list_refresh_link->pdata[0]; g_ptr_array_remove_index_fast (priv->delayed_action.list_refresh_link, 0); - if (priv->delayed_action.list_master_connected->len == 0) + if (priv->delayed_action.list_refresh_link->len == 0) priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_REFRESH_LINK; nm_assert (_nm_utils_ptrarray_find_first (priv->delayed_action.list_refresh_link->pdata, priv->delayed_action.list_refresh_link->len, user_data) < 0); @@ -1658,6 +1658,33 @@ delayed_action_handle_idle (gpointer user_data) } static void +delayed_action_clear_REFRESH_LINK (NMPlatform *platform, int ifindex) +{ + NMLinuxPlatformPrivate *priv; + gssize idx; + gpointer user_data; + + if (ifindex <= 0) + return; + + priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); + if (!NM_FLAGS_HAS (priv->delayed_action.flags, DELAYED_ACTION_TYPE_REFRESH_LINK)) + return; + + user_data = GINT_TO_POINTER (ifindex); + + idx = _nm_utils_ptrarray_find_first (priv->delayed_action.list_refresh_link->pdata, priv->delayed_action.list_refresh_link->len, user_data); + if (idx < 0) + return; + + _LOGT_delayed_action (DELAYED_ACTION_TYPE_REFRESH_LINK, user_data, "clear"); + + g_ptr_array_remove_index_fast (priv->delayed_action.list_refresh_link, idx); + if (priv->delayed_action.list_refresh_link->len == 0) + priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_REFRESH_LINK; +} + +static void delayed_action_schedule (NMPlatform *platform, DelayedActionType action_type, gpointer user_data) { NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform); @@ -1874,6 +1901,37 @@ 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. + * Currently, kernel misses to sent us a notification in this case (rh #1262908). */ + + 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 */ + && old->_link.netlink.is_in_netlink + && !new->_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 */ @@ -2043,9 +2101,11 @@ do_request_all (NMPlatform *platform, DelayedActionType action_type, gboolean ha /* clear any delayed action that request a refresh of this object type. */ priv->delayed_action.flags &= ~iflags; + _LOGT_delayed_action (iflags, NULL, "handle (do-request-all)"); if (obj_type == NMP_OBJECT_TYPE_LINK) { priv->delayed_action.flags &= ~DELAYED_ACTION_TYPE_REFRESH_LINK; g_ptr_array_set_size (priv->delayed_action.list_refresh_link, 0); + _LOGT_delayed_action (DELAYED_ACTION_TYPE_REFRESH_LINK, NULL, "clear (do-request-all)"); } event_handler_read_netlink_all (platform, FALSE); @@ -2356,12 +2416,14 @@ event_notification (struct nl_msg *msg, gpointer user_data) switch (msghdr->nlmsg_type) { case RTM_NEWLINK: - if ( NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK - && g_hash_table_lookup (priv->delayed_deletion, obj) != NULL) { - /* the object is scheduled for delayed deletion. Replace that object - * by clearing the value from priv->delayed_deletion. */ - _LOGT ("delayed-deletion: clear delayed deletion of protected object %s", nmp_object_to_string (obj, NMP_OBJECT_TO_STRING_ID, NULL, 0)); - g_hash_table_insert (priv->delayed_deletion, nmp_object_ref (obj), NULL); + if (NMP_OBJECT_GET_TYPE (obj) == NMP_OBJECT_TYPE_LINK) { + if (g_hash_table_lookup (priv->delayed_deletion, obj) != NULL) { + /* the object is scheduled for delayed deletion. Replace that object + * by clearing the value from priv->delayed_deletion. */ + _LOGT ("delayed-deletion: clear delayed deletion of protected object %s", nmp_object_to_string (obj, NMP_OBJECT_TO_STRING_ID, NULL, 0)); + g_hash_table_insert (priv->delayed_deletion, nmp_object_ref (obj), NULL); + } + delayed_action_clear_REFRESH_LINK (platform, obj->link.ifindex); } /* fall-through */ case RTM_NEWADDR: |