diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2011-03-07 16:08:00 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2011-03-16 12:25:03 -0700 |
commit | 5efcff83be5b97ef99731f8da1eab5f1a51cca0d (patch) | |
tree | 8229644829bd99e03432646fc51160ca9afa14c8 | |
parent | f527c078e1f175a078784c5b10d5539af20dcda0 (diff) | |
download | vyatta-cfg-system-5efcff83be5b97ef99731f8da1eab5f1a51cca0d.tar.gz vyatta-cfg-system-5efcff83be5b97ef99731f8da1eab5f1a51cca0d.zip |
Fix SNMP ifAlias for more than 10 devices
Bug 6853
Handle OID format when ifIndex is 10 or greater.
Needed to fix regex parsing.
Also allow symbolic OID.
(cherry picked from commit 6689df5d9b09d215ec98f0080da5fd5f61f12da8)
-rwxr-xr-x | scripts/snmp/if-mib-alias | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/scripts/snmp/if-mib-alias b/scripts/snmp/if-mib-alias index d8b3ea9f..d17644e9 100755 --- a/scripts/snmp/if-mib-alias +++ b/scripts/snmp/if-mib-alias @@ -24,20 +24,20 @@ use strict; use warnings; use feature "switch"; -# Collect interface alias values +# Collect interface all alias values sub get_alias { my @interfaces; open (my $ip, '-|', 'ip li') - or die "Can't run ip command\n"; + or die "Can't run ip command\n"; my $index; while(<$ip>) { - if (/^(\d+): ([^:]*): /) { - $index = $1; - $interfaces[$index] = $2; - } elsif (/^ +alias (.*)$/) { - $interfaces[$index] = $1; - } + if (/^(\d+): ([^:]*): /) { + $index = $1; + $interfaces[$index] = $2; + } elsif (/^ +alias (.*)$/) { + $interfaces[$index] = $1; + } } close $ip; return @interfaces; @@ -46,7 +46,8 @@ sub get_alias { sub get_oid { my $oid = shift; die "Not a valid Object ID: $oid" - unless ($oid =~ /^[0-9.]*\.(\d)$/); + unless ($oid =~ /.(\d+)$/); + my $ifindex = $1; my @interfaces = get_alias(); @@ -54,6 +55,7 @@ sub get_oid { print "$oid\nstring\n$ifalias\n" if $ifalias; } +# OID of ifAlias [RFC2863] my $BASE = '.1.3.6.1.2.1.31.1.1.1.18'; sub get_next { @@ -63,7 +65,7 @@ sub get_next { if ($oid eq $BASE); die "Not a valid Object ID: $oid" - unless ($oid =~ /^([0-9.]*)\.(\d+)$/); + unless ($oid =~ /^(\S*)\.(\d+)$/); my $base = $1; my $ifindex = $2; @@ -94,7 +96,7 @@ sub ifindextoname { sub set_oid { my ($oid, $target, $value) = @_; die "Not a valid Object ID: $oid" - unless ($oid =~ /^[0-9.]*\.(\d)$/); + unless ($oid =~ /\.(\d+)$/); my $ifindex = $1; unless ($target eq 'string') { print "wrong-type\n"; |