ports/159252: net-mgmt/net-snmp 5.7 "Cannot find module" (SNMPv2-SMI) noise

Tacid tacid at tacid.kiev.ua
Thu Jul 28 10:00:26 UTC 2011


>Number:         159252
>Category:       ports
>Synopsis:       net-mgmt/net-snmp 5.7 "Cannot find module" (SNMPv2-SMI) noise
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 28 10:00:21 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Tacid
>Release:        7.4-RELEASE
>Organization:
Asters
>Environment:
FreeBSD example.com 7.4-RELEASE FreeBSD 7.4-RELEASE #0: Thu Feb 17 03:51:56 UTC 2011     root at walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
After update to 5.7 using snmp will cause some "cannot find module" noise, for examle:

> snmpget -v2c -c public localhost SNMPv2-MIB::sysDescr.0
MIB search path: /home/cgenybr/.snmp/mibs:/usr/local/share/snmp/mibs
Cannot find module (SNMPv2-SMI): At line 6 in /usr/local/share/snmp/mibs/SCTP-MIB.txt
Cannot find module (SNMPv2-TC): At line 8 in /usr/local/share/snmp/mibs/SCTP-MIB.txt
Cannot find module (INET-ADDRESS-MIB): At line 12 in /usr/local/share/snmp/mibs/SCTP-MIB.txt
Cannot find module (SCTP-MIB): At line 1 in (none)
Cannot find module (SNMPv2-MIB): At line 1 in (none)
Cannot find module (IANAifType-MIB): At line 13 in /usr/local/share/snmp/mibs/IF-MIB.txt
Cannot find module (IF-MIB): At line 1 in (none)
Cannot find module (IP-MIB): At line 1 in (none)
Cannot find module (TCP-MIB): At line 1 in (none)
Cannot find module (UDP-MIB): At line 1 in (none)
Cannot find module (HOST-RESOURCES-MIB): At line 1 in (none)
Cannot find module (SNMP-FRAMEWORK-MIB): At line 11 in /usr/local/share/snmp/mibs/NOTIFICATION-LOG-MIB.txt
Cannot find module (NOTIFICATION-LOG-MIB): At line 1 in (none)
Cannot find module (SNMP-TARGET-MIB): At line 14 in /usr/local/share/snmp/mibs/DISMAN-EVENT-MIB.txt
Cannot find module (DISMAN-EVENT-MIB): At line 1 in (none)
Cannot find module (DISMAN-SCHEDULE-MIB): At line 1 in (none)
Cannot find module (UCD-SNMP-MIB): At line 1 in (none)
Cannot find module (UCD-DEMO-MIB): At line 1 in (none)
Cannot find module (NET-SNMP-MIB): At line 12 in /usr/local/share/snmp/mibs/NET-SNMP-AGENT-MIB.txt
Cannot find module (NET-SNMP-AGENT-MIB): At line 1 in (none)
Cannot find module (HOST-RESOURCES-TYPES): At line 1 in (none)
Cannot find module (SNMP-MPD-MIB): At line 1 in (none)
Cannot find module (SNMP-USER-BASED-SM-MIB): At line 1 in (none)
Cannot find module (SNMP-VIEW-BASED-ACM-MIB): At line 1 in (none)
Cannot find module (SNMP-COMMUNITY-MIB): At line 1 in (none)
Cannot find module (NET-SNMP-EXAMPLES-MIB): At line 11 in /usr/local/share/snmp/mibs/NET-SNMP-PASS-MIB.txt
Cannot find module (NET-SNMP-PASS-MIB): At line 1 in (none)
Cannot find module (NET-SNMP-EXTEND-MIB): At line 1 in (none)
Cannot find module (UCD-DLMOD-MIB): At line 1 in (none)
Cannot find module (SNMP-NOTIFICATION-MIB): At line 1 in (none)
Cannot find module (SNMPv2-TM): At line 1 in (none)
Cannot find module (NET-SNMP-VACM-MIB): At line 1 in (none)
SNMPv2-MIB::sysDescr.0 = STRING: shevdid.com 4266707402 FreeBSD 7.4-RELEASE


Problem discussion here: http://www.mail-archive.com/net-snmp-users@lists.sourceforge.net/msg28230.html

Patch and description found here: http://sourceforge.net/tracker/?func=detail&aid=3362233&group_id=12694&atid=312694
(copied details)

In 5.5, the behavior when starting up snmpd, doing a walk, etc was less noisy than in 5.7. This is due to a side effect introduced via r20472 -- in particular the fact that there are some SMIs like SNMPv2-SMI return NULL via parse (this is wrong given the definition of this MIB file, but everything works later on when doing an snmp operation with the MIBs specified).

 So instead of falling back to MODULE_NOT_FOUND in read_module_internal, the following returns an appropriate value according to gMibError, and also extends gMibError to cover error cases in parse.

 Later on things should ultimately be cleaned up so that the silent 'parsing' error is properly resolved in the SMI, whether it be by redefining the SMI to include all of the necessary symbols or a proper code change to accommodate the parsing discrepancies in the file.
>How-To-Repeat:
update to net-snmp 5.7 and run
> snmpget -v2c -c public localhost SNMPv2-MIB::sysDescr.0

>Fix:


Patch attached with submission follows:

--- snmplib/parse.c
+++ snmplib/parse.c
@@ -3902,8 +3902,13 @@ read_module_internal(const char *name)
                 return MODULE_ALREADY_LOADED;
             }
             if ((fp = fopen(mp->file, "r")) == NULL) {
+                int rval;
+                if (errno == ENOTDIR || errno == ENOENT)
+                    rval = MODULE_NOT_FOUND;
+                else
+                    rval = MODULE_LOAD_FAILED;
                 snmp_log_perror(mp->file);
-                return MODULE_LOAD_FAILED;
+                return rval;
             }
             mp->no_imports = 0; /* Note that we've read the file */
             File = mp->file;
@@ -3917,10 +3922,7 @@ read_module_internal(const char *name)
             File = oldFile;
             mibLine = oldLine;
             current_module = oldModule;
-            if (np != NULL)
-                return MODULE_LOADED_OK;
-            else if (gMibError == MODULE_SYNTAX_ERROR) 
-                return MODULE_SYNTAX_ERROR;
+            return gMibError ? gMibError : MODULE_LOADED_OK;
         }
 
     return MODULE_NOT_FOUND;
@@ -4339,6 +4341,7 @@ parse(FILE * fp, struct node *root)
         case END:
             if (state != IN_MIB) {
                 print_error("Error, END before start of MIB", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             } else {
                 struct module  *mp;
@@ -4403,6 +4406,7 @@ parse(FILE * fp, struct node *root)
                 nnp = parse_macro(fp, name);
                 if (nnp == NULL) {
                     print_error("Bad parse of MACRO", NULL, type);
+                    gMibError = MODULE_SYNTAX_ERROR;
                     /*
                      * return NULL;
                      */
@@ -4427,6 +4431,7 @@ parse(FILE * fp, struct node *root)
                 type = get_token(fp, token, MAXTOKEN);
             if (type == ENDOFFILE) {
                 print_error("Expected \"}\"", token, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             type = get_token(fp, token, MAXTOKEN);
@@ -4436,6 +4441,7 @@ parse(FILE * fp, struct node *root)
         case DEFINITIONS:
             if (state != BETWEEN_MIBS) {
                 print_error("Error, nested MIBS", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             state = IN_MIB;
@@ -4460,6 +4466,7 @@ parse(FILE * fp, struct node *root)
             nnp = parse_objecttype(fp, name);
             if (nnp == NULL) {
                 print_error("Bad parse of OBJECT-TYPE", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             break;
@@ -4467,6 +4474,7 @@ parse(FILE * fp, struct node *root)
             nnp = parse_objectgroup(fp, name, OBJECTS, &objects);
             if (nnp == NULL) {
                 print_error("Bad parse of OBJECT-GROUP", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             break;
@@ -4474,6 +4482,7 @@ parse(FILE * fp, struct node *root)
             nnp = parse_objectgroup(fp, name, NOTIFICATIONS, &notifs);
             if (nnp == NULL) {
                 print_error("Bad parse of NOTIFICATION-GROUP", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             break;
@@ -4481,6 +4490,7 @@ parse(FILE * fp, struct node *root)
             nnp = parse_trapDefinition(fp, name);
             if (nnp == NULL) {
                 print_error("Bad parse of TRAP-TYPE", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             break;
@@ -4488,6 +4498,7 @@ parse(FILE * fp, struct node *root)
             nnp = parse_notificationDefinition(fp, name);
             if (nnp == NULL) {
                 print_error("Bad parse of NOTIFICATION-TYPE", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             break;
@@ -4495,6 +4506,7 @@ parse(FILE * fp, struct node *root)
             nnp = parse_compliance(fp, name);
             if (nnp == NULL) {
                 print_error("Bad parse of MODULE-COMPLIANCE", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             break;
@@ -4502,6 +4514,7 @@ parse(FILE * fp, struct node *root)
             nnp = parse_capabilities(fp, name);
             if (nnp == NULL) {
                 print_error("Bad parse of AGENT-CAPABILITIES", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             break;
@@ -4509,6 +4522,7 @@ parse(FILE * fp, struct node *root)
             nnp = parse_macro(fp, name);
             if (nnp == NULL) {
                 print_error("Bad parse of MACRO", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 /*
                  * return NULL;
                  */
@@ -4520,6 +4534,7 @@ parse(FILE * fp, struct node *root)
             nnp = parse_moduleIdentity(fp, name);
             if (nnp == NULL) {
                 print_error("Bad parse of MODULE-IDENTITY", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             break;
@@ -4527,6 +4542,7 @@ parse(FILE * fp, struct node *root)
             nnp = parse_objectgroup(fp, name, OBJECTS, &objects);
             if (nnp == NULL) {
                 print_error("Bad parse of OBJECT-IDENTITY", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             break;
@@ -4534,16 +4550,19 @@ parse(FILE * fp, struct node *root)
             type = get_token(fp, token, MAXTOKEN);
             if (type != IDENTIFIER) {
                 print_error("Expected IDENTIFIER", token, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             type = get_token(fp, token, MAXTOKEN);
             if (type != EQUALS) {
                 print_error("Expected \"::=\"", token, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             nnp = parse_objectid(fp, name);
             if (nnp == NULL) {
                 print_error("Bad parse of OBJECT IDENTIFIER", NULL, type);
+                gMibError = MODULE_SYNTAX_ERROR;
                 return NULL;
             }
             break;
@@ -4555,6 +4574,7 @@ parse(FILE * fp, struct node *root)
             break;
         default:
             print_error("Bad operator", token, type);
+            gMibError = MODULE_SYNTAX_ERROR;
             return NULL;
         }
         if (nnp) {


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list