Discussion:
"rotating" IPv4 addresses - bug or feature?
(too old to reply)
j+ (Jukka Salmi)
2007-07-11 00:12:23 UTC
Permalink
Hi,

after bringing down a NetBSD 3 system to single user and then back up
to multi user, I noticed that the systems three IPv4 addresses were
"rotated". I can also reproduce this on a -current system:

$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0 inet 192.168.0.2/24 alias
$ ifconfig vr0 inet 192.168.0.3/24 alias
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
address: 00:0c:6e:74:f6:81
media: Ethernet autoselect (100baseTX full-duplex)
status: active
inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255

So far so good, but then:

$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
address: 00:0c:6e:74:f6:81
media: Ethernet autoselect (100baseTX full-duplex)
status: active
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255

Hmm, it's not a problem AFAICT, I just wonder if this is expected
behaviour...


Regards, Jukka
--
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
David Young
2007-07-11 00:31:25 UTC
Permalink
Post by j+ (Jukka Salmi)
Hmm, it's not a problem AFAICT, I just wonder if this is expected
behaviour...
It is expected behavior. The kernel keeps a linked list of addresses
on each interface. Adding/deleting addresses can change the order of
that list. When userland asks the kernel for the addresses, it writes
them out in the order that they appear on the list.

Only the address that is first on the list is "special" in any way;
after the kernel chooses an outgoing IP interface, it uses the first
address on the interface for the source, if the socket did not bind(2)
to some other address. (I recommend to users who desire the kernel to
make a less arbitrary choice of source address, recompile your kernel with
'options IPSELSRC' and set a policy that suits you.)

Dave
--
David Young OJC Technologies
***@ojctech.com Urbana, IL * (217) 278-3933 ext 24

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Alan Barrett
2007-07-11 09:12:12 UTC
Permalink
On Wed, 11 Jul 2007, Jukka Salmi wrote:
[several ifconfig commands, then:]
Post by j+ (Jukka Salmi)
$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
address: 00:0c:6e:74:f6:81
media: Ethernet autoselect (100baseTX full-duplex)
status: active
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
This looks like a bug to me. "ifconfig vr0 inet 192.168.0.1/24" should
not have made 192.168.0.2 become the first address in the list; it
should have made 192.168.0.1 the first adress in the list.

--apb (Alan Barrett)

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
j+ (Jukka Salmi)
2007-07-11 10:53:05 UTC
Permalink
Post by Alan Barrett
[several ifconfig commands, then:]
Post by j+ (Jukka Salmi)
$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
address: 00:0c:6e:74:f6:81
media: Ethernet autoselect (100baseTX full-duplex)
status: active
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
This looks like a bug to me. "ifconfig vr0 inet 192.168.0.1/24" should
not have made 192.168.0.2 become the first address in the list; it
should have made 192.168.0.1 the first adress in the list.
That's what I had expected, too.

I just noticed something what really looks like a bug to me:

$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255

$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255

$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255

Huh, 192.168.0.2 is gone...


Regards, Jukka
--
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
David Young
2007-07-11 18:06:03 UTC
Permalink
Post by j+ (Jukka Salmi)
Post by Alan Barrett
[several ifconfig commands, then:]
Post by j+ (Jukka Salmi)
$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
address: 00:0c:6e:74:f6:81
media: Ethernet autoselect (100baseTX full-duplex)
status: active
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
This looks like a bug to me. "ifconfig vr0 inet 192.168.0.1/24" should
not have made 192.168.0.2 become the first address in the list; it
should have made 192.168.0.1 the first adress in the list.
That's what I had expected, too.
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
Huh, 192.168.0.2 is gone...
You have to use the 'alias' keyword, or else the kernel will replace the
first address instead of adding an address. IMO we should get rid of
'alias' and make ifconfig inet work as ifconfig inet6 does before 5.0:
always add an address unless the operator gives the 'delete' keyword.

Dave
--
David Young OJC Technologies
***@ojctech.com Urbana, IL * (217) 278-3933 ext 24

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Alan Barrett
2007-07-11 18:38:54 UTC
Permalink
Post by David Young
Post by j+ (Jukka Salmi)
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
Huh, 192.168.0.2 is gone...
You have to use the 'alias' keyword, or else the kernel will replace the
first address instead of adding an address.
Yes, that's what I expected, but that's not what happened. The kernel
removed the previous "first address", but failed to move the "new"
address to the beginning of the list.

--apb (Alan Barrett)

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
j+ (Jukka Salmi)
2007-07-12 12:03:48 UTC
Permalink
[...]
Post by David Young
Post by j+ (Jukka Salmi)
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.2 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
$ ifconfig vr0 inet 192.168.0.1/24
$ ifconfig vr0
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
[...]
inet 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
inet alias 192.168.0.1 netmask 0xffffff00 broadcast 192.168.0.255
Huh, 192.168.0.2 is gone...
You have to use the 'alias' keyword, or else the kernel will replace the
first address instead of adding an address.
I didn't want to add a new address. I just wanted to point out that
if I "add" the already existing first address, then the addresses are
rotated; and if I "add" it again, then the first alias address
disappears. In other words, the first address was not replaced.


Regards, Jukka
--
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~

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