Subject: Re: ifconfig(8) and netmask setting
To: Matt Thomas <>
From: Arnaud Lacombe <>
List: tech-net
Date: 01/18/2007 00:31:52
On Wed, Jan 17, 2007 at 05:50:13PM -0800, Matt Thomas wrote:
> Arnaud LACOMBE wrote:
> >Is it OK to force the user to specify an address when (s)he wants to change
> >the netmask (or broadcast) of a given interface ?
> >
> >Currently, if no address is specified, ifconfig(8) silently fails (in
> >fact... not really as it does nothing :/). On FreeBSD, if no address are
> >specified, the netmask of the default address is updated.
> >
> >The attached patch fix bin/10911 and part of bin/31940 by making the
> >address mandatory when changing netmask/broadcast address (tested for
> >INET, not INET6 or ISO).
> >
> >any comments ?
> Yuck!   I'd fetch the current information and then update it after applying
> the new netmask.
The way I check for the address might not be the better one I admit :)

Another way to do this is available here:
but ...

... does this :
correspond more to what you suggest [only for the netmask by now) ?

This behaviour is the same as freebsd. I'd like also to warn when the
ioctl fails and return EADDRNOTAVAIL. It will happen when an interface
has no address and we try to change is netmask without specifying any

> I wouldn't change the broadcast address if didn't match
> (addr & mask) | (~0 & ~mask) but I would warn.
There is currently no restriction on broadcast address, where does you're
check come from ? 

 - Arnaud