device: split ensure_ipx_config() into IPv4 and IPv6 (bgo #751430)

Without that we can remove addresses from con-ip6-config due to external
changes *before* it is applied and thus manual IPv6 addresses are not applied
together with ipv6.method=auto.

Testcase:
$ nmcli con add type ether con-name AAA ifname eth0 autoconnect no
$ nmcli con mod AAA ipv4.addresses 1.1.1.1/24 ipv6.addresses 99::99/64
$ nmcli con up AAA

Fixes:Beaker:NetworkManager_Test37_run_once_new_connection
Fixes:Beaker:NetworkManager_Test84_ipv6_addresses_no_when_static_switch_asked

https://bugzilla.gnome.org/show_bug.cgi?id=751430

(cherry picked from commit 0a00eb67dd)
This commit is contained in:
Jiří Klimeš 2015-06-24 09:42:58 +00:00
parent ab9d36c4c4
commit ee022bb688

View file

@ -3097,13 +3097,11 @@ _device_get_default_route_from_platform (NMDevice *self, int addr_family, NMPlat
/*********************************************/
static void
ensure_con_ipx_config (NMDevice *self)
ensure_con_ip4_config (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMConnection *connection;
g_assert (!!priv->con_ip4_config == !!priv->con_ip6_config);
if (priv->con_ip4_config)
return;
@ -3112,20 +3110,37 @@ ensure_con_ipx_config (NMDevice *self)
return;
priv->con_ip4_config = nm_ip4_config_new ();
priv->con_ip6_config = nm_ip6_config_new ();
nm_ip4_config_merge_setting (priv->con_ip4_config,
nm_connection_get_setting_ip4_config (connection),
nm_device_get_ip4_route_metric (self));
if (nm_device_uses_assumed_connection (self)) {
/* For assumed connections ignore all addresses and routes. */
nm_ip4_config_reset_addresses (priv->con_ip4_config);
nm_ip4_config_reset_routes (priv->con_ip4_config);
}
}
static void
ensure_con_ip6_config (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMConnection *connection;
if (priv->con_ip6_config)
return;
connection = nm_device_get_connection (self);
if (!connection)
return;
priv->con_ip6_config = nm_ip6_config_new ();
nm_ip6_config_merge_setting (priv->con_ip6_config,
nm_connection_get_setting_ip6_config (connection),
nm_device_get_ip6_route_metric (self));
if (nm_device_uses_assumed_connection (self)) {
/* For assumed connections ignore all addresses and routes. */
nm_ip4_config_reset_addresses (priv->con_ip4_config);
nm_ip4_config_reset_routes (priv->con_ip4_config);
nm_ip6_config_reset_addresses (priv->con_ip6_config);
nm_ip6_config_reset_routes (priv->con_ip6_config);
}
@ -3184,7 +3199,7 @@ ip4_config_merge_and_apply (NMDevice *self,
composite = nm_ip4_config_new ();
if (commit)
ensure_con_ipx_config (self);
ensure_con_ip4_config (self);
if (priv->dev_ip4_config)
nm_ip4_config_merge (composite, priv->dev_ip4_config);
@ -3777,7 +3792,7 @@ ip6_config_merge_and_apply (NMDevice *self,
composite = nm_ip6_config_new ();
if (commit)
ensure_con_ipx_config (self);
ensure_con_ip6_config (self);
/* Merge all the IP configs into the composite config */
if (priv->ac_ip6_config)