Change the way to retrieve IP address of interface (#1026)
Use by default the ipTable MIB entry to retrieve the IP address of interfaces and fallback to the index method as previously. Fixe the issue with the case where the index is not really an IP address (seen in Fortinet with VDOM). Related to issue #1016
This commit is contained in:
@@ -410,6 +410,7 @@ sub _get_ipv4_aliases {
|
|||||||
my @aliases;
|
my @aliases;
|
||||||
|
|
||||||
my $ip_index = $snmp->ip_index;
|
my $ip_index = $snmp->ip_index;
|
||||||
|
my $ip_table = $snmp->ip_table;
|
||||||
my $interfaces = $snmp->interfaces;
|
my $interfaces = $snmp->interfaces;
|
||||||
my $ip_netmask = $snmp->ip_netmask;
|
my $ip_netmask = $snmp->ip_netmask;
|
||||||
|
|
||||||
@@ -420,6 +421,7 @@ sub _get_ipv4_aliases {
|
|||||||
foreach my $vrf (@vrf_list) {
|
foreach my $vrf (@vrf_list) {
|
||||||
snmp_comm_reindex($snmp, $device, $vrf);
|
snmp_comm_reindex($snmp, $device, $vrf);
|
||||||
$ip_index = { %$ip_index, %{$snmp->ip_index} };
|
$ip_index = { %$ip_index, %{$snmp->ip_index} };
|
||||||
|
$ip_table = { %$ip_table, %{$snmp->ip_table} };
|
||||||
$interfaces = { %$interfaces, %{$snmp->interfaces} };
|
$interfaces = { %$interfaces, %{$snmp->interfaces} };
|
||||||
$ip_netmask = { %$ip_netmask, %{$snmp->ip_netmask} };
|
$ip_netmask = { %$ip_netmask, %{$snmp->ip_netmask} };
|
||||||
}
|
}
|
||||||
@@ -427,7 +429,7 @@ sub _get_ipv4_aliases {
|
|||||||
|
|
||||||
# build device aliases suitable for DBIC
|
# build device aliases suitable for DBIC
|
||||||
foreach my $entry (keys %$ip_index) {
|
foreach my $entry (keys %$ip_index) {
|
||||||
my $ip = NetAddr::IP::Lite->new($entry)
|
my $ip = NetAddr::IP::Lite->new($ip_table->{$entry}) || NetAddr::IP::Lite->new($entry)
|
||||||
or next;
|
or next;
|
||||||
my $addr = $ip->addr;
|
my $addr = $ip->addr;
|
||||||
|
|
||||||
@@ -435,10 +437,10 @@ sub _get_ipv4_aliases {
|
|||||||
next if acl_matches($ip, 'group:__LOOPBACK_ADDRESSES__');
|
next if acl_matches($ip, 'group:__LOOPBACK_ADDRESSES__');
|
||||||
next if setting('ignore_private_nets') and $ip->is_rfc1918;
|
next if setting('ignore_private_nets') and $ip->is_rfc1918;
|
||||||
|
|
||||||
my $iid = $ip_index->{$addr};
|
my $iid = $ip_index->{$entry};
|
||||||
my $port = $interfaces->{$iid};
|
my $port = $interfaces->{$iid};
|
||||||
my $subnet = $ip_netmask->{$addr}
|
my $subnet = $ip_netmask->{$entry}
|
||||||
? NetAddr::IP::Lite->new($addr, $ip_netmask->{$addr})->network->cidr
|
? NetAddr::IP::Lite->new($addr, $ip_netmask->{$entry})->network->cidr
|
||||||
: undef;
|
: undef;
|
||||||
|
|
||||||
debug sprintf ' [%s] device - aliased as %s', $device->ip, $addr;
|
debug sprintf ' [%s] device - aliased as %s', $device->ip, $addr;
|
||||||
|
|||||||
Reference in New Issue
Block a user