mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 09:10:17 +01:00
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
This commit is contained in:
parent
bf3b3d444c
commit
8de7b8ed31
3 changed files with 18 additions and 12 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue