Desired behaviour of "ifconfig -alias"

Ian Smith smithi at
Sat Feb 10 05:13:10 UTC 2007

On Fri, 9 Feb 2007, Jeremy Chadwick wrote:
 > On Fri, Feb 09, 2007 at 09:13:22PM -0500, Kevin Way wrote:
 > > I'm as much of a change-hating curmudgeon as the next guy, but if
 > > anybody is relying on
 > > "ifconfig iface -alias" 's undefined behavior, then they deserve the
 > > pain that will come with a fix.
 > > 
 > > As it stands the behavior appears to vary between drivers (archive
 > > search shows that on fxp it
 > > blows away all IPs, while on bce it blows away the primary IP, leaving
 > > all aliases intact.)
 > Upon looking at the code, I can see exactly where this (read: -alias
 > without any arguments) can be addressed, and it's not in the NIC
 > drivers.
 > Tracing through src/sbin/ifconfig/ifconfig.c in RELENG_6:
 > main() iterates through argv, calling cmd_lookup() on each argument
 > passed.  cmd_lookup() does a strcmp() comparison against the argument
 > passed and what's in each struct entry pointed to by pointer "cmds".
 > "cmds" is populated via the constructor ifconfig_ctor(), taking its
 > data from a struct table called basic_cmds.  Entries in basic_cmds
 > use macros named DEF_CMD(), DEF_CMD_ARG(), and DEF_CMD_ARG2(), which
 > define the number of arguments required.
 > Thus, it seems to me that either the struct of basic_cmds needs to be
 > changed to address things differently (argv parsers are fun!), or one
 > could simply move "-alias" to require "inet" or "inet6" (or whatever
 > other things you might want to match on).

This is way out of my league, but:

 -alias  Remove the network address specified.  This would be used if you
         incorrectly specified an alias, or it was no longer needed. If
         you have incorrectly set an NS address having the side effect of
         specifying the host portion, removing all NS addresses will allow
         you to respecify the host portion.

Does not 'remove the network address specified' imply that this should
fail if a) there is no network address specified or b) the address that
is specified is not an existing alias address for the interface?

Secondly, pardon my ignorance, but what does 'NS' refer to here?  That
string / term occurs nowhere else in ifconfig(8). 

Perhaps I'm missing a valid (and used) usage of -alias with no address?


Cheers, Ian

More information about the freebsd-stable mailing list