Subject: Re: ifconfig(8) and netmask setting
To: Arnaud LACOMBE <arnaud.lacombe.1@ulaval.ca>
From: Matt Thomas <matt@3am-software.com>
List: tech-net
Date: 01/17/2007 17:50:13
Arnaud LACOMBE wrote:
> Hi,
> 
> 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.  I wouldn't change the broadcast address if didn't match
(addr & mask) | (~0 & ~mask) but I would warn.