This is a discussion on patch for discovery of Non Increasing OIDs in bulkwalk perl within the SNMP Coders forums, part of the Networking and Network Related category; Hello, when polling some Cisco router I discovered that the perl snmp bulkwalk function did not abort bulkwalking when some ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello, when polling some Cisco router I discovered that the perl snmp bulkwalk function did not abort bulkwalking when some of the routers did not increase their OIDs. This patch adds an option 'NonIncreasing' to SNMP::Session->new. If this option is set, an error is return instead of bulkwalking in an never ending loop (making my life miserable :-) Can somebody review and test this patch? [This patch depends on the previous patch for the bus error] Kind regards, Ole Bj=F8rn. rocs3(obh) net-snmp 575$ cat patch.nonincreasing=20 diff -cr net-snmp-5.3.pre4-orig/include/net-snmp/library/snmp_api.h net-snm= p-5.3.pre4-obh/include/net-snmp/library/snmp_api.h *** net-snmp-5.3.pre4-orig/include/net-snmp/library/snmp_api.h Tue Aug 30 = 02:24:45 2005 --- net-snmp-5.3.pre4-obh/include/net-snmp/library/snmp_api.h Tue Nov 22 = 15:57:21 2005 *************** *** 487,494 **** #define SNMPERR_MALLOC (-62) #define SNMPERR_KRB5 (-63) #define SNMPERR_PROTOCOL (-64) =20=20 ! #define SNMPERR_MAX (-64) =20=20 #define non_repeaters errstat #define max_repetitions errindex --- 493,501 ---- #define SNMPERR_MALLOC (-62) #define SNMPERR_KRB5 (-63) #define SNMPERR_PROTOCOL (-64) + #define SNMPERR_OID_NONINCREASING (-65) =20=20 ! #define SNMPERR_MAX (-65) =20=20 #define non_repeaters errstat #define max_repetitions errindex diff -cr net-snmp-5.3.pre4-orig/perl/SNMP/SNMP.pm net-snmp-5.3.pre4-obh/per= l/SNMP/SNMP.pm *** net-snmp-5.3.pre4-orig/perl/SNMP/SNMP.pm Sun Nov 20 22:16:23 2005 --- net-snmp-5.3.pre4-obh/perl/SNMP/SNMP.pm Tue Nov 22 15:16:30 2005 *************** *** 116,121 **** --- 116,123 ---- $best_guess =3D 0; # determine whether or not to enable best-guess regul= ar # expression object name translation. 1 =3D Regex (-Ib= ), # 2 =3D random (-IR) + $non_increasing =3D 0; # stop polling with an "OID not increasing"-error + # when an OID does not increases in bulkwalk. $replace_newer =3D 0; # determine whether or not to tell the parser to re= place # older MIB modules with newer ones when loading MIBs. # WARNING: This can cause an incorrect hierarchy. *************** *** 542,547 **** --- 544,550 ---- $this->{UseSprintValue} =3D $SNMP::use_sprint_value=20 unless exists $this->{UseSprintValue}; $this->{BestGuess} =3D $SNMP::best_guess unless exists $this->{BestGue= ss}; + $this->{NonIncreasing} ||=3D $SNMP::non_increasing; $this->{UseEnums} =3D $SNMP::use_enums unless exists $this->{UseEnums}; $this->{UseNumeric} =3D $SNMP::use_numeric unless exists $this->{UseNu= meric}; =20=20 *************** *** 570,575 **** --- 573,579 ---- $this->{UseSprintValue} =3D $SNMP::use_sprint_value=20 unless exists $this->{UseSprintValue}; $this->{BestGuess} =3D $SNMP::best_guess unless exists $this->{BestGue= ss}; + $this->{NonIncreasing} ||=3D $SNMP::non_increasing; $this->{UseEnums} =3D $SNMP::use_enums unless exists $this->{UseEnums}; $this->{UseNumeric} =3D $SNMP::use_numeric unless exists $this->{UseNu= meric}; =20=20 *************** *** 1524,1529 **** --- 1528,1541 ---- 0 causes a regular lookup. setting to 1 causes a regular expression=20 match (defined as -Ib in snmpcmd) and setting to 2 causes a random=20 access lookup (defined as -IR in snmpcmd). +=20 + =3Ditem NonIncreasing +=20 + defaults to the value of SNMP::non_increasing at time of session + creation. this setting controls if a non-increasing OID during + bulkwalk will causes an error. setting to 0 causes the default + behaviour (which may, in very badly performing agents, result in a never-= ending loop). + setting to 1 causes an error (OID not increasing) when this error occur. =20=20 =3Ditem ErrorStr =20=20 diff -cr net-snmp-5.3.pre4-orig/perl/SNMP/SNMP.xs net-snmp-5.3.pre4-obh/per= l/SNMP/SNMP.xs *** net-snmp-5.3.pre4-orig/perl/SNMP/SNMP.xs Wed Oct 5 14:26:46 2005 --- net-snmp-5.3.pre4-obh/perl/SNMP/SNMP.xs Tue Nov 22 15:11:45 2005 *************** *** 1957,1962 **** --- 1957,1963 ---- SV **err_str_svp =3D hv_fetch((HV*)SvRV(context->sess_ref), "ErrorStr"= , 8, 1); SV **err_num_svp =3D hv_fetch((HV*)SvRV(context->sess_ref), "ErrorNum"= , 8, 1); SV **err_ind_svp =3D hv_fetch((HV*)SvRV(context->sess_ref), "ErrorInd"= , 8, 1); + int check =3D SvIV(*hv_fetch((HV*)SvRV(context->sess_ref), "NonIncrea= sing",13,1)); =20=20 DBPRT(3, (DBOUT "bulkwalk: sess_ref =3D 0x%p, sess_ptr_sv =3D 0x%p\n", context->sess_ref, sess_ptr_sv)); *************** *** 2114,2119 **** --- 2115,2130 ---- context->reqbase[pix].last_oid, context->reqbase[pix].last_len) =3D=3D 0) { + if (check)=20 + { + DBPRT(2, (DBOUT "Error: OID not increasing: %s\n", + snprint_objid(_debugx, sizeof(_debugx), vars->name= ,vars->name_length))); + sv_setpv(*err_str_svp, (char*)snmp_api_errstring(SNMPERR_OID= _NONINCREASING)); + sv_setiv(*err_num_svp, SNMPERR_OID_NONINCREASING); + sv_setiv(*err_ind_svp, pix); + goto err; + } +=20=20=20=20=20=20=20=20=20=20=20=20=20 DBPRT(2, (DBOUT "Ignoring repeat oid: %s\n", snprint_objid(_debugx, sizeof(_debugx), vars->name,= vars->name_length))); =20=20 diff -cr net-snmp-5.3.pre4-orig/snmplib/snmp_api.c net-snmp-5.3.pre4-obh/sn= mplib/snmp_api.c *** net-snmp-5.3.pre4-orig/snmplib/snmp_api.c Wed Nov 16 16:10:19 2005 --- net-snmp-5.3.pre4-obh/snmplib/snmp_api.c Tue Nov 22 14:25:19 2005 *************** *** 298,303 **** --- 298,304 ---- "Out of memory (malloc failure)", /* SNMPERR_MALLOC */ "Kerberos related error", /* SNMPERR_KRB5 */ "Protocol error", /* SNMPERR_PROTOCOL */ + "OID not increasing", /* SNMPERR_OID_NONINCREASING */ }; =20=20 static const char *secLevelName[] =3D { Ole Bj=F8rn Hessen, NMS-IP, PF-Nett, Telenor Networks ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today Register for a JBoss Training Course. Free Certification Exam for All Training Attendees Through End of 2005. For more info visit: http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/...et-snmp-coders |