Desired behaviour of "ifconfig -alias"

Jeremy Chadwick koitsu at
Sat Feb 10 02:48:06 UTC 2007

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

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).

It seems to me that this oversight was addressed when adding 802.1
support to ifconfig -- thus creating ifieee80211.c, which has
pre-requisite counts and things for some of the arguments.

Thus, what I'm saying is this: the change should be doable, and
the argument for "keeping this brokenness" fails miserably (sorry
Brooks, I don't want you to feel like I'm raining on your parade,
but your argument doesn't jive with me.)

> Am I missing a reason that this could ever be desirable?  If it was
> consistent, I could see an
> argument for documentation.  But as it stands, the only thing to
> document would be that the
> behavior varies between drivers, and a fix has been declined on the
> basis of momentum.

I can't see why this would be desirable either.

I don't want ifconfig to go the route of Linux's ipfwadm --> ipchains
--> iptables (anyone familiar with that migration should understand
my comparison), but we're talking about an oversight of the syntax
parser here.

Additionally, if each driver (fxp vs. bge vs. nve) all behave
differently on -alias, that's also odd.  I bet that one can be
explained, though.

> At a minimum can this get normalized in -HEAD?

I would like to see this addressed in -HEAD and backported to RELENG_6,
because this isn't an ifconfig syntax change, it's addressing a
decent oversight in what expected arguments are for certain commands.

| Jeremy Chadwick                                 jdc at |
| Parodius Networking               |
| UNIX Systems Administrator                   Mountain View, CA, USA |
| Making life hard for others since 1977.               PGP: 4BD6C0CB |

More information about the freebsd-stable mailing list