
On Tue, Nov 03, 2009 at 09:40:50PM +0100, Vincent Bernat wrote:
When a MIB is incomplete (because for example, there is a missing MIB which should have been imported), it is not possible to retrieve nodes that are not resolvable to an OID (which is good). However, it is still possible to retrieve nodes by their name.
For example : $ cat test.mib TEST-MIB DEFINITIONS ::= BEGIN IMPORTS inexistentObject FROM INEXISTENT-MIB; myNode OBJECT IDENTIFIER ::= { inexistentObject 1 } END $ smiquery -p test.mib node TEST-MIB::myNode MibNode: TEST-MIB::myNode OID: 1414743380.1112100141 Declaration: <value-assignment> NodeKind: node
The OID is bogus. Sometimes, libsmi will just segfault.
I am trying to track this down. It seems that you get internally an Object that points to the Node that is marked as incomplete and where the oid has already been freed. The bogus output or the crashes seem to be caused by dereferencing this dead pointer. If you comment
freeNodeTree(parser.pendingNodePtr);
and
smiFree(parser.pendingNodePtr);
in loadModule(), the crash should go away. However, this is not a fix and ideally the library should not return SmiNodes that are broken. My attempts to track down where the inconsistency should be fixed has not been successful yet.
Frank, do you happen to have an idea why the oid pointer goes away or why libsmi returns SmiNodes that point to incomplete OID tree nodes?
If I use smidump, it is able to detect that the MIB is bogus. If I force dump (with -k), it gives me an empty MIB because the bogus node is not added to the list of nodes. smidump detects the problem by looking at "conformance" attribute in smi_module structure. I don't find any documentation about this. Is it the same conformance level as described in smilint(1)? Therefore, if I load a MIB how should I test conformance level?
- (module->conformance) && (module->conformance >= 1)
- (module->conformance) && (module->conformance > 1)
The module->conformance carries the lowest error level that was raised for the module. The value 0 means no error has been raised. Hence, smidump does:
if ((smiModule->conformance) && (smiModule->conformance < 3)) { flags |= SMIDUMP_FLAG_ERROR; if (! (flags & SMIDUMP_FLAG_SILENT)) { fprintf(stderr, "smidump: module `%s' contains errors, " "expect flawed output\n", argv[i]); } }
This is probably generally a good idea if applications do want to be safe against problems originating from bad MIB modules. I have added a sentence to the smi_module.3 manual page explaining the conformance member.
/js