Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Oct 2010 17:09:35 +0300
From:      Nikolay Denev <ndenev@gmail.com>
To:        freebsd-stable@freebsd.org, freebsd-net@freebsd.org
Subject:   ifconfig, vnets and interface names
Message-ID:  <7051D018-684F-417A-AAA0-00603B2FDCD4@gmail.com>

next in thread | raw e-mail | index | archive | help
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@nas:/home/ndenev# ifconfig epair0 create
    epair0a
    [16:51]root@nas:/home/ndenev# ifconfig epair1 create
    epair1a

Then I'm creating two vnet jails :

    [16:51]root@nas:/home/ndenev# jail -c vnet name=3Dtest1 =
host.hostname=3Dtest1 path=3D/ persist
    [16:51]root@nas:/home/ndenev# jail -c vnet name=3Dtest2 =
host.hostname=3Dtest2 path=3D/ persist

Now push one side of the epairs to each vnet :

    [16:51]root@nas:/home/ndenev# ifconfig epair0b vnet test1
    [16:52]root@nas:/home/ndenev# ifconfig epair1b vnet test2

Rename the interfaces in the vnet jails :

    [16:52]root@nas:/home/ndenev# jexec test1 ifconfig epair0b name eth0
    [16:52]root@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@nas:/home/ndenev# jail -r test1
    [16:52]root@nas:/home/ndenev# jail -r test2

And that's what ifconfig shows after this :

    [16:52]root@nas:/home/ndenev# ifconfig    =20
    <... snip lo0 and physical interface ...>
    epair0a: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
	    ether 02:8c:53:00:03:0a
    epair1a: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
	   ether 02:b6:49:00:05:0a
    eth0: flags=3D8842<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@nas:/home/ndenev# ifconfig eth0 destroy
    [16:53]root@nas:/home/ndenev# ifconfig=20
    <... snip lo0 and physical interface ...>
    epair1a: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 =
mtu 1500
	    ether 02:b6:49:00:05:0a
    eth0: flags=3D8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu =
1500
	    ether 02:b6:49:00:06:0b
    [16:53]root@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=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7051D018-684F-417A-AAA0-00603B2FDCD4>