From owner-freebsd-net@FreeBSD.ORG Mon Apr 19 11:09:14 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 656DF16A4CE; Mon, 19 Apr 2004 11:09:14 -0700 (PDT) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5583043D41; Mon, 19 Apr 2004 11:09:14 -0700 (PDT) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.9p1/8.12.8) with ESMTP id i3JI9Cgd071974; Mon, 19 Apr 2004 11:09:12 -0700 (PDT) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.9p1/8.12.3/Submit) id i3JI9CCh071973; Mon, 19 Apr 2004 11:09:12 -0700 (PDT) (envelope-from rizzo) Date: Mon, 19 Apr 2004 11:09:12 -0700 From: Luigi Rizzo To: net@freebsd.org, jlemon@freebsd.org Message-ID: <20040419110912.A71274@xorpc.icir.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Subject: 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:09:14 -0000 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. 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. cheers luigi