arping: print IP address conflicts

Print a warning whenever we find a IP conflict on the network. In the
future we may export a flag on the device or send a signal so that
clients can notify the user of the conflict.
This commit is contained in:
Beniamino Galvani 2018-03-31 11:52:27 +02:00
parent ac8618c78f
commit df488184a8

View file

@ -179,6 +179,7 @@ acd_event (GIOChannel *source, GIOCondition condition, gpointer data)
NMArpingManagerPrivate *priv = NM_ARPING_MANAGER_GET_PRIVATE (self);
NAcdEvent *event;
char address_str[INET_ADDRSTRLEN];
gs_free char *hwaddr_str = NULL;
int r;
if ( n_acd_dispatch (info->acd)
@ -204,6 +205,19 @@ acd_event (GIOChannel *source, GIOCondition condition, gpointer data)
case N_ACD_EVENT_USED:
info->duplicate = TRUE;
break;
case N_ACD_EVENT_DEFENDED:
_LOGD ("defended address %s from host %s",
nm_utils_inet4_ntop (info->address, address_str),
(hwaddr_str = nm_utils_hwaddr_ntoa (event->defended.sender,
event->defended.n_sender)));
break;
case N_ACD_EVENT_CONFLICT:
_LOGW ("conflict for address %s detected with host %s on interface '%s'",
nm_utils_inet4_ntop (info->address, address_str),
(hwaddr_str = nm_utils_hwaddr_ntoa (event->defended.sender,
event->defended.n_sender)),
nm_platform_link_get_name (NM_PLATFORM_GET, priv->ifindex));
break;
default:
_LOGD ("event '%s' for address %s",
acd_event_to_string (event->event),