device/dhcp: avoid crash by not starting DHCPv6 client without ifindex

https://bugzilla.redhat.com/show_bug.cgi?id=1973199
(cherry picked from commit 85f53f43e9)
This commit is contained in:
Thomas Haller 2021-07-14 18:18:02 +02:00
parent d525a3b795
commit bbfdbf5f76
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -9968,6 +9968,7 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection)
gboolean iaid_explicit;
NMSettingConnection * s_con;
const NMPlatformIP6Address *ll_addr = NULL;
int ip_ifindex;
g_return_val_if_fail(connection, FALSE);
@ -9987,7 +9988,13 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection)
return FALSE;
}
pllink = nm_platform_link_get(nm_device_get_platform(self), nm_device_get_ip_ifindex(self));
ip_ifindex = nm_device_get_ip_ifindex(self);
if (ip_ifindex <= 0) {
_LOGD(LOGD_DHCP6, "can't start DHCPv6: interface is gone");
return FALSE;
}
pllink = nm_platform_link_get(nm_device_get_platform(self), ip_ifindex);
if (pllink)
hwaddr = nmp_link_address_get_as_bytes(&pllink->l_address);
@ -9998,7 +10005,7 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection)
nm_dhcp_manager_get(),
nm_device_get_multi_index(self),
nm_device_get_ip_iface(self),
nm_device_get_ip_ifindex(self),
ip_ifindex,
&ll_addr->address,
nm_connection_get_uuid(connection),
nm_device_get_route_table(self, AF_INET6),