From owner-freebsd-net@FreeBSD.ORG Mon May 26 14:04:20 2003 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 7095337B401 for ; Mon, 26 May 2003 14:04:20 -0700 (PDT) Received: from mta5.snfc21.pbi.net (mta5.snfc21.pbi.net [206.13.28.241]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0AA9543F85 for ; Mon, 26 May 2003 14:04:20 -0700 (PDT) (envelope-from mbsd@pacbell.net) Received: from atlas ([64.165.199.230])(built Oct 18net@freebsd.org; Mon, 26 May 2003 14:04:19 -0700 (PDT) Date: Mon, 26 May 2003 14:04:19 -0700 (PDT) From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= In-reply-to: <3ED1CB03.8010005@fsn.hu> X-X-Sender: mikko@atlas.home To: Attila Nagy Message-id: <20030526135441.U326@atlas.home> MIME-version: 1.0 Content-type: TEXT/PLAIN; charset=US-ASCII Content-transfer-encoding: 7BIT References: <20030526010717.98E8391682@vineyard.net> <3ED1CB03.8010005@fsn.hu> cc: net@freebsd.org Subject: Re: A problem with too many network interfaces 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, 26 May 2003 21:04:20 -0000 On Mon, 26 May 2003, Attila Nagy wrote: > Eric W.Bates wrote: > > I'm trying to build a router/filter on FreeBSD 4.8 with 4 real NIC and > > 32 vlan interfaces. > > Starting dhcpd generates an error after 15 interfaces: > > "[interface] not found" > > My C skills are lacking so while I'm grovelling thru dhcpd source to > > find the problem; I was wondering if anyone knows of a kernel limit I > > need to increase? > It has nothing to do with FreeBSD. It sort-of has... See below. > Take a look at common/discover.c to find the following code snippet: > > void discover_interfaces (state) > int state; > { > struct interface_info *tmp, *ip; > struct interface_info *last, *next; > char buf [2048]; > ^^^^ > Increase the size of buf for example to 32768 and it will work. Any static size will be too small at some point. Note how the code has some hacks to resize the buffer for certain cases (mainly for assorted Linux flavors, by the look of it). But there is no handling of the BSD behavior of silently truncating the result if it won't fit, nor to handle OSes that return an error. A proper BSD port could use something like the trick in Stevens[1] and keep retrying the call with a larger bufer until the length of the result is the same as in the previous call. Simply making the buffer "large enough" is of course easier... :-) $.02, /Mikko 1) W. Richard Stevens, UNIX Network Programming 2nd Ed. vol1, p434-435