From 842ac96d48b0f52add5f0198f8ad219f57c7cce6 Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Wed, 5 Nov 2014 21:07:11 -0500 Subject: [PATCH] Capture port VLANs on Cisco interfaces which are configured for trunking but are not in operational trunking mode --- ChangeLog | 2 ++ Info/CiscoVTP.pm | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 202f5e5b..9f3bf97f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,8 @@ version 3.21 () * [#64] Misdetection: Wireless APs, add products MIB to L2::3Com * Use FDB ID to VID mapping if available to determine end station VLAN rather than assuming they are the same. + * Capture port VLANs on Cisco interfaces which are configured for + trunking but are not in operational trunking mode version 3.20 (2014-09-08) diff --git a/Info/CiscoVTP.pm b/Info/CiscoVTP.pm index 7935902e..b8a19470 100644 --- a/Info/CiscoVTP.pm +++ b/Info/CiscoVTP.pm @@ -149,6 +149,7 @@ sub i_vlan { my $port_vlan = $vtp->vtp_trunk_native($partial) || {}; my $i_vlan = $vtp->i_vlan2($partial) || {}; + my $trunk_dyn = $vtp->vtp_trunk_dyn($partial) || {}; my $trunk_dyn_stat = $vtp->vtp_trunk_dyn_stat($partial) || {}; my %i_vlans; @@ -165,8 +166,17 @@ sub i_vlan { foreach my $port ( keys %$port_vlan ) { my $vlan = $port_vlan->{$port}; next unless defined $vlan; + + # ports up and trunking should have a trunking status my $stat = $trunk_dyn_stat->{$port}; - if ( defined $stat and $stat =~ /^trunking/ ) { + + # vtp_trunk_dyn_stat is not useful for down ports + # so we use vtp_trunk_dyn to see if trunking is set + my $dyn = $trunk_dyn->{$port}; + + if (($stat and $stat =~ /^trunking/ ) + or ($dyn and (($dyn eq 'on') or ($dyn eq 'onNoNegotiate')))) + { $i_vlans{$port} = $vlan; } } @@ -217,6 +227,7 @@ sub i_vlan_membership { my $vtp_vlans = $vtp->v_state(); my $i_vlan = $vtp->i_vlan2($partial) || {}; my $trunk_dyn_stat = $vtp->vtp_trunk_dyn_stat($partial) || {}; + my $trunk_dyn = $vtp->vtp_trunk_dyn($partial) || {}; my $i_vlan_membership = {}; @@ -248,7 +259,9 @@ sub i_vlan_membership { foreach my $port ( keys %$ports_vlans ) { my $stat = $trunk_dyn_stat->{$port}; - if ( defined $stat and $stat =~ /^trunking/ ) { + my $dyn = $trunk_dyn->{$port}; + if (($stat and $stat =~ /^trunking/ ) + or ($dyn and (($dyn eq 'on') or ($dyn eq 'onNoNegotiate')))) { my $k = 0; my $list1 = $ports_vlans->{$port} || '0'; my $list2 = $ports_vlans_2k->{$port} || '0'; @@ -270,6 +283,13 @@ sub i_vlan_membership { return $i_vlan_membership; } +sub i_vlan_membership_untagged { + my $vtp = shift; + my $partial = shift; + + return $vtp->i_vlan($partial); +} + sub set_i_pvid { my $vtp = shift; my ( $vlan_id, $ifindex ) = @_;