From owner-freebsd-virtualization@FreeBSD.ORG Wed Aug 26 06:22:03 2009 Return-Path: Delivered-To: freebsd-virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E24AB106568C for ; Wed, 26 Aug 2009 06:22:03 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mail.cksoft.de (mail.cksoft.de [195.88.108.3]) by mx1.freebsd.org (Postfix) with ESMTP id 9E1D88FC21 for ; Wed, 26 Aug 2009 06:22:03 +0000 (UTC) Received: from localhost (amavis.fra.cksoft.de [192.168.74.71]) by mail.cksoft.de (Postfix) with ESMTP id ED4D041C6B4; Wed, 26 Aug 2009 08:05:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at cksoft.de Received: from mail.cksoft.de ([195.88.108.3]) by localhost (amavis.fra.cksoft.de [192.168.74.71]) (amavisd-new, port 10024) with ESMTP id QsnSH+xe-l1l; Wed, 26 Aug 2009 08:05:06 +0200 (CEST) Received: by mail.cksoft.de (Postfix, from userid 66) id 525CA41C6A7; Wed, 26 Aug 2009 08:05:06 +0200 (CEST) Received: from maildrop.int.zabbadoz.net (maildrop.int.zabbadoz.net [10.111.66.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.int.zabbadoz.net (Postfix) with ESMTP id 848E54448E6; Wed, 26 Aug 2009 06:00:57 +0000 (UTC) Date: Wed, 26 Aug 2009 06:00:57 +0000 (UTC) From: "Bjoern A. Zeeb" X-X-Sender: bz@maildrop.int.zabbadoz.net To: Nikos Vassiliadis In-Reply-To: <4A9453D9.4020604@gmx.com> Message-ID: <20090826055308.C93661@maildrop.int.zabbadoz.net> References: <4A93E416.20200@gmx.com> <4A9428CF.6050308@elischer.org> <4A9453D9.4020604@gmx.com> X-OpenPGP-Key: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: FreeBSD virtualization mailing list Subject: Re: interface name collisions X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2009 06:22:04 -0000 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?