From 0e367d40f4fafb49a85892b226c2475bc6e22184 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 2 Aug 2018 17:25:57 +0200 Subject: [PATCH 1/3] platform: fix typo progess -> progress --- src/platform/nm-linux-platform.c | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index a8a649c7b4..70559c576a 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -3405,7 +3405,7 @@ typedef struct { WaitForNlResponseResult *out_seq_result; char **out_errmsg; union { - int *out_refresh_all_in_progess; + int *out_refresh_all_in_progress; NMPObject **out_route_get; gpointer out_data; } response; @@ -3437,7 +3437,7 @@ typedef struct { /* counter that a refresh all action is in progress, separated * by type. */ - int refresh_all_in_progess[_DELAYED_ACTION_IDX_REFRESH_ALL_NUM]; + int refresh_all_in_progress[_DELAYED_ACTION_IDX_REFRESH_ALL_NUM]; GPtrArray *list_master_connected; GPtrArray *list_refresh_link; @@ -3910,7 +3910,7 @@ delayed_action_refresh_all_in_progress (NMPlatform *platform, DelayedActionType if (NM_FLAGS_ANY (priv->delayed_action.flags, action_type)) return TRUE; - if (priv->delayed_action.refresh_all_in_progess[delayed_action_refresh_all_to_idx (action_type)] > 0) + if (priv->delayed_action.refresh_all_in_progress[delayed_action_refresh_all_to_idx (action_type)] > 0) return TRUE; return FALSE; @@ -3940,10 +3940,10 @@ delayed_action_wait_for_nl_response_complete (NMPlatform *platform, case DELAYED_ACTION_RESPONSE_TYPE_VOID: break; case DELAYED_ACTION_RESPONSE_TYPE_REFRESH_ALL_IN_PROGRESS: - if (data->response.out_refresh_all_in_progess) { - nm_assert (*data->response.out_refresh_all_in_progess > 0); - *data->response.out_refresh_all_in_progess -= 1; - data->response.out_refresh_all_in_progess = NULL; + if (data->response.out_refresh_all_in_progress) { + nm_assert (*data->response.out_refresh_all_in_progress > 0); + *data->response.out_refresh_all_in_progress -= 1; + data->response.out_refresh_all_in_progress = NULL; } break; case DELAYED_ACTION_RESPONSE_TYPE_ROUTE_GET: @@ -4666,11 +4666,11 @@ do_request_all_no_delayed_actions (NMPlatform *platform, DelayedActionType actio const NMPClass *klass = nmp_class_from_type (obj_type); nm_auto_nlmsg struct nl_msg *nlmsg = NULL; int nle; - int *out_refresh_all_in_progess; + int *out_refresh_all_in_progress; - out_refresh_all_in_progess = &priv->delayed_action.refresh_all_in_progess[delayed_action_refresh_all_to_idx (iflags)]; - nm_assert (*out_refresh_all_in_progess >= 0); - *out_refresh_all_in_progess += 1; + out_refresh_all_in_progress = &priv->delayed_action.refresh_all_in_progress[delayed_action_refresh_all_to_idx (iflags)]; + nm_assert (*out_refresh_all_in_progress >= 0); + *out_refresh_all_in_progress += 1; /* clear any delayed action that request a refresh of this object type. */ priv->delayed_action.flags &= ~iflags; @@ -4704,9 +4704,9 @@ do_request_all_no_delayed_actions (NMPlatform *platform, DelayedActionType actio if (nle < 0) continue; - if (_nl_send_nlmsg (platform, nlmsg, NULL, NULL, DELAYED_ACTION_RESPONSE_TYPE_REFRESH_ALL_IN_PROGRESS, out_refresh_all_in_progess) < 0) { - nm_assert (*out_refresh_all_in_progess > 0); - *out_refresh_all_in_progess -= 1; + if (_nl_send_nlmsg (platform, nlmsg, NULL, NULL, DELAYED_ACTION_RESPONSE_TYPE_REFRESH_ALL_IN_PROGRESS, out_refresh_all_in_progress) < 0) { + nm_assert (*out_refresh_all_in_progress > 0); + *out_refresh_all_in_progress -= 1; } } } @@ -4735,10 +4735,10 @@ event_seq_check_refresh_all (NMPlatform *platform, guint32 seq_number) data = &g_array_index (priv->delayed_action.list_wait_for_nl_response, DelayedActionWaitForNlResponseData, i); if ( data->response_type == DELAYED_ACTION_RESPONSE_TYPE_REFRESH_ALL_IN_PROGRESS - && data->response.out_refresh_all_in_progess + && data->response.out_refresh_all_in_progress && data->seq_number == priv->nlh_seq_last_seen) { - *data->response.out_refresh_all_in_progess -= 1; - data->response.out_refresh_all_in_progess = NULL; + *data->response.out_refresh_all_in_progress -= 1; + data->response.out_refresh_all_in_progress = NULL; break; } } From 9ed07fbb46c7dfbd4db8f1a908d4a522dc4917b4 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 3 Aug 2018 10:54:17 +0200 Subject: [PATCH 2/3] device: clear queued IP config sources when the device is unrealized If the device is later realized again, we assert that there aren't any IP config changes queued. Therefore, they must be cleared on unrealize(). --- src/devices/nm-device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 55a81e4f34..c09a80da54 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -4407,6 +4407,9 @@ nm_device_unrealize (NMDevice *self, gboolean remove_resources, GError **error) } } + nm_clear_g_source (&priv->queued_ip_config_id_4); + nm_clear_g_source (&priv->queued_ip_config_id_6); + g_object_freeze_notify (G_OBJECT (self)); NM_DEVICE_GET_CLASS (self)->unrealize_notify (self); From 281974b93216a33941b9527d823c9e20d9087bc4 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 2 Aug 2018 17:45:09 +0200 Subject: [PATCH 3/3] manager: don't update ifindex of existing devices When NM has to rebuild the platform cache, it first generates ADD and then REMOVE events for the links. So, if an interface is removed and readded, platform will emit the ADDED event with a new ifindex while the device with old ifindex still exists. In such case the manager currently updates the device's ifindex but this causes problems as the DNS manager tracks configurations by their ifindex and so the configurations for the old device will become stale. Fix this by removing the device and adding it again when we detect a change of ifindex on a device that already had valid one. https://bugzilla.redhat.com/show_bug.cgi?id=1542366 --- src/nm-manager.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 8ca87551c9..44be55164a 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -3083,10 +3083,21 @@ platform_link_added (NMManager *self, continue; if (nm_device_is_real (candidate)) { - /* Ignore the link added event since there's already a realized - * device with the link's name. + /* There's already a realized device with the link's name + * and a different ifindex. */ - nm_device_update_from_platform_link (candidate, plink); + if (nm_device_get_ifindex (candidate) <= 0) + nm_device_update_from_platform_link (candidate, plink); + else { + /* The ifindex of a device can't be changed after + * initialization because it is used as a key by + * the dns-manager. + */ + _LOGD (LOGD_DEVICE, "(%s): removing old device %p after ifindex change from %d to %d", + plink->name, candidate, nm_device_get_ifindex (candidate), ifindex); + remove_device (self, candidate, FALSE, TRUE); + goto add; + } return; } else if (nm_device_realize_start (candidate, plink, @@ -3106,6 +3117,7 @@ platform_link_added (NMManager *self, /* Try next unrealized device */ } +add: /* Try registered device factories */ factory = nm_device_factory_manager_find_factory_for_link_type (plink->type); if (factory) {