[PATCH git master] device/wwan: indicate whether IP iface/ifindex changed and simplify WwAN code
- From: Dan Williams <dcbw redhat com>
- To: "networkmanager." <networkmanager-list gnome org>
- Subject: [PATCH git master] device/wwan: indicate whether IP iface/ifindex changed and simplify WwAN code
- Date: Wed, 11 Jan 2017 19:35:09 -0600
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.
---
src/devices/nm-device-private.h | 2 +-
src/devices/nm-device.c | 19 +++++++++++++++----
src/devices/wwan/nm-device-modem.c | 9 ++-------
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h
index c5b4936..c2ba98f 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 bd53b09..0c6ab41 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 fec0d4c..7a70a0b 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
--
2.9.3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]