netdisco / netdisco-mibs

82 stars 88 forks source link

RFC Mibs referencing invalid names #182

Closed Jellyfrog closed 1 year ago

Jellyfrog commented 2 years ago

Hi,

Since you guys like fixing broken MIBs I wonder what your opinion on the following is: https://github.com/netdisco/netdisco-mibs/blob/b74938a41566893bf24463b2a8c6707fde3d3318/rfc/DNS-SERVER-MIB.txt#L5 https://github.com/netdisco/netdisco-mibs/blob/4dab432443e687d61f660d8d2825bdf5f3e940a8/rfc/CLNS-MIB.txt#L7 But in RFC1213 we got the name RFC1213-MIB: https://github.com/netdisco/netdisco-mibs/blob/b74938a41566893bf24463b2a8c6707fde3d3318/rfc/RFC1213-MIB.txt#L1 ie. RFC-1213 != RFC1213-MIB... Should it be patched? Is it even wrong? Or am I misunderstanding something?

JeroenvIS commented 2 years ago

Nice find! I believe this is indeed wrong in the DNS-SERVER-MIB and CLNS-MIB; perhaps because the inconsistency in naming with several other contemporary RFC numbered MIBs wasn't noticed.

I now wonder why we never saw this before. How did you notice this?

Jellyfrog commented 2 years ago

There are others also, but thought I start with one of them...

I used this tool; https://github.com/etingof/pysmi

~/.local/bin/mibdump.py --mib-borrower=false --destination-format=json --generate-mib-texts --no-dependencies --mib-source=/var/lib/snmp/mibs/ietf/ DNS-SERVER-MIB
Source MIB repositories: /var/lib/snmp/mibs/ietf/
Borrow missing/failed MIBs from:
Existing/compiled MIB locations:
Compiled MIBs destination directory: .
MIBs excluded from code generation: RFC-1212, RFC-1215, RFC1065-SMI, RFC1155-SMI, RFC1158-MIB, RFC1213-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, SNMPv2-TM
MIBs to compile: DNS-SERVER-MIB
Destination format: json
Custom destination template: None
Parser grammar cache directory: not used
Also compile all relevant MIBs: no
Rebuild MIBs regardless of age: no
Dry run mode: no
Create/update MIBs: yes
Byte-compile Python modules: no (optimization level no)
Ignore compilation errors: no
Generate OID->MIB index: no
Generate texts in MIBs: yes
Keep original texts layout: no
Try various file names while searching for MIB module: yes
Created/updated MIBs:
Pre-compiled MIBs borrowed:
Up to date MIBs: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC
Missing source MIBs: RFC-1213
Ignored MIBs:
Failed MIBs: DNS-SERVER-MIB (no module "RFC-1213" in symbolTable at MIB DNS-SERVER-MIB)
ollyg commented 2 years ago

seems the net-snmp tools are 'smart' enough to spot the error and work around it...?

here I do a test and you can see the error message (with -Pw option) says what it's doing:

% snmptranslate -Le -Pw -m 'CLNS-MIB' bork
OBJECT-TYPE MACRO (lines 25..39 parsed and ignored).
Importing PhysAddress from replacement module RFC1213-MIB instead of RFC-1213 (/Users/oliver/git/netdisco-mibs/rfc/CLNS-MIB.txt)
MODULE-IDENTITY MACRO (lines 55..79 parsed and ignored).
OBJECT-IDENTITY MACRO (lines 81..103 parsed and ignored).
OBJECT-TYPE MACRO (lines 212..298 parsed and ignored).
NOTIFICATION-TYPE MACRO (lines 302..334 parsed and ignored).
bork: Unknown Object Identifier (Sub-id not found: (top) -> bork)

i.e. replacement module RFC1213-MIB instead of RFC-1213

I'll look at updating our testload script to catch this (and maybe ignore the MACRO things there, dunno what they are).

ollyg commented 2 years ago

re: MACRO errors. Per this thread https://sourceforge.net/p/net-snmp/mailman/net-snmp-users/thread/3EEDF5B7.7030401%40uregina.ca/#msg15553708

They can be safely ignored. They show up because you have set mibWarningLevel 1 in your snmp.conf file, but they are more of a debugging message, so they should probably be moved to that category.

However -Pw is mibWarningLevel 1 (and -PW is mibWarningLevel 2). So net-snmp has cosmetic error (MACRO) mixed in with arguably real error (MIB not found?!) at mibWarningLevel 1. Perhaps worth raising with net-snmp crew.

ollyg commented 2 years ago

OK per this thread https://sourceforge.net/p/net-snmp/mailman/message/5581783/

We should be safe to have -Pw enabled and then filter out MACRO warnings from the output:

It's because the parser already has internal definitions of the SMI macros. Therefore when it sees a macro definition of any kind, it just ignores it, printing out a polite note if you asked it to.

ollyg commented 2 years ago

ah, it could just be these errors come from module loading order (and might explain why net-snmp sees as warning rather than critical).

✘ Errors from CLNS-MIB in rfc/CLNS-MIB.txt
Importing PhysAddress from replacement module RFC1213-MIB instead of RFC-1213
✘ Errors from DIRECTORY-SERVER-MIB in rfc/DIRECTORY-SERVER-MIB.txt
Importing DisplayString from replacement module RFC1213-MIB instead of RFC1158-MIB

In the example above, RFC1213-MIB has overridden not only its namesake RFC-1213 but also RFC1158-MIB.

ollyg commented 2 years ago

(yes, we should/could still rename RFC-1213-MIB to RFC1213 though!)

ollyg commented 1 year ago

Many thanks @Jellyfrog ! Closing this as I believe we've now patched our import/sanity-check scripts to catch such issues.