#1278 Bugfix for bulk gets in SNMP.pm



We've been using SNMP.pm to pull out various tables from our switches into
our home-grown network management system. However, there's one thing that's
been causing issues for us for a long time, and that's getting the LLDP
tables (lldpRemTable).

The basic issues is that the values, at least when you query Cisco equipment,
tends to be so big that the packets get truncated. There's logic to try to
estimate the result size in the module and scale back accordingly on the
number of repetitions, but it fails in this case because the average value is
so big (it typically contains the entire “show ver” for the remote device).
This causes “ack: gettable results not appropriate”, even the results are
fully appropriate. (We've been turning off bulk gets, but it's not an ideal
solution, and in any case, it can still fail in the same way, it just needs
bigger values to do so.)

The attached patch (in context diff, because unified diff became unusually
unreadable!) first rewrites _gettable_do_it to be a bit less $#{$ everywhere
(so that I could understand it myself :-) ), and then fixes so that it
properly deals with a truncated response: For each value returned, the right
varbind is advanced, and the decision of which ones to keep querying is
delayed until the very end.

We've queried a variety of equipment we've got around (mostly Cisco and HP,
though), and this seems to fix the issue for us. Would you consider this for
inclusion in a future version?


1 Attachments


  • I found a small mistake in the patch, that can cause a warning (and seemingly sometimes make the entire thing segfault; SNMP.xs isn't very forgiving!). $vbl can seemingly sometimes be undef at the very end, and then scalar @$vbls of course won't work. (Curiously enough, $#$vbls, as used in the old version, actually returns -1.) Simply change the $num_vbls line to

    my $num_vbls = defined($vbl) ? scalar @$vbl : 0;