From dc3d1e0b4639f6446bb88e2bf0a19270b2bec4f9 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 10 Aug 2022 17:32:16 -0400 Subject: [PATCH] avoid error if juniper vlan not in bp_index --- lib/SNMP/Info/Layer3/Juniper.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/SNMP/Info/Layer3/Juniper.pm b/lib/SNMP/Info/Layer3/Juniper.pm index c0dff171..a52d7e24 100644 --- a/lib/SNMP/Info/Layer3/Juniper.pm +++ b/lib/SNMP/Info/Layer3/Juniper.pm @@ -327,7 +327,14 @@ sub i_vlan_membership { foreach my $vlan ( keys %$v_ports ) { my @bp_indexes = split /,/, $v_ports->{$vlan}; - push @{ $res->{ $bp_index->{$_} } }, $vlan for @bp_indexes; + foreach my $idx (@bp_indexes) { + if (!exists $bp_index->{$_}) { + print " VLAN $vlan has no bp_index mapping. Skipping.\n" + if $DEBUG; + next; + } + push @{ $res->{ $bp_index->{$_} } }, $vlan for @bp_indexes; + } } return $res; } @@ -353,7 +360,14 @@ sub i_vlan_membership_untagged { foreach my $vlan ( keys %$v_ports ) { my @bp_indexes = split /,/, $v_ports->{$vlan}; - push @{ $res->{ $bp_index->{$_} } }, $vlan for @bp_indexes; + foreach my $idx (@bp_indexes) { + if (!exists $bp_index->{$_}) { + print " untagged VLAN $vlan has no bp_index mapping. Skipping.\n" + if $DEBUG; + next; + } + push @{ $res->{ $bp_index->{$_} } }, $vlan for @bp_indexes; + } } return $res; }