diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2023-08-10 17:36:49 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2023-08-11 13:30:38 +0200 |
commit | 9143c1b542a27028343899f0fc14924d0a9f1672 (patch) | |
tree | fe6a4d69b2b810231abd15c05177c28143eab804 | |
parent | db307e69cbbc0438699d2ac245b173528dec8e31 (diff) |
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
<info> 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
<info> device (veth0): state change: ip-config -> failed (reason 'ip-config-unavailable', sys-iface-state: 'managed')
<warn> device (veth0): Activation: failed for connection 'veth0+'
-rw-r--r-- | src/core/devices/nm-device.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 5f1b057a38..47d17a200b 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); |