From 55b2a27f4051093134b1fec5c6256d3d4d8252e8 Mon Sep 17 00:00:00 2001 From: Eric Miller <> Date: Wed, 5 Apr 2006 02:30:17 +0000 Subject: [PATCH] check for unreachable root ip before assignment --- Info/Layer3/BayRS.pm | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Info/Layer3/BayRS.pm b/Info/Layer3/BayRS.pm index a37c5e62..0fba5ec1 100644 --- a/Info/Layer3/BayRS.pm +++ b/Info/Layer3/BayRS.pm @@ -317,23 +317,17 @@ sub root_ip { my $idx = $ip_index->{$entry}; next unless $idx == 0; my $clip = $ip_table->{$entry}; - next unless ((defined $clip) and ($clip eq '0.0.0.0')); + next unless ( (defined $clip) and ($clip eq '0.0.0.0') and ($bayrs->_snmp_connect_ip($clip)) ); print " SNMP::Layer3::BayRS::root_ip() using $clip\n" if $bayrs->debug(); return $clip; } # Check for OSPF Router ID my $ospf_ip = $bayrs->ospf_rtr_id(); - if ((defined $ospf_ip) and ($ospf_ip ne '0.0.0.0')) { + if ((defined $ospf_ip) and ($ospf_ip ne '0.0.0.0') and ($bayrs->_snmp_connect_ip($ospf_ip)) ) { print " SNMP::Layer3::BayRS::root_ip() using $ospf_ip\n" if $bayrs->debug(); return $ospf_ip; } - # Else Return First IP Address - foreach my $entry (keys %$ip_table){ - my $ip = $ip_table->{$entry}; - print " SNMP::Layer3::BayRS::root_ip() using $ip\n" if $bayrs->debug(); - next unless $ip; - return $ip if ($ip ne '0.0.0.0'); - } + return undef; } @@ -459,8 +453,7 @@ Returns (B) after conversion to ASCII decimal Returns the primary IP used to communicate with the router. -Returns the first found: CLIP (CircuitLess IP), (B), or the first -IP interface. +Returns the first found: CLIP (CircuitLess IP), (B), or undefined. =back