device: don't assume by default IPv6LL-only connections

Add the new configuration option 'assume-ipv6ll-only' which specifies
the devices for which NM will try to assume an existing IPv6LL-only
configuration.

The new default behavior is to ignore such configurations since IPv6LL
addresses are automatically assigned by the kernel when the device is
brought up and thus the presence of an IPv6LL address doesn't mean
that the device was configured by the administrator.

The previous behavior was to always assume IPv6LL-only configurations
but this often had the unwanted effect of preventing other on-disk
configurations to be activated. To preserve the old behavior the
option must be set to '*'.

https://bugzilla.redhat.com/show_bug.cgi?id=1138426
This commit is contained in:
Beniamino Galvani 2015-05-20 11:36:37 +02:00
parent 231e9e3968
commit 3bc097b084
4 changed files with 41 additions and 0 deletions

View file

@ -208,6 +208,20 @@ no-auto-default=*
</listitem>
</varlistentry>
<varlistentry>
<term><varname>assume-ipv6ll-only</varname></term>
<listitem>
<para>
Specify devices for which NetworkManager will try to
generate a connection based on initial configuration when
the device only has an IPv6 link-local address.
</para>
<para>See <xref linkend="device-spec"/> for the syntax how to
specify a device.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>configure-and-quit</varname></term>
<listitem>

View file

@ -2172,6 +2172,20 @@ nm_device_generate_connection (NMDevice *self, NMDevice *master)
connection = NULL;
}
/* Ignore any IPv6LL-only, not master connections without slaves,
* unless they are in the assume-ipv6ll-only list.
*/
if ( connection
&& g_strcmp0 (ip4_method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0
&& g_strcmp0 (ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0
&& !nm_setting_connection_get_master (NM_SETTING_CONNECTION (s_con))
&& !priv->slaves
&& !nm_config_data_get_assume_ipv6ll_only (nm_config_get_data (nm_config_get ()), self)) {
_LOGD (LOGD_DEVICE, "ignoring generated connection (IPv6LL-only and not in master-slave relationship)");
g_object_unref (connection);
connection = NULL;
}
return connection;
}

View file

@ -46,6 +46,7 @@ typedef struct {
} no_auto_default;
GSList *ignore_carrier;
GSList *assume_ipv6ll_only;
char *dns_mode;
char *rc_manager;
@ -160,6 +161,15 @@ nm_config_data_get_ignore_carrier (const NMConfigData *self, NMDevice *device)
return nm_device_spec_match_list (device, NM_CONFIG_DATA_GET_PRIVATE (self)->ignore_carrier);
}
gboolean
nm_config_data_get_assume_ipv6ll_only (const NMConfigData *self, NMDevice *device)
{
g_return_val_if_fail (NM_IS_CONFIG_DATA (self), FALSE);
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
return nm_device_spec_match_list (device, NM_CONFIG_DATA_GET_PRIVATE (self)->assume_ipv6ll_only);
}
/************************************************************************/
static gboolean
@ -328,6 +338,7 @@ finalize (GObject *gobject)
g_free (priv->rc_manager);
g_slist_free_full (priv->ignore_carrier, g_free);
g_slist_free_full (priv->assume_ipv6ll_only, g_free);
g_key_file_unref (priv->keyfile);
@ -361,6 +372,7 @@ constructed (GObject *object)
priv->rc_manager = g_key_file_get_value (priv->keyfile, "main", "rc-manager", NULL);
priv->ignore_carrier = nm_config_get_device_match_spec (priv->keyfile, "main", "ignore-carrier");
priv->assume_ipv6ll_only = nm_config_get_device_match_spec (priv->keyfile, "main", "assume-ipv6ll-only");
G_OBJECT_CLASS (nm_config_data_parent_class)->constructed (object);
}

View file

@ -92,6 +92,7 @@ const char *nm_config_data_get_dns_mode (const NMConfigData *self);
const char *nm_config_data_get_rc_manager (const NMConfigData *self);
gboolean nm_config_data_get_ignore_carrier (const NMConfigData *self, NMDevice *device);
gboolean nm_config_data_get_assume_ipv6ll_only (const NMConfigData *self, NMDevice *device);
G_END_DECLS