From 8a91b7beb48934ef730eb627b37e5373d30981d8 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 10 Aug 2023 17:36:49 +0200 Subject: [PATCH] device: log ACD conflicts l3cfg emits a log for ACD conflicts. However, l3cfg is not aware of what are the related NMDevice or the currently active connection, and so it can't log the proper metadata fields (NM_DEVICE and NM_CONNECTION) to the journal. Instead, let NMDevice log about ACD collisions; in this way, it is possible to get the message when filtering by device and connection. For example: $ journalctl -e NM_CONNECTION=d1df47be-721f-472d-a1bf-51815ac7ec3d + NM_DEVICE=veth0 device (veth0): IP address 172.25.42.1 cannot be configured because it is already in use in the network by host 00:99:88:77:66:55 device (veth0): state change: ip-config -> failed (reason 'ip-config-unavailable', sys-iface-state: 'managed') device (veth0): Activation: failed for connection 'veth0+' (cherry picked from commit 9143c1b542a27028343899f0fc14924d0a9f1672) --- src/core/devices/nm-device.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index ee0f502f17..d1212560db 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -4247,6 +4247,20 @@ _dev_l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, N case NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT: { const NML3AcdAddrInfo *addr_info = ¬ify_data->acd_event.info; + char buf_addr[NM_INET_ADDRSTRLEN]; + + if (addr_info->state == NM_L3_ACD_ADDR_STATE_USED) { + _LOGI(LOGD_DEVICE, + "IP address %s cannot be configured because it is already in use in the " + "network by host %s", + nm_inet4_ntop(addr_info->addr, buf_addr), + nm_ether_addr_to_string_a(&addr_info->last_conflict_addr)); + } else if (addr_info->state == NM_L3_ACD_ADDR_STATE_CONFLICT) { + _LOGI(LOGD_DEVICE, + "conflict detected for IP address %s with host %s", + nm_inet4_ntop(addr_info->addr, buf_addr), + nm_ether_addr_to_string_a(&addr_info->last_conflict_addr)); + } if (addr_info->state > NM_L3_ACD_ADDR_STATE_PROBING) _dev_ipmanual_check_ready(self);