summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-07-15 17:16:56 -0500
committerDan Williams <dcbw@redhat.com>2014-07-23 14:26:39 -0500
commitaf1f183b3d1a38548be96cf41e835847e89b953b (patch)
treed63df2a398a1333efc56e2df78c510319c2c52be
parent69ea2705eceee1c8c1ead77dc4013b3c217a235b (diff)
downloadNetworkManager-af1f183b3d1a38548be96cf41e835847e89b953b.tar.gz
wwan: split out WWAN IP4Config from device config
We want to set the WWAN config last, to ensure that the configuration we use overwrites anything that pppd might have set, becuase it touches some stuff itself. That means we have to keep the WWAN config separate, since dev_ip4_config is used for DHCP and IPv4LL, which we always set first to ensure they these don't overwrite external, administrator added config (eg, priv->ext_ip4_config). This also synchronizes the IPv4 config path with the upcoming IPv6 config path.
-rw-r--r--src/devices/nm-device-private.h2
-rw-r--r--src/devices/nm-device.c29
-rw-r--r--src/devices/wwan/nm-device-modem.c6
3 files changed, 35 insertions, 2 deletions
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h
index c1f1c799bf..3bb17db162 100644
--- a/src/devices/nm-device-private.h
+++ b/src/devices/nm-device-private.h
@@ -98,4 +98,6 @@ void nm_device_set_carrier (NMDevice *device, gboolean carrier);
void nm_device_emit_recheck_auto_activate (NMDevice *device);
void nm_device_queue_recheck_assume (NMDevice *device);
+void nm_device_set_wwan_ip4_config (NMDevice *device, NMIP4Config *config);
+
#endif /* NM_DEVICE_PRIVATE_H */
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index ee6c3862ea..0a17300978 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -237,6 +237,7 @@ typedef struct {
IpState ip4_state;
NMIP4Config * dev_ip4_config; /* Config from DHCP, PPP, LLv4, etc */
NMIP4Config * ext_ip4_config; /* Stuff added outside NM */
+ NMIP4Config * wwan_ip4_config; /* WWAN configuration */
/* DHCPv4 tracking */
NMDHCPClient * dhcp4_client;
@@ -2662,6 +2663,12 @@ ip4_config_merge_and_apply (NMDevice *self,
if (priv->ext_ip4_config)
nm_ip4_config_merge (composite, priv->ext_ip4_config);
+ /* Merge WWAN config *last* to ensure modem-given settings overwrite
+ * any external stuff set by pppd or other scripts.
+ */
+ if (priv->wwan_ip4_config)
+ nm_ip4_config_merge (composite, priv->wwan_ip4_config);
+
/* Merge user overrides into the composite config */
connection = nm_device_get_connection (self);
if (connection) {
@@ -5204,6 +5211,25 @@ nm_device_set_vpn4_config (NMDevice *device, NMIP4Config *config)
}
}
+void
+nm_device_set_wwan_ip4_config (NMDevice *device, NMIP4Config *config)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (device);
+
+ if (priv->wwan_ip4_config == config)
+ return;
+
+ g_clear_object (&priv->wwan_ip4_config);
+ if (config)
+ priv->wwan_ip4_config = g_object_ref (config);
+
+ /* NULL to use existing configs */
+ if (!ip4_config_merge_and_apply (device, NULL, TRUE, NULL)) {
+ nm_log_warn (LOGD_IP4, "(%s): failed to set WWAN IPv4 configuration",
+ nm_device_get_ip_iface (device));
+ }
+}
+
static gboolean
nm_device_set_ip6_config (NMDevice *self,
NMIP6Config *new_config,
@@ -5864,6 +5890,8 @@ update_ip_config (NMDevice *self, gboolean initial)
nm_ip4_config_subtract (priv->ext_ip4_config, priv->dev_ip4_config);
if (priv->vpn4_config)
nm_ip4_config_subtract (priv->ext_ip4_config, priv->vpn4_config);
+ if (priv->wwan_ip4_config)
+ nm_ip4_config_subtract (priv->ext_ip4_config, priv->wwan_ip4_config);
ip4_config_merge_and_apply (self, NULL, FALSE, NULL);
}
@@ -6511,6 +6539,7 @@ _cleanup_generic_post (NMDevice *self, gboolean deconfigure)
nm_device_set_ip6_config (self, NULL, TRUE, &ignored);
g_clear_object (&priv->dev_ip4_config);
g_clear_object (&priv->ext_ip4_config);
+ g_clear_object (&priv->wwan_ip4_config);
g_clear_object (&priv->vpn4_config);
g_clear_object (&priv->ip4_config);
g_clear_object (&priv->ac_ip6_config);
diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c
index 98ff610229..a4d92998dd 100644
--- a/src/devices/wwan/nm-device-modem.c
+++ b/src/devices/wwan/nm-device-modem.c
@@ -158,8 +158,10 @@ modem_ip4_config_result (NMModem *self,
error && error->message ? error->message : "(unknown)");
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
- } else
- nm_device_activate_schedule_ip4_config_result (device, config);
+ } else {
+ nm_device_set_wwan_ip4_config (device, config);
+ nm_device_activate_schedule_ip4_config_result (device, NULL);
+ }
}
static void