summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2017-01-11 19:35:09 -0600
committerThomas Haller <thaller@redhat.com>2017-01-12 13:34:22 +0100
commit8de7b8ed3136fd0651eebd6aacef1a4286d7cda0 (patch)
treee8d8034620b7a02c55d7c75b33ff863e97a72535
parentbf3b3d444c7750a68a0771d99f48e663815e258e (diff)
downloadNetworkManager-8de7b8ed3136fd0651eebd6aacef1a4286d7cda0.tar.gz
device/wwan: indicate whether IP iface/ifindex changed and simplify WwAN code
Replace some code in the WWAN device class that checks for a changed interface name with code that uses the new return value from nm_device_set_ip_iface(), which now checks whether the ip_ifindex changed too. https://mail.gnome.org/archives/networkmanager-list/2017-January/msg00010.html
-rw-r--r--src/devices/nm-device-private.h2
-rw-r--r--src/devices/nm-device.c19
-rw-r--r--src/devices/wwan/nm-device-modem.c9
3 files changed, 18 insertions, 12 deletions
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h
index c5b4936b51..c2ba98f387 100644
--- a/src/devices/nm-device-private.h
+++ b/src/devices/nm-device-private.h
@@ -45,7 +45,7 @@ enum NMActStageReturn {
NMSettings *nm_device_get_settings (NMDevice *self);
-void nm_device_set_ip_iface (NMDevice *self, const char *iface);
+gboolean nm_device_set_ip_iface (NMDevice *self, const char *iface);
void nm_device_activate_schedule_stage3_ip_config_start (NMDevice *device);
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 64bb62c893..f172ec2c6f 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -848,22 +848,32 @@ nm_device_get_ip_ifindex (NMDevice *self)
return priv->ip_iface ? priv->ip_ifindex : priv->ifindex;
}
-void
+/**
+ * nm_device_set_ip_iface:
+ * @self: the #NMDevice
+ * @iface: the new IP interface name
+ *
+ * Updates the IP interface name and possibly the ifindex.
+ *
+ * Returns: %TRUE if the anything (name or ifindex) changed, %FALSE if nothing
+ * changed.
+ */
+gboolean
nm_device_set_ip_iface (NMDevice *self, const char *iface)
{
NMDevicePrivate *priv;
int ifindex;
- g_return_if_fail (NM_IS_DEVICE (self));
+ g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
priv = NM_DEVICE_GET_PRIVATE (self);
if (nm_streq0 (iface, priv->ip_iface)) {
if (!iface)
- return;
+ return FALSE;
ifindex = nm_platform_if_nametoindex (NM_PLATFORM_GET, iface);
if ( ifindex <= 0
|| priv->ip_ifindex == ifindex)
- return;
+ return FALSE;
priv->ip_ifindex = ifindex;
_LOGD (LOGD_DEVICE, "ip-ifname: update ifindex for ifname '%s': %d", iface, priv->ip_ifindex);
@@ -904,6 +914,7 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface)
priv->ip_mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ip_ifindex);
_notify (self, PROP_IP_IFACE);
+ return TRUE;
}
static gboolean
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index fec0d4ce91..7a70a0bf43 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -260,16 +260,11 @@ static void
data_port_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
{
NMDevice *self = NM_DEVICE (user_data);
- const char *old = nm_device_get_ip_iface (self);
- const char *new = nm_modem_get_data_port (modem);
- gboolean changed = FALSE;
-
- if (new && g_strcmp0 (new, old))
- changed = TRUE;
+ gboolean changed;
/* We set the IP iface in the device as soon as we know it, so that we
* properly ifup it if needed */
- nm_device_set_ip_iface (self, new);
+ changed = nm_device_set_ip_iface (self, nm_modem_get_data_port (modem));
/* Disable IPv6 immediately on the interface since NM handles IPv6
* internally, and leaving it enabled could allow the kernel's IPv6