bsnmpd: ifTable and if_nametoindex() inconsistency
Harti Brandt
hartmut.brandt at dlr.de
Mon Jan 24 13:40:29 UTC 2011
On Sat, 22 Jan 2011, Eugene Grosbein wrote:
EG>I run 8.2-PRERELEASE with bsnmpd and mpd55 serving PPPoE users.
EG>I've noticed that sometimes snmpwalk shows interface indexes
EG>that partially differ from what if_nametoindex(3) returns
EG>with off-by-one or off-by-two. For example, just now this server has
EG>813 connected PPPoE sessions (interfaces named ngXXXX)
EG>and SNMP returns wrong indexes for 567 out of them, starting from ng334.
EG>
EG>I've restarted bsnmpd but this made it worse: now all dynamic ngXXXX
EG>interfaces have obtained new indexes in SNMP ifTable and no one
EG>equals to if_nametoindex(name).
EG>
EG>Aren't these indexes supposed to be equal?
EG>I really need quick method to obtain SNMP index within mpd55 code
EG>(for my local mpd hacks) and if_nametoindex() used to seem nice way...
EG>I need to export indexes via mpd's web interface so that they may be
EG>checked remotely using SNMP.
The problem is that the RFC which defines the ifTable puts some
interesting restrictions on the ifIndex. For example, the same interface
must get the same index if it is removed and inserted again (without the
RFC actually describing what means 'same'). Somewhere in the bsnmp code or
the man page there is a discussion on this. What it does is: it remembers
the ifIndex <-> MAC address mapping and remaps the interface indexes so
that this mapping remains constant. This also means, that an interface
index is never reused for another interface. So, unless you reboot the
system, the same index means always the same interface (identified by MAC
address), which is probably a good thing.
For 'virtual' interfaces of all kinds there is never the same interface -
each interface is a new one and the index is just incremented for each new
interface.
Since I implemented this I'm torn apart whether this is a good idea or
not :-(
harti
More information about the freebsd-net
mailing list