summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2011-03-07 16:08:00 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2011-03-07 16:08:00 -0800
commit6689df5d9b09d215ec98f0080da5fd5f61f12da8 (patch)
tree8cb0383f96f54db96cf4135410cdc8360db5ae1f /scripts
parent1703a3daba4af98bf64d940988dfb007aef61995 (diff)
downloadvyatta-cfg-system-6689df5d9b09d215ec98f0080da5fd5f61f12da8.tar.gz
vyatta-cfg-system-6689df5d9b09d215ec98f0080da5fd5f61f12da8.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.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/snmp/if-mib-alias24
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";