#310 multiple LLDP management addresses

This commit is contained in:
Oliver Gorwits
2017-06-24 18:47:42 +01:00
parent b93b6dbb83
commit 4ad9497784
2 changed files with 26 additions and 31 deletions

View File

@@ -10,7 +10,8 @@
* #320 DNS subroutines are redefined * #320 DNS subroutines are redefined
* #318 ACLs with RegExp are very slow - aggressive resolver timeouts * #318 ACLs with RegExp are very slow - aggressive resolver timeouts
* #317 #265 #311 when renumbering on discover, delete likely duplicate devices * #317 #265 #311 when renumbering on discover, delete likely duplicate devices
* #316 Neighbor map should fall back to device sysname after dns * #316 neighbor map should fall back to device sysname after dns
* #310 multiple LLDP management addresses
2.036001 - 2017-06-22 2.036001 - 2017-06-22

View File

@@ -829,39 +829,33 @@ sub store_neighbors {
} }
} }
# hack for devices seeing multiple neighbors on the port # what we came here to do.... discover the neighbor(s)
if (ref [] eq ref $remote_ip) { foreach my $n ((ref $remote_ip) ? @$remote_ip : ($remote_ip)) {
debug sprintf
' [%s] neigh - port %s has multiple neighbors, setting remote as self',
$device->ip, $port;
foreach my $n (@$remote_ip) {
debug sprintf
' [%s] neigh - adding neighbor %s, type [%s], on %s to discovery queue',
$device->ip, $n, ($remote_type || ''), $port;
push @to_discover, [$n, $remote_type];
}
# set self as remote IP to suppress any further work
$remote_ip = $device->ip;
$remote_port = $port;
}
else {
# what we came here to do.... discover the neighbor
debug sprintf debug sprintf
' [%s] neigh - adding neighbor %s, type [%s], on %s to discovery queue', ' [%s] neigh - adding neighbor %s, type [%s], on %s to discovery queue',
$device->ip, $remote_ip, ($remote_type || ''), $port; $device->ip, $n, ($remote_type || ''), $port;
push @to_discover, [$remote_ip, $remote_type]; push @to_discover, [$n, $remote_type];
}
$remote_port = $c_port->{$entry}; # devices seeing multiple neighbors on the port
if (defined $remote_port) { # pick the highest IP for the neighbor, which results in preferring IPv6
# clean weird characters if (ref [] eq ref $remote_ip) {
$remote_port =~ s/[^\d\/\.,()\w:-]+//gi; debug sprintf
} ' [%s] neigh - port %s has multiple neighbors, picking highest',
else { $device->ip, $port;
info sprintf ' [%s] neigh - no remote port found for port %s at %s',
$device->ip, $port, $remote_ip; $remote_ip = [reverse sort {NetAddr::IP::Lite->new($a)
} <=> NetAddr::IP::Lite->new($b)} @$remote_ip]->[0];
}
$remote_port = $c_port->{$entry};
if (defined $remote_port) {
# clean weird characters
$remote_port =~ s/[^\d\/\.,()\w:-]+//gi;
}
else {
info sprintf ' [%s] neigh - no remote port found for port %s at %s',
$device->ip, $port, $remote_ip;
} }
$portrow->update({ $portrow->update({