summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-09-08 14:09:51 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2017-09-08 14:29:02 +0200
commit44e71d70ea58501f8b9948b902d9505a6392b01b (patch)
treecccdc7b30957a5df1824ca7d53795f48105d0ce3
parent4bc231e33abb4f5edb6fc1f42053a06e6e5fd5ec (diff)
downloadNetworkManager-44e71d70ea58501f8b9948b902d9505a6392b01b.tar.gz
ppp: rename the interface only when necessary
Previously when the interface created by pppd was already the one we expected, we would rename it to itself and remove the device from the manager. Don't do it. Fixes: 6c3195931e94cab70208ce97f3b834f5d9f5ff62
-rw-r--r--src/devices/nm-device-ppp.c13
-rw-r--r--src/devices/nm-device-private.h2
-rw-r--r--src/devices/nm-device.c28
3 files changed, 28 insertions, 15 deletions
diff --git a/src/devices/nm-device-ppp.c b/src/devices/nm-device-ppp.c
index 7c034f5f85..d786a62e22 100644
--- a/src/devices/nm-device-ppp.c
+++ b/src/devices/nm-device-ppp.c
@@ -105,17 +105,20 @@ ppp_ip4_config (NMPPPManager *ppp_manager,
NMDevice *device = NM_DEVICE (user_data);
NMDevicePpp *self = NM_DEVICE_PPP (device);
NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE (self);
+ gboolean renamed;
_LOGT (LOGD_DEVICE | LOGD_PPP, "received IPv4 config from pppd");
if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG) {
if (nm_device_activate_ip4_state_in_conf (device)) {
- if (!nm_device_take_over_link (device, iface)) {
+ if (!nm_device_take_over_link (device, iface, &renamed)) {
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
return;
}
- nm_manager_remove_device (nm_manager_get (), iface);
+ if (renamed)
+ nm_manager_remove_device (nm_manager_get (), iface);
+
nm_device_activate_schedule_ip4_config_result (device, config);
return;
}
@@ -178,11 +181,13 @@ act_stage3_ip4_config_start (NMDevice *device,
{
NMDevicePpp *self = NM_DEVICE_PPP (device);
NMDevicePppPrivate *priv = NM_DEVICE_PPP_GET_PRIVATE (self);
+ gboolean renamed;
if (priv->pending_ip4_config) {
- if (!nm_device_take_over_link (device, priv->pending_ifname))
+ if (!nm_device_take_over_link (device, priv->pending_ifname, &renamed))
return NM_ACT_STAGE_RETURN_FAILURE;
- nm_manager_remove_device (nm_manager_get (), priv->pending_ifname);
+ if (renamed)
+ nm_manager_remove_device (nm_manager_get (), priv->pending_ifname);
if (out_config)
*out_config = g_steal_pointer (&priv->pending_ip4_config);
else
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h
index a02cab3159..a884faa2bf 100644
--- a/src/devices/nm-device-private.h
+++ b/src/devices/nm-device-private.h
@@ -57,7 +57,7 @@ gboolean nm_device_bring_up (NMDevice *self, gboolean wait, gboolean *no_firmwar
void nm_device_take_down (NMDevice *self, gboolean block);
-gboolean nm_device_take_over_link (NMDevice *self, const char *ifname);
+gboolean nm_device_take_over_link (NMDevice *self, const char *ifname, gboolean *renamed);
gboolean nm_device_hw_addr_set (NMDevice *device,
const char *addr,
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index aadd2cd6cf..9cb29cf27f 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -1007,15 +1007,18 @@ nm_device_get_iface (NMDevice *self)
}
gboolean
-nm_device_take_over_link (NMDevice *self, const char *ifname)
+nm_device_take_over_link (NMDevice *self, const char *ifname, gboolean *renamed)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
const NMPlatformLink *plink;
NMPlatform *platform;
- gboolean up, success;
+ gboolean up, success = TRUE;
int ifindex;
g_return_val_if_fail (priv->ifindex <= 0, FALSE);
+ g_return_val_if_fail (ifname, FALSE);
+
+ NM_SET_OUT (renamed, FALSE);
platform = nm_device_get_platform (self);
plink = nm_platform_link_get_by_ifname (platform, ifname);
@@ -1023,14 +1026,19 @@ nm_device_take_over_link (NMDevice *self, const char *ifname)
return FALSE;
ifindex = plink->ifindex;
- up = NM_FLAGS_HAS (plink->n_ifi_flags, IFF_UP);
-
- /* Rename the link to the device ifname */
- if (up)
- nm_platform_link_set_down (platform, ifindex);
- success = nm_platform_link_set_name (platform, ifindex, nm_device_get_iface (self));
- if (up)
- nm_platform_link_set_up (platform, ifindex, NULL);
+
+ if (!nm_streq (ifname, nm_device_get_iface (self))) {
+ up = NM_FLAGS_HAS (plink->n_ifi_flags, IFF_UP);
+
+ /* Rename the link to the device ifname */
+ if (up)
+ nm_platform_link_set_down (platform, ifindex);
+ success = nm_platform_link_set_name (platform, ifindex, nm_device_get_iface (self));
+ if (up)
+ nm_platform_link_set_up (platform, ifindex, NULL);
+
+ NM_SET_OUT (renamed, success);
+ }
if (success) {
priv->ifindex = ifindex;