device: allow ipv6ll address to be set for disconnected devices

Commit f85941ee91 ("device: don't try to generate ipv6ll address for
disconnected devices") disabled the generation of IPv6 link-local
addresses for disconnected devices to fix a crash. However that broke
the following:

 $ ip a f dev eth0
 $ systemctl start NetworkManager
 $ nmcli d
 DEVICE  TYPE      STATE         CONNECTION
 eth0    ethernet  disconnected  eth0
 $ ip a a dev eth0 2001::42/64
 $ ip a show eth0
 4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
     link/ether 52:52:00:61:32:81 brd ff:ff:ff:ff:ff:ff
     inet6 2001::42/64 scope global
        valid_lft forever preferred_lft forever
     (no link-local address)

Instead, enable the generation of a link-local address even if the
device is disconnected and fix nm_device_get_ip_iface_identifier() to
not require a connection if @ignore_token is set.

Fixes: f85941ee91
This commit is contained in:
Beniamino Galvani
2016-07-07 16:29:25 +02:00
parent e988ed96f9
commit 75406d1760

View File

@@ -823,18 +823,15 @@ nm_device_get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *iid, gboo
{
NMSettingIP6Config *s_ip6;
const char *token = NULL;
NMConnection *connection;
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
connection = nm_device_get_applied_connection (self);
nm_assert (connection);
s_ip6 = NM_SETTING_IP6_CONFIG (nm_connection_get_setting_ip6_config (connection));
nm_assert (s_ip6);
if (!ignore_token)
if (!ignore_token) {
s_ip6 = (NMSettingIP6Config *)
nm_device_get_applied_setting (self, NM_TYPE_SETTING_IP6_CONFIG);
g_return_val_if_fail (s_ip6, FALSE);
token = nm_setting_ip6_config_get_token (s_ip6);
}
if (token)
return nm_utils_ipv6_interface_identifier_get_from_token (iid, token);
else
@@ -9459,8 +9456,7 @@ queued_ip6_config_change (gpointer user_data)
priv->queued_ip6_config_id = 0;
update_ip6_config (self, FALSE);
if ( priv->state > NM_DEVICE_STATE_DISCONNECTED
&& priv->state < NM_DEVICE_STATE_DEACTIVATING
if (priv->state < NM_DEVICE_STATE_DEACTIVATING
&& nm_platform_link_get (NM_PLATFORM_GET, priv->ifindex)) {
/* Handle DAD failures */
for (iter = priv->dad6_failed_addrs; iter; iter = g_slist_next (iter)) {