ifconfig, vnets and interface names
Nikolay Denev
ndenev at gmail.com
Sun Oct 17 14:37:14 UTC 2010
Hello,
While playing with vnet jails I've discovered the following oddity, which probably is not what's expected to happen :
First I'm creating two epair(4) interfaces :
[16:51]root at nas:/home/ndenev# ifconfig epair0 create
epair0a
[16:51]root at nas:/home/ndenev# ifconfig epair1 create
epair1a
Then I'm creating two vnet jails :
[16:51]root at nas:/home/ndenev# jail -c vnet name=test1 host.hostname=test1 path=/ persist
[16:51]root at nas:/home/ndenev# jail -c vnet name=test2 host.hostname=test2 path=/ persist
Now push one side of the epairs to each vnet :
[16:51]root at nas:/home/ndenev# ifconfig epair0b vnet test1
[16:52]root at nas:/home/ndenev# ifconfig epair1b vnet test2
Rename the interfaces in the vnet jails :
[16:52]root at nas:/home/ndenev# jexec test1 ifconfig epair0b name eth0
[16:52]root at nas:/home/ndenev# jexec test2 ifconfig epair1b name eth0
And now I'm destroying the vnets, so all of the interfaces are "reclaimed" by the host :
[16:52]root at nas:/home/ndenev# jail -r test1
[16:52]root at nas:/home/ndenev# jail -r test2
And that's what ifconfig shows after this :
[16:52]root at nas:/home/ndenev# ifconfig
<... snip lo0 and physical interface ...>
epair0a: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 02:8c:53:00:03:0a
epair1a: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 02:b6:49:00:05:0a
eth0: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 02:8c:53:00:04:0b
ether 02:b6:49:00:06:0b
Instead of two interfaces, I'm seeing one with to lladdrs, because of the interface names being the same.
Then I'm trying to destroy them :
[16:52]root at nas:/home/ndenev# ifconfig eth0 destroy
[16:53]root at nas:/home/ndenev# ifconfig
<... snip lo0 and physical interface ...>
epair1a: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 02:b6:49:00:05:0a
eth0: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 02:b6:49:00:06:0b
[16:53]root at nas:/home/ndenev# ifconfig eth0 destroy
So in this case there may be not a clean way to address one of the interfaces specifically (i.e. destroy only the second one)?
I've not investigated further, but I'm thinking probably this is just a "bug" in ifconfig interpreting/parsing the information from the kernel.
Maybe a solution is to extend ifconfig to be able print the interface list along with the ifIndex values and also manage the interfaces by index?
Auto renaming also is also probably a possible solution (i.e. eth0_1 , eth0_2 ) as these are interfaces coming from destroyed vnet's and are not likely to be in use. (but still sounds scary :) )
Regards,
Nikolay
More information about the freebsd-net
mailing list