From owner-freebsd-net@FreeBSD.ORG Mon Apr 19 11:33:17 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A6A6716A4CE; Mon, 19 Apr 2004 11:33:17 -0700 (PDT) Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8CF6643D1F; Mon, 19 Apr 2004 11:33:17 -0700 (PDT) (envelope-from brdavis@odin.ac.hmc.edu) Received: from odin.ac.hmc.edu (IDENT:brdavis@localhost.localdomain [127.0.0.1]) by odin.ac.hmc.edu (8.12.10/8.12.3) with ESMTP id i3JIXHjU017558; Mon, 19 Apr 2004 11:33:17 -0700 Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.12.10/8.12.3/Submit) id i3JIXH4V017555; Mon, 19 Apr 2004 11:33:17 -0700 Date: Mon, 19 Apr 2004 11:33:17 -0700 From: Brooks Davis To: Luigi Rizzo Message-ID: <20040419183316.GE8967@Odin.AC.HMC.Edu> References: <20040419110912.A71274@xorpc.icir.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pQhZXvAqiZgbeUkD" Content-Disposition: inline In-Reply-To: <20040419110912.A71274@xorpc.icir.org> User-Agent: Mutt/1.5.4i cc: net@freebsd.org Subject: Re: what is the story on if_index allocation ? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Apr 2004 18:33:17 -0000 --pQhZXvAqiZgbeUkD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 19, 2004 at 11:09:12AM -0700, Luigi Rizzo wrote: >=20 > I am a bit unclear -- how do we allocate if_index values for > network interfaces ? > I thought the strategy was allocate them sequentially, and > only reuse numbers at the top of the allocated range. > But then i see if_findindex() is quite complicated, and > seems to look for hints using resource_string_value() and > resource_find_dev() to possibly recycle old indexes below > if_index. >=20 > Can someone explain what is the goal ? Reuse a number if an > interface has the same name of a previously existing one and > the index is free ? And does it make sense, anyways, or > we could just simplify that code and just reuse the first > available entry in ifindex_table[] ? > Even the current allocation strategy does not guarantee that > indexes reflect the order of creation of interfaces, if that > is what we care about. harti recently mentioned that the SNMP RFC requires that interfaces keep the same index across various events including loading and unloading the driver. I suspect this code is an attempt to handle that case. Keying off of lladdrs is probably as close as you're going to get to obeying that requirement in the kernel. I'm not convinced we should worry about it in the kernel. The whole concept of the "same interface" is rather dependent on the particular application context. For instance, when dealing with virtual interfaces on a tunnel server, interfaces could be created and destroyed on demand and if you wanted to do accounting via SNMP indexs should be consistant for each account. I'm tempted to push the whole problem off to userland where appropriate application dependent policies can be implemented. -- Brooks --=20 Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 --pQhZXvAqiZgbeUkD Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFAhBtsXY6L6fI4GtQRArXyAJ9fbT/XEK+6ygu4A2E4yyx0XE0w1ACeNzIX 0gTVURU9MZuC8iAy0jA/PI4= =JMWr -----END PGP SIGNATURE----- --pQhZXvAqiZgbeUkD--