From 899563534a14d365ff4d5d63752d2f4ed500098e Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 11 Jan 2014 14:08:46 +0000 Subject: [PATCH] [#52] Check is neighbour remote_id is a MAC (R. Kerr) --- Netdisco/Changes | 1 + Netdisco/lib/App/Netdisco/Core/Discover.pm | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Netdisco/Changes b/Netdisco/Changes index 6fc99b6f..86811bce 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -13,6 +13,7 @@ * [#66] DB Schema update to add "native" column to PK of device_port_vlan table * [#64] Addition of Wireshark abbreviations for OUI manufacturers * [#79] Support perlbrew environment as alternative to localenv + * [#52] Check is neighbour remote_id is a MAC (R. Kerr) [BUG FIXES] diff --git a/Netdisco/lib/App/Netdisco/Core/Discover.pm b/Netdisco/lib/App/Netdisco/Core/Discover.pm index af07df13..c5ee4003 100644 --- a/Netdisco/lib/App/Netdisco/Core/Discover.pm +++ b/Netdisco/lib/App/Netdisco/Core/Discover.pm @@ -8,6 +8,7 @@ use App::Netdisco::Util::DNS ':all'; use NetAddr::IP::Lite ':lower'; use Encode; use Try::Tiny; +use Net::MAC; use base 'Exporter'; our @EXPORT = (); @@ -662,6 +663,13 @@ sub store_neighbors { ' [%s] neigh - bad address %s on port %s, searching for %s instead', $device->ip, $remote_ip, $port, $remote_id; + if (!defined $neigh) { + my $mac = Net::MAC->new(mac => $remote_id, 'die' => 0, verbose => 0); + if (not $mac->get_error) { + $neigh = $devices->single({mac => $remote_id}); + } + } + if (!defined $neigh) { (my $shortid = $remote_id) =~ s/\..*//; $neigh = $devices->single({name => { -ilike => "${shortid}%" }});