From d4ae9237a6d29a2759f2f609141cb1c487d8143f Mon Sep 17 00:00:00 2001 From: Jeroen van Ingen Date: Mon, 23 Oct 2017 15:45:04 +0200 Subject: [PATCH] Improve generic Info::Layer3 serial number detection Serial numbers weren't reported for stackable Layer3::H3C devices, even when not actually stacked. Report serial number not only if the entity has no parent, but also if it has a parent but is of type "chassis". This fixes #232. --- Changes | 4 ++++ lib/SNMP/Info/Layer3.pm | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 098606bc..57c852c5 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,10 @@ version 3.38 () * Layer2::Airespace several newer 802.11 data rates added + [BUG FIXES] + + * #232 Improve generic Info::Layer3 serial number detection + version 3.37 (2017-07-11) [ENHANCEMENTS] diff --git a/lib/SNMP/Info/Layer3.pm b/lib/SNMP/Info/Layer3.pm index d7b4d05a..3f3ccae0 100644 --- a/lib/SNMP/Info/Layer3.pm +++ b/lib/SNMP/Info/Layer3.pm @@ -196,10 +196,13 @@ sub serial { my $serial1 = $l3->serial1(); my $e_parent = $l3->e_parent() || {}; + my $e_class = $l3->e_class() || {}; foreach my $iid ( keys %$e_parent ) { my $parent = $e_parent->{$iid}; - if ( $parent eq '0' ) { + my $class = $e_class->{$iid} || ''; + # Only consider serial numbers for entries without a parent, or if they are of type "chassis" + if ( $parent eq '0' or $class eq 'chassis') { my $serial = $l3->e_serial($iid); if ( $serial && $serial->{$iid} ) { return $serial->{$iid};