From owner-freebsd-net@FreeBSD.ORG Mon Jan 24 13:40:29 2011 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4EE89106566B for ; Mon, 24 Jan 2011 13:40:29 +0000 (UTC) (envelope-from Hartmut.Brandt@dlr.de) Received: from smtp4.dlr.de (smtp3.dlr.de [129.247.252.33]) by mx1.freebsd.org (Postfix) with ESMTP id DAB8C8FC15 for ; Mon, 24 Jan 2011 13:40:28 +0000 (UTC) Received: from DLREXHUB01.intra.dlr.de ([172.21.152.130]) by smtp4.dlr.de with Microsoft SMTPSVC(6.0.3790.4675); Mon, 24 Jan 2011 14:28:24 +0100 Received: from beagle.kn.op.dlr.de (129.247.178.136) by smtp.dlr.de (172.21.152.151) with Microsoft SMTP Server (TLS) id 14.1.270.1; Mon, 24 Jan 2011 14:28:23 +0100 Date: Mon, 24 Jan 2011 14:28:21 +0100 From: Harti Brandt X-X-Sender: brandt_h@beagle.kn.op.dlr.de To: Eugene Grosbein In-Reply-To: <4D3B20C0.8090907@rdtc.ru> Message-ID: <20110124141752.U47002@beagle.kn.op.dlr.de> References: <4D3B20C0.8090907@rdtc.ru> X-OpenPGP-Key: harti@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [129.247.178.136] X-OriginalArrivalTime: 24 Jan 2011 13:28:24.0243 (UTC) FILETIME=[937D2030:01CBBBCA] Cc: "net@freebsd.org" Subject: Re: bsnmpd: ifTable and if_nametoindex() inconsistency X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Harti Brandt List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jan 2011 13:40:29 -0000 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