From 3f7229f4e7b7afb319366c70036bd0f5c3b72c33 Mon Sep 17 00:00:00 2001 From: Jeroen van Ingen Date: Tue, 24 Jun 2014 17:50:03 +0200 Subject: [PATCH] Cisco Nexus workaround: add probable VPC IP address to device IP address table, determined by checking listening UDP sockets --- Info/Layer3/Nexus.pm | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Info/Layer3/Nexus.pm b/Info/Layer3/Nexus.pm index 03fb75f6..a1dfbcb2 100644 --- a/Info/Layer3/Nexus.pm +++ b/Info/Layer3/Nexus.pm @@ -129,6 +129,12 @@ sub ip_table { $ip_table{$ip} = $ip; } + + my $local_addrs = $nexus->_local_addr(); + foreach my $addr (keys %$local_addrs) { + $ip_table{$addr} = $addr unless exists $ip_table{$addr}; + } + return \%ip_table; } @@ -146,6 +152,12 @@ sub ip_index { $ip_index{$ip} = $index; } + + my $local_addrs = $nexus->_local_addr(); + foreach my $addr (keys %$local_addrs) { + $ip_index{$addr} = 0 unless exists $ip_index{$addr}; + } + return \%ip_index; } @@ -163,6 +175,12 @@ sub ip_netmask { $ip_netmask{$ip} = $netmask; } + + my $local_addrs = $nexus->_local_addr(); + foreach my $addr (keys %$local_addrs) { + $ip_netmask{$addr} = $local_addrs->{$addr} unless exists $ip_netmask{$addr}; + } + return \%ip_netmask; } @@ -180,9 +198,29 @@ sub ip_broadcast { $ip_broadcast{$ip} = $broadcast; } + + my $local_addrs = $nexus->_local_addr(); + foreach my $addr (keys %$local_addrs) { + $ip_broadcast{$addr} = $addr unless exists $ip_broadcast{$addr}; + } + return \%ip_broadcast; } +sub _local_addr { + my $nexus = shift; + my $listen_addr = $nexus->udpLocalAddress() || {}; + my %local_addr; + foreach my $sock (keys %$listen_addr) { + my $addr = $listen_addr->{$sock}; + next if ($addr =~ /^127\./); # localhost + next if ($addr eq '0.0.0.0'); # "any" + next if ($addr =~ /^(\d+)\./ and $1 ge 224); # Class D or E space: Multicast or Experimental + $local_addr{$addr} = '255.255.255.255'; # Fictional netmask + } + return \%local_addr; +} + 1; __END__ @@ -283,6 +321,13 @@ Each entry in this table is an IP address in use on this device. Some versions do not index the table with the IPv4 address in accordance with the MIB definition, these overrides correct that behavior. +Also, the table is augmented with IP addresses in use by UDP sockets on the +device, as determined by checking F. Valid +addresses from this table (any IPv4 that is not localhost, 0.0.0.0, Class D +(multicast) or Class E (experimental) are added as a /32 on interface ID 0. +This is a workaround to determine possible VPC Keepalive IP adresses on the +device, which are probably advertised by CDP/LLDP to neighbors. + =over =item $nexus->ip_index()