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.
This commit is contained in:
Dan Williams 2014-07-15 17:16:56 -05:00
parent 69ea2705ec
commit af1f183b3d
3 changed files with 35 additions and 2 deletions

View file

@ -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 */

View file

@ -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);

View file

@ -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