summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2019-10-22 16:55:55 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2019-10-22 17:48:12 +0200
commit2e305da7f4744d5b5dc2c6a7f70216314710380c (patch)
treef3190cf344f8fc50cd7d8355749ad60823b0fbaf
parentf2d3f29c7343dd5641cd4c29d6d229b60e41dc66 (diff)
downloadNetworkManager-bg/reapply-activating-rh1763062.tar.gz
device: allow reapply when the device is activatingbg/reapply-activating-rh1763062
Allow a reapply of the connection when the device is still activating and ensure that each reapply action is performed only at a given activation stage. For example, the IP configuration is not reactivated if the device is in the prepare stage. https://bugzilla.redhat.com/show_bug.cgi?id=1763062
-rw-r--r--src/devices/nm-device-ethernet.c7
-rw-r--r--src/devices/nm-device-wireguard.c28
-rw-r--r--src/devices/nm-device.c39
-rw-r--r--src/devices/wifi/nm-device-wifi.c4
4 files changed, 48 insertions, 30 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 8b78fa5327..a9e57afb66 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -1696,6 +1696,7 @@ static void
reapply_connection (NMDevice *device, NMConnection *con_old, NMConnection *con_new)
{
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device);
+ NMDeviceState state = nm_device_get_state (device);
NM_DEVICE_CLASS (nm_device_ethernet_parent_class)->reapply_connection (device,
con_old,
@@ -1703,8 +1704,10 @@ reapply_connection (NMDevice *device, NMConnection *con_old, NMConnection *con_n
_LOGD (LOGD_DEVICE, "reapplying wired settings");
- link_negotiation_set (device);
- wake_on_lan_enable (device);
+ if (state >= NM_DEVICE_STATE_PREPARE)
+ link_negotiation_set (device);
+ if (state >= NM_DEVICE_STATE_CONFIG)
+ wake_on_lan_enable (device);
}
static void
diff --git a/src/devices/nm-device-wireguard.c b/src/devices/nm-device-wireguard.c
index d65607089b..c916fa4658 100644
--- a/src/devices/nm-device-wireguard.c
+++ b/src/devices/nm-device-wireguard.c
@@ -1787,23 +1787,27 @@ reapply_connection (NMDevice *device,
NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE (self);
gs_unref_object NMIPConfig *ip4_config = NULL;
gs_unref_object NMIPConfig *ip6_config = NULL;
-
- priv->auto_default_route_refresh = TRUE;
-
- ip4_config = _get_dev2_ip_config (self, AF_INET);
- ip6_config = _get_dev2_ip_config (self, AF_INET6);
-
- nm_device_set_dev2_ip_config (device, AF_INET, ip4_config);
- nm_device_set_dev2_ip_config (device, AF_INET6, ip6_config);
+ NMDeviceState state = nm_device_get_state (device);
NM_DEVICE_CLASS (nm_device_wireguard_parent_class)->reapply_connection (device,
con_old,
con_new);
- link_config (NM_DEVICE_WIREGUARD (device),
- "reapply",
- LINK_CONFIG_MODE_REAPPLY,
- NULL);
+ if (state >= NM_DEVICE_STATE_CONFIG) {
+ priv->auto_default_route_refresh = TRUE;
+ link_config (NM_DEVICE_WIREGUARD (device),
+ "reapply",
+ LINK_CONFIG_MODE_REAPPLY,
+ NULL);
+ }
+
+ if (state >= NM_DEVICE_STATE_IP_CONFIG) {
+ ip4_config = _get_dev2_ip_config (self, AF_INET);
+ ip6_config = _get_dev2_ip_config (self, AF_INET6);
+
+ nm_device_set_dev2_ip_config (device, AF_INET, ip4_config);
+ nm_device_set_dev2_ip_config (device, AF_INET6, ip6_config);
+ }
}
/*****************************************************************************/
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index a632ce3b29..298f86f372 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -11561,7 +11561,8 @@ check_and_reapply_connection (NMDevice *self,
NMSettingIPConfig *s_ip6_old, *s_ip6_new;
GHashTableIter iter;
- if (priv->state != NM_DEVICE_STATE_ACTIVATED) {
+ if ( priv->state < NM_DEVICE_STATE_PREPARE
+ || priv->state > NM_DEVICE_STATE_ACTIVATED) {
g_set_error_literal (error,
NM_DEVICE_ERROR,
NM_DEVICE_ERROR_NOT_ACTIVE,
@@ -11674,24 +11675,31 @@ check_and_reapply_connection (NMDevice *self,
*************************************************************************/
klass->reapply_connection (self, con_old, con_new);
- nm_device_update_firewall_zone (self);
- nm_device_update_metered (self);
- lldp_init (self, FALSE);
+ if (priv->state >= NM_DEVICE_STATE_CONFIG)
+ lldp_init (self, FALSE);
- s_ip4_old = nm_connection_get_setting_ip4_config (con_old);
- s_ip4_new = nm_connection_get_setting_ip4_config (con_new);
- s_ip6_old = nm_connection_get_setting_ip6_config (con_old);
- s_ip6_new = nm_connection_get_setting_ip6_config (con_new);
+ if (priv->state >= NM_DEVICE_STATE_IP_CONFIG) {
+ s_ip4_old = nm_connection_get_setting_ip4_config (con_old);
+ s_ip4_new = nm_connection_get_setting_ip4_config (con_new);
+ s_ip6_old = nm_connection_get_setting_ip6_config (con_old);
+ s_ip6_new = nm_connection_get_setting_ip6_config (con_new);
- /* Allow reapply of MTU */
- priv->mtu_source = NM_DEVICE_MTU_SOURCE_NONE;
+ /* Allow reapply of MTU */
+ priv->mtu_source = NM_DEVICE_MTU_SOURCE_NONE;
- nm_device_reactivate_ip4_config (self, s_ip4_old, s_ip4_new);
- nm_device_reactivate_ip6_config (self, s_ip6_old, s_ip6_new);
+ nm_device_reactivate_ip4_config (self, s_ip4_old, s_ip4_new);
+ nm_device_reactivate_ip6_config (self, s_ip6_old, s_ip6_new);
- _routing_rules_sync (self, NM_TERNARY_TRUE);
+ _routing_rules_sync (self, NM_TERNARY_TRUE);
+
+ reactivate_proxy_config (self);
+ }
- reactivate_proxy_config (self);
+ if (priv->state >= NM_DEVICE_STATE_IP_CHECK)
+ nm_device_update_firewall_zone (self);
+
+ if (priv->state >= NM_DEVICE_STATE_ACTIVATED)
+ nm_device_update_metered (self);
return TRUE;
}
@@ -11788,7 +11796,8 @@ impl_device_reapply (NMDBusObject *obj,
return;
}
- if (priv->state != NM_DEVICE_STATE_ACTIVATED) {
+ if ( priv->state < NM_DEVICE_STATE_PREPARE
+ || priv->state > NM_DEVICE_STATE_ACTIVATED) {
error = g_error_new_literal (NM_DEVICE_ERROR,
NM_DEVICE_ERROR_NOT_ACTIVE,
"Device is not activated");
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 1d49ea4344..65ba2bcc0f 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -3209,6 +3209,7 @@ static void
reapply_connection (NMDevice *device, NMConnection *con_old, NMConnection *con_new)
{
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
+ NMDeviceState state = nm_device_get_state (device);
NM_DEVICE_CLASS (nm_device_wifi_parent_class)->reapply_connection (device,
con_old,
@@ -3216,7 +3217,8 @@ reapply_connection (NMDevice *device, NMConnection *con_old, NMConnection *con_n
_LOGD (LOGD_DEVICE, "reapplying wireless settings");
- if (!wake_on_wlan_enable (self))
+ if ( state >= NM_DEVICE_STATE_CONFIG
+ && !wake_on_wlan_enable (self))
_LOGW (LOGD_DEVICE | LOGD_WIFI, "Cannot configure WoWLAN.");
}