interface name collisions

Bjoern A. Zeeb bzeeb-lists at lists.zabbadoz.net
Wed Aug 26 06:22:04 UTC 2009


On Wed, 26 Aug 2009, Nikos Vassiliadis wrote:

Hi,

> When an interface is moved from a parent to a child vnet
> a check is done. I tried to copy that behavior. Does it
> look correct?
>
> --- sys/net/if.c.orig   2009-08-24 15:52:05.000000000 +0300
> +++ sys/net/if.c        2009-08-25 23:55:26.000000000 +0300
> @@ -992,6 +992,13 @@
>        prison_hold_locked(pr);
>        mtx_unlock(&pr->pr_mtx);
>
> +        /* Make sure the named iface does not exist in the dst. prison/vnet. 
> */
> +       ifp = ifunit(ifname);
> +       if (ifp != NULL) {
> +               prison_free(pr);
> +               return (EEXIST);
> +       }
> +
>        /* Make sure the named iface exists in the source prison/vnet. */
>        CURVNET_SET(pr->pr_vnet);
>        ifp = ifunit(ifname);           /* XXX Lock to avoid races. */


I hope there would be a comment somewhere that vmomve should be
re-done to fix all this... it was in the commit message:

:: There is some duplicate interface name checking before actually moving
:: the interface between network stacks without locking and thus race
:: prone. Ideally if_vmove will correctly and automagically handle these
:: in the future.

So what you do above replicates this behaviour but doesn't really make
it better as you still may run into the problem only less likely.

Robert is currently fixing other if.c bugs for ifindex allocation (proper
locking, reducing races,..), so I am satying away from there to not
interfere with his work but hope to go back there next week, when the if.c
code has settled.

/bz

-- 
Bjoern A. Zeeb           What was I talking about and who are you again?


More information about the freebsd-virtualization mailing list