summaryrefslogtreecommitdiff
path: root/src/devices/wwan/nm-device-modem.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-01-11 09:47:30 +0100
committerThomas Haller <thaller@redhat.com>2018-02-21 20:28:46 +0100
commitc7b3586b9db49fed8926d746ec24e3d21b542f42 (patch)
tree9f25cf61525bbb144688802a003111eae0a8d171 /src/devices/wwan/nm-device-modem.c
parent2ea8e1029fc3a4f51e240ea4b90a74f5031a608b (diff)
downloadNetworkManager-c7b3586b9db49fed8926d746ec24e3d21b542f42.tar.gz
wwan: rework setting modem's data-port
Depending on the bearer's configuration method, the data-port is either a networking interface, or an tty for ppp. Let's treat them strictily separate. Also, rework how NM_MODEM_DATA_PORT was used in both contexts. Instead, use the that we actually care about. Also, when nm_device_set_ip_ifindex() fails, fail activation right away. Also, we early try to resolve the network interface's name to an ifindex. If that fails, the device is already gone and we fail early.
Diffstat (limited to 'src/devices/wwan/nm-device-modem.c')
-rw-r--r--src/devices/wwan/nm-device-modem.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index 86f1864946..7aa2fd9315 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -260,21 +260,26 @@ modem_ip6_config_result (NMModem *modem,
}
static void
-data_port_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
+ip_ifindex_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data)
{
- NMDevice *self = NM_DEVICE (user_data);
- gboolean has_ifindex;
+ NMDevice *device = NM_DEVICE (user_data);
+
+ if (!nm_device_is_activating (device))
+ return;
- /* We set the IP iface in the device as soon as we know it, so that we
- * properly ifup it if needed */
- has_ifindex = nm_device_set_ip_iface (self, nm_modem_get_data_port (modem));
+ if (!nm_device_set_ip_ifindex (device,
+ nm_modem_get_ip_ifindex (modem))) {
+ nm_device_state_changed (device,
+ NM_DEVICE_STATE_FAILED,
+ NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
+ return;
+ }
/* Disable IPv6 immediately on the interface since NM handles IPv6
* internally, and leaving it enabled could allow the kernel's IPv6
* RA handling code to run before NM is ready.
*/
- if (has_ifindex)
- nm_device_ipv6_sysctl_set (self, "disable_ipv6", "1");
+ nm_device_ipv6_sysctl_set (device, "disable_ipv6", "1");
}
static void
@@ -629,7 +634,7 @@ set_modem (NMDeviceModem *self, NMModem *modem)
g_signal_connect (modem, NM_MODEM_STATE_CHANGED, G_CALLBACK (modem_state_cb), self);
g_signal_connect (modem, NM_MODEM_REMOVED, G_CALLBACK (modem_removed_cb), self);
- g_signal_connect (modem, "notify::" NM_MODEM_DATA_PORT, G_CALLBACK (data_port_changed_cb), self);
+ g_signal_connect (modem, "notify::" NM_MODEM_IP_IFINDEX, G_CALLBACK (ip_ifindex_changed_cb), self);
g_signal_connect (modem, "notify::" NM_MODEM_DEVICE_ID, G_CALLBACK (ids_changed_cb), self);
g_signal_connect (modem, "notify::" NM_MODEM_SIM_ID, G_CALLBACK (ids_changed_cb), self);
g_signal_connect (modem, "notify::" NM_MODEM_SIM_OPERATOR_ID, G_CALLBACK (ids_changed_cb), self);