[#123] Allow devices with no LLDP/CDP to be found as Nodes

This commit is contained in:
Oliver Gorwits
2014-08-25 18:48:11 +01:00
parent 05493abbb7
commit 2bc92999b8
2 changed files with 17 additions and 3 deletions

View File

@@ -8,6 +8,7 @@
[ENHANCEMENTS] [ENHANCEMENTS]
* Port search also searches on the Remote ID and Type * Port search also searches on the Remote ID and Type
* [#123] Allow devices with no LLDP/CDP to be found as Nodes
2.029005 - 2014-08-13 2.029005 - 2014-08-13

View File

@@ -346,6 +346,8 @@ sub _walk_fwtable {
next; next;
} }
my $vlan = $fw_vlan->{$idx} || $comm_vlan || '0';
# check to see if the port is connected to another device # check to see if the port is connected to another device
# and if we have that device in the database. # and if we have that device in the database.
@@ -371,12 +373,13 @@ sub _walk_fwtable {
debug sprintf debug sprintf
' [%s] macsuck %s - port %s is detected uplink - skipping.', ' [%s] macsuck %s - port %s is detected uplink - skipping.',
$device->ip, $mac, $port; $device->ip, $mac, $port;
$skiplist->{$port} = [ $vlan, $mac ] # remember for later
if exists $port_macs->{$mac};
next; next;
} }
} }
my $vlan = $fw_vlan->{$idx} || $comm_vlan || '0';
if (exists $port_macs->{$mac}) { if (exists $port_macs->{$mac}) {
my $switch_ip = $port_macs->{$mac}; my $switch_ip = $port_macs->{$mac};
if ($device->ip eq $switch_ip) { if ($device->ip eq $switch_ip) {
@@ -395,7 +398,8 @@ sub _walk_fwtable {
if (not setting('macsuck_bleed')) { if (not setting('macsuck_bleed')) {
debug sprintf ' [%s] macsuck %s - adding port %s to skiplist', debug sprintf ' [%s] macsuck %s - adding port %s to skiplist',
$device->ip, $mac, $port; $device->ip, $mac, $port;
$skiplist->{$port} = delete $cache->{$vlan}->{$port};
$skiplist->{$port} = [ $vlan, $mac ]; # remember for later
next; next;
} }
} }
@@ -410,6 +414,15 @@ sub _walk_fwtable {
++$cache->{$vlan}->{$port}->{$mac}; ++$cache->{$vlan}->{$port}->{$mac};
} }
# restore MACs of neighbor devices.
# this is when we have a "possible uplink" detected but we still want to
# record the single MAC of the neighbor device so it works in Node search.
foreach my $port (keys %$skiplist) {
my ($vlan, $mac) = @{ $skiplist->{$port} };
delete $cache->{$_}->{$port} for keys %$cache; # nuke nodes on all VLANs
++$cache->{$vlan}->{$port}->{$mac};
}
return $cache; return $cache;
} }