Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Jan 2011 14:28:21 +0100
From:      Harti Brandt <hartmut.brandt@dlr.de>
To:        Eugene Grosbein <egrosbein@rdtc.ru>
Cc:        "net@freebsd.org" <net@freebsd.org>
Subject:   Re: bsnmpd: ifTable and if_nametoindex() inconsistency
Message-ID:  <20110124141752.U47002@beagle.kn.op.dlr.de>
In-Reply-To: <4D3B20C0.8090907@rdtc.ru>
References:  <4D3B20C0.8090907@rdtc.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110124141752.U47002>