From dcf2c0ee54460a6205c98cb6851558cb12cdf3f0 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 10 Aug 2022 09:17:31 +0100 Subject: [PATCH] #468 Cisco dotted subinterfaces had incorrect vlan assigned --- Changes | 6 ++++++ lib/SNMP/Info/Layer3/Cisco.pm | 24 +++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index 3a0911c1..5ca4cac0 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +Version 3.86 (2022-08-10) + + [BUG FIXES] + + * #468 Cisco dotted subinterfaces had incorrect vlan assigned + Version 3.85 (2022-08-02) [NEW FEATURES] diff --git a/lib/SNMP/Info/Layer3/Cisco.pm b/lib/SNMP/Info/Layer3/Cisco.pm index a43bf15e..4996871b 100644 --- a/lib/SNMP/Info/Layer3/Cisco.pm +++ b/lib/SNMP/Info/Layer3/Cisco.pm @@ -116,6 +116,9 @@ $VERSION = '3.85'; %SNMP::Info::CiscoVTP::MUNGE, ); + +# the i_vlan in SUPER is just fine; this exists to catch any dotted vlan +# subinterfaces not caught by CiscoVTP sub i_vlan { my $cisco = shift; my $partial = shift; @@ -126,18 +129,17 @@ sub i_vlan { foreach my $idx ( keys %$i_descr ) { next unless $i_type->{$idx}; - if ( $i_type->{$idx} eq 'l2vlan' - || $i_type->{$idx} eq '135' && !defined $i_vlan->{$idx} ) - { - # Not sure where this regex came from, anchored at end? - if ( $i_descr->{$idx} =~ /\.(\d+)$/ ) { - $i_vlan->{$idx} = $1; - } + next unless (($i_type->{$idx} eq 'l2vlan' or $i_type->{$idx} eq '135') + and !defined $i_vlan->{$idx}); - # This matches 101 in 'Ethernet0.101-802.1Q vLAN subif' - elsif ( $i_descr->{$idx} =~ /\.(\d+)-/ ) { - $i_vlan->{$idx} = $1; - } + # Not sure where this regex came from, anchored at end? + if ( $i_descr->{$idx} =~ /\.(\d+)$/ ) { + $i_vlan->{$idx} = $1; + } + + # This matches 101 in 'Ethernet0.101-802.1Q vLAN subif' + elsif ( $i_descr->{$idx} =~ /\.(\d+)-/ ) { + $i_vlan->{$idx} = $1; } } return $i_vlan;