Desired behaviour of "ifconfig -alias"
olli at lurza.secnetix.de
Tue Feb 13 10:38:28 UTC 2007
JoaoBR <joao at matik.com.br> wrote:
> Oliver Fromme wrote:
> > No, not at all. As soon as you use the terms "primary IP
> > address" and "secondary IP addresses", you imply that they
> > are not equal. But they are equal. It's just a list of
> > IP addresses assigned to an interface which happens to have
> > a certain order.
> nobody claims that there is an master-slave order or something, alias is the
> secondary in order of time, but not in value, I do not even understand why
> you talking so much about this, the point is more than clear
No, it doesn't seem to be clear to you.
As soon as you use the terms "primary" and "secondary",
you are implying a certain order in the meaning of the
IP addresses. But as far as the ifconfig(8) tool is
concerned, there is no order, no matter ow you would
interpret it. In theory, ifconfig could print the IP
addresses for an interface in random order, and each
time in a different order. Which of them would you
call "primary" then? Which of them would be "aliases"?
> > > > If no IP address is specified, then it's not completely
> > > > nonsensical to remove the first address. In fact I've
> > > > used that short-cut to quickly remove the only address
> > > > from an interface. I've used "ifconfig xyz0 delete"
> > > > quite a lot.
> yes it is! it does not matter which word, without an IP address it should NOT
> remove anything
I understand that that's your preference. But it's not
mine. People clearly have different opinions on that
subject. That doesn't mean that one opinion is right
and the other is wrong. It's just a matter of perception.
Currently it is undocumented what the ifconfig command
does when no IP address is specified. While you could
assume that it prints a syntax error message, it is not
guaranteed that it does.
Basically there are two possibilities: Change the man
page so it documents the behaviour correctly. Or change
the program so it prints an error message, _and_ change
the man page so it documents that fact.
Personally, as I've already mentioned, I would prefer
to solve the problem by printing the error message for
the "-alias" parameter only, but keep the current
behaviour for the "delete" and "remove" parameters.
Another possibility, of course, is to make the behaviour
configurable, e.g. dependant on a variable such as
IFCONFIG_TRADITIONAL or IFCONFIG_FORSISSIES.
> > > the man page tells us that -alias removes *the* specified address and
> > > not the first, also the man page does not say that there is any further
> > > action when *no* IP address specified
> > That's true. Usually if something is not documented, the
> > behaviour is undefined.
> undefined is absolutely not similar to remove something ..
"Undefined" can mean anything. There are quite a lot of
examples of undefined behaviour.
> all commands which remove something "usally" say something when trying to use
> without value, rm, rmdir, rmuser ... I really do not remember any other
> then -alias which does so
>From the top of my head, lprm(1) does so. However, the
difference is that it's documented in its manual page.
> > In fact, it might also make sense to enhance the syntax
> > to allow the specification of a number, for example
> > "ifconfig xyz0 delete #2" would remove the second address
> my god what a horrible idea is that!
You fail to explain why.
I think it would be very useful and less error prone,
because typing a single digit is easier than typing an
> do you remember "#" in UNIX????
You did not quote my next sentence (intentionally?) where
I wrote that the syntax was just an example. My point was
the functionality, not the exact syntax in that example.
I also wouldn't object "ifconfig xyz0 delete all" which
would quickly delete all addresses from an interface. I
could have used that more than once, really. Instead,
currently I have to use "ifconfig xyz0 delete" several
times until I get EADDRNOTAVAIL (thankfully there's a
shell history, so I just need to press Cursor-up and
> the command "ifconfig nic -alias IP" is OK, perfect, even delete is, the
> problem and the only problem is that both remove without specifying a value a
> value and that *IS* wrong behaviour,
Neither you nor me decide what is "wrong".
Actually I think there is no right or wrong here. The
issue is that every behaviour clearly has advantages
and disadvantages. Whether one is "more wrong" or
"more right" (i.e. has more disadvantages than advantages
or vice versa) can be debated, as we see here. There
are quite a lot of points that need to be taken into
1. Standards compliance, if applicable.
2. Consistency with other operating systems, if desirable.
3. Consistency with historic behaviour.
4. POLA compliance.
5. Possibility of breakage when changes are made.
6. Feature regression.
7. Convenience of usage.
8. ... and probably much more.
Some of those points are more important than others, of
course. The above list does not imply an order, i.e.
the first point is not the primary one. ;-)
> otherwise *you* must agree that rm
> removes the first file it finds, rmuser the first user and and and, that is
> wrong, documented or not
It would be wrong, because it would violate the synopsis
according to SUSv3/POSIX.
The problem is that there is no synopsis for the parameters
in ifconfig (in the manual page), apart from the fact that
ifconfig isn't a standard and differs considerably between
operating systems. For example, Solaris doesn't know the
notion of "IP aliases" at all (on the other hand, the
ifconfig(1M) manual page on Solaris has a very detailed
and complete synopsis).
> > However, such a feature will run into problems when the
> > set of ip addresses is not an ordered list anymore, which
> > might very well happen in the future. Then there will be
> > no "first" and "last" anymore, but instead the interface
> > will just have an unordered set of IP addresses. In fact
> > I wish that would already be the case, so people saying
> > "primary" and "secondary" would shut up already. :-)
> then they come up in random order on each "ifconfig nic" :) ???
Yes, why not? If you think that's strange or funny, then
you haven't really understood my whole point.
If the IP addresses are not stored in a simple list
internally, but in a more efficient structure (such as
certain kinds of trees), then it can very well happen
that they're printed in random order. Unless, of course,
the ifconfig tool sorted them itself for output (like
ls(1) sorts file names by default unless you use -f),
but then the order would still be arbitrary and not
reflect any order meaningful to the kernel.
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart
Any opinions expressed in this message are personal to the author and may
not necessarily reflect the opinions of secnetix GmbH & Co KG in any way.
FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd
"If Java had true garbage collection, most programs
would delete themselves upon execution."
-- Robert Sewell
More information about the freebsd-stable