A problem with too many network interfaces

Mikko Työläjärvi mbsd at pacbell.net
Mon May 26 14:04:20 PDT 2003


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


More information about the freebsd-net mailing list