[j-nsp] BGP4-MIB-v2

Vincent Bernat bernat at luffy.cx
Fri Jan 20 10:29:45 EST 2017


Hey!

I have been reported a (simple) bug in the implementation of the
BGP4-V2-MIB-JUNIPER. I know that if I open a JTAC case about this, I
will be asked a lot of unrelated questions, then I would be told that
since this never really worked, this is not the scope for JTAC.

So, as I know some Juniper people reads here, here is the bug. I'd be
happy to provide more details if needed.


The MIB says:

    jnxBgpM2PeerEntry OBJECT-TYPE
        SYNTAX     JnxBgpM2PeerEntry
        MAX-ACCESS not-accessible
        STATUS     current
        DESCRIPTION
            "Entry containing information about the connection with
             a remote BGP peer."
        INDEX {
            jnxBgpM2PeerRoutingInstance,
            jnxBgpM2PeerLocalAddrType,
            jnxBgpM2PeerLocalAddr,
            jnxBgpM2PeerRemoteAddrType,
            jnxBgpM2PeerRemoteAddr
        }
        ::= { jnxBgpM2PeerTable 1 }

And jnxBgpM2PeerLocalAddr is:

    jnxBgpM2CfgPeerLocalAddr OBJECT-TYPE
        SYNTAX     InetAddress (SIZE (4..20))
        MAX-ACCESS read-create
        STATUS     current
        DESCRIPTION
            "The address of the local end of the peering session."
        ::= { jnxBgpM2CfgPeerEntry 4 }

(and similar for RemoteAddr). The important bit is the size: variable.

With SNMP, when an index has a variable length, except if it's the last
one _and_ the MIB says the size is IMPLIED, the length should be
prepended to the value.

So, 192.0.2.47 should be encoded to 4.192.0.2.47.

Let's suppose we need to encode:

jnxBgpM2PeerRoutingInstance: 0
jnxBgpM2PeerLocalAddrType: 1 (code for ipv4)
jnxBgpM2PeerLocalAddr: 192.0.2.47
jnxBgpM2PeerRemoteAddrType: 1 (code for ipv4)
jnxBgpM2PeerRemoteAddr: 192.0.2.48

We should have:

0.1.4.192.0.2.47.1.4.192.0.2.48

But JunOS (at least 13.3 and 14.1) is using:

0.1.192.0.2.47.1.192.0.2.48
-- 
Don't comment bad code - rewrite it.
            - The Elements of Programming Style (Kernighan & Plauger)


More information about the juniper-nsp mailing list