Discussion:
ifconfig(8) and netmask setting
(too old to reply)
Arnaud LACOMBE
2007-01-18 00:40:01 UTC
Permalink
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 ?

- Arnaud
Matt Thomas
2007-01-18 01:50:13 UTC
Permalink
Post by Arnaud LACOMBE
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.


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Arnaud Lacombe
2007-01-18 05:31:52 UTC
Permalink
Post by Matt Thomas
Post by Arnaud LACOMBE
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:
http://sigfpe.info/netbsd/bin-10911/ifconfig-10911-exit_new.diff
but ...

... does this :
http://sigfpe.info/netbsd/bin-10911/ifconfig-10911-update_default.diff
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
address.
Post by Matt Thomas
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

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...