Commit 0981023d authored by Kirk Webb's avatar Kirk Webb
Browse files

Extend the horrible "non-modular" hack in the Cisco snmpit module.

First, a "bug fix": By coincidence the snmpit Cisco module was able to
build up the mod/port-to-ifindex mapping on newer switches where
interface descriptions include a submodule ID (e.g.
"GigabitEthernet1/0/1" vs. "GigabitEthernet1/1"). However, it was
actually just grabbing the submodule ID in place of the module ID.  This
is OK (in some loose sense) for non-modular switches where everything is
effectivley on the same module. Not good for IOS/NX-OS switches with
actual modules and submodule identifiers. Things would not have worked
for these.  As a fix that retains backward compatibility, the Cisco
snmpit module now correctly extracts the module ID, but subtracts '1'
from it.  This allows existing installations that have zero-based module
numbering in their database for non-modular IOS/NX-OS switches with
submodule IDs to continue to work as is.

The above nonsense is not what I set out to do, however, and the commit
just gets worse. I extended the hack for non-modular switches with a mix
of gigabit and ten gigabit to bump any ten gigabit interface port's
module ID to "1". The existing hack already did this for non-modular
switches with a mix of fast Ethernet and gigabit.  Absolutely horrific.
I need a shower.
parent 83718697
......@@ -2083,10 +2083,11 @@ sub readifIndex($) {
foreach my $rowref (@$rows) {
my ($name,$iid,$descr) = @$rowref;
if ($descr =~ /(\D*)(\d+)\/(\d+)$/) {
if ($descr =~ /(\D*)(\d+)\/(\d+)(\/(\d+))?$/) {
my $hassubmod = defined($4) ? 1 : 0;
my $type = $1;
my $module = $2;
my $port = $3;
my $module = $hassubmod ? int($2)-1 : $2; # XXX: disgusting backward compat
my $port = $hassubmod ? $5 : $3;
$self->debug("IFINDEX: $descr ($type,$module,$port)\n", 2);
......@@ -2095,10 +2096,15 @@ sub readifIndex($) {
# Hack for non-modular switches with both 100Mbps and
# gigabit ports - consider gigabit ports to be on module 1
#
if (($module == 0) && ($type =~ /^gi/i)) {
if (!$hassubmod && ($module == 0) && ($type =~ /^gi/i)) {
$module = 1;
$self->debug("NON_MODULAR_HACK: Moving $descr to mod $module\n");
}
# XXX: Horrible hack for gi/te port mix on, e.g., 2960-ios
elsif ($hassubmod && ($module == 0) && ($type =~ /^te/i)) {
$module = 1;
$self->debug("NON_MODULAR_HACK: Moving $descr to mod $module\n");
}
}
my $modport = "$module.$port";
my $ifindex;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment