Giter VIP home page Giter VIP logo

Comments (4)

SuperQ avatar SuperQ commented on August 30, 2024

Yes, I think this may need to be fixed upstream first.

from snmp_exporter.

nathanlcarlson avatar nathanlcarlson commented on August 30, 2024

I've done some more learning and think this may be more of a bug with Switch B. BITS "types" (not the ANS.1 Bitstring type, but rather an SNMP "construct", https://datatracker.ietf.org/doc/html/rfc1906#section-8 ) are meant to be encoded and reported as the ASN.1 Octet String type. Switch B seems to report the encoding type as 0x03, Bitstring, but then proceed to encode it as an Octet String. Somehow snmpget figures this out though, somewhere in here probably https://github.com/net-snmp/net-snmp/blob/master/snmplib/mib.c#L1809 . It is probably desirable for gosnmp to behave similarly, handling Bitstring as Octet String.

from snmp_exporter.

nathanlcarlson avatar nathanlcarlson commented on August 30, 2024

I'm not great with C, but it looks like this is where ASN Bitstring is parsed: https://github.com/net-snmp/net-snmp/blob/90a70ebd82ae1b545e7a58c1b3eb10981cb85adc/snmplib/asn1.c#L1824 . Doing some tracing on Switch B's output through this makes it seem like that Bitstring parsing code isn't that careful and essentially treats Bitstrings as Octet Strings.

Tracing that function also explains why Switch B reports Bitstring: 03 in the debug output when the actual BITS data is 3E. It is (unintentionally) just reporting 0x03, the Bitstring type code.

from snmp_exporter.

nathanlcarlson avatar nathanlcarlson commented on August 30, 2024

It seems the ASN.1 Bitstring type has no place, officially, in SNMP. Encoding a BITS construct as anything other than an Octet String is incorrect. It just happens to be that netsnmp (kind of) handles it. I'll close this and the other issue as I'm reasonably confident this is simply incorrect behavior from the switch.

from snmp_exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.