platform: merge branch 'th/platform-refresh-link-bgo754996'

https://bugzilla.gnome.org/show_bug.cgi?id=754996

(cherry picked from commit 54afd0400b)
This commit is contained in:
Thomas Haller 2015-09-18 11:27:40 +02:00
commit e8f5005d3d

View file

@ -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);
@ -1657,6 +1657,33 @@ delayed_action_handle_idle (gpointer user_data)
return G_SOURCE_REMOVE;
}
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)
{
@ -1873,6 +1900,37 @@ cache_pre_hook (NMPCache *cache, const NMPObject *old, const NMPObject *new, NMP
NULL);
}
}
{
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
@ -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: