From 4e2b642ed16833e5fe40037b2971af14f00a49d2 Mon Sep 17 00:00:00 2001 From: Bill Fenner Date: Mon, 7 Oct 2013 09:32:18 -0700 Subject: [PATCH] If the port ID claims to be interfaceName, use it for lldp_port The LLDP spec says that if lldpRemPortIdSubtype is "interface name", then lldpRemPortId should contain ifName. It doesn't say much about lldpRemPortDesc; some vendors seem to always leave it empty, some use the interface description / ifAlias. Our algorithm for lldp_port is now basically: If we find that lldpRemPortIdSubtype is "interface name", then use the lldpRemPortId, else use lldpRemPortDesc if set, else use lldpRemPortId. --- Info/LLDP.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Info/LLDP.pm b/Info/LLDP.pm index 8a69846f..c6286164 100644 --- a/Info/LLDP.pm +++ b/Info/LLDP.pm @@ -168,10 +168,15 @@ sub lldp_port { my %lldp_port; foreach my $key ( sort keys %$pid ) { my $port = $pdesc->{$key}; + my $type = $ptype->{$key}; + if ( $type and $type eq 'interfaceName' ) { + # If the pid claims to be an interface name, + # believe it. + $port = $pid->{$key}; + } unless ($port) { $port = $pid->{$key}; next unless $port; - my $type = $ptype->{$key}; next unless $type; # May need to format other types in the future, i.e. Network address