From cb3463bbc19234b37276e608fd20ac954900c74f Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 31 Aug 2023 14:06:09 +0200 Subject: [PATCH] core: don't fail if at least one static address passes DAD It seems more useful to have a best effort approach and configure everything we can; in that way we achieve at least some connectivity, and then sysadmin can check the logs in case something is missing. Currently instead, the whole activation fails (so, no address is configured) if just one of the addresses fails DAD. Ideally, we should have a way to make this configurable; but for now, implement the more useful behavior as default. (cherry picked from commit a45024714f457e38f268f9aec5f6e4fbeab508ed) --- src/core/devices/nm-device.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index e8c25bc6ef..14d85b80e2 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -10403,12 +10403,24 @@ _dev_ipmanual_check_ready(NMDevice *self) addr_family, flags, &conflicts); - if (conflicts) { - _dev_ipmanual_set_state(self, addr_family, NM_DEVICE_IP_STATE_FAILED); - _dev_ip_state_check_async(self, AF_UNSPEC); - } else if (ready) { - _dev_ipmanual_set_state(self, addr_family, NM_DEVICE_IP_STATE_READY); - _dev_ip_state_check_async(self, AF_UNSPEC); + if (ready) { + guint num_addrs = 0; + + num_addrs = + nm_l3_config_data_get_num_addresses(priv->l3cds[L3_CONFIG_DATA_TYPE_MANUALIP].d, + addr_family); + + if (conflicts && conflicts->len == num_addrs) { + _LOGD_ipmanual(addr_family, "all manual addresses failed DAD, failing"); + _dev_ipmanual_set_state(self, addr_family, NM_DEVICE_IP_STATE_FAILED); + _dev_ip_state_check_async(self, AF_UNSPEC); + } else { + if (conflicts) { + _LOGD_ipmanual(addr_family, "some manual addresses passed DAD, continuing"); + } + _dev_ipmanual_set_state(self, addr_family, NM_DEVICE_IP_STATE_READY); + _dev_ip_state_check_async(self, AF_UNSPEC); + } } } }