From owner-freebsd-current@FreeBSD.ORG Tue Sep 23 01:49:16 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17D661065674 for ; Tue, 23 Sep 2008 01:49:16 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.152]) by mx1.freebsd.org (Postfix) with ESMTP id 8A74E8FC26 for ; Tue, 23 Sep 2008 01:49:15 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: by fg-out-1718.google.com with SMTP id l26so1518828fgb.35 for ; Mon, 22 Sep 2008 18:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=ZSlGhNh5PAyfztSsoWDlH7LRG9bjnpH52X3bEoIquHs=; b=FWP1B7Z+v0mxSReywHqQaQeQHM7xV2+XOkSGMF1nmW+bpzGSJSZWHRJLYVso1Co6Cx TBUSjhMTr0OGXmA5+/hluJYNv2ih1RiOEGrs5IFq3vR1TRnUP0wey2DYg3xeNTQDzHSQ wsnpt5Pu6OTHEnHJ7Q+r/+OSLpxRIkTIXnGwk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=BRgtDdUeEU72mLn4QfTHtWCeCYplWjPGHNor5C2GYDafVB9sosvzdRt8ymz7uRNXbQ Y8NGLW9N/Et3uCYgpeueYZu0joLMpD02xHKa8IergAytbmfuNF0+LvWQqaK3U0vCF6gD 9Cm4N/vGI1UcSKkfS463yQRsNpba0kCAnMZ08= Received: by 10.86.29.8 with SMTP id c8mr5623535fgc.23.1222134554280; Mon, 22 Sep 2008 18:49:14 -0700 (PDT) Received: by 10.86.62.1 with HTTP; Mon, 22 Sep 2008 18:49:14 -0700 (PDT) Message-ID: Date: Mon, 22 Sep 2008 18:49:14 -0700 From: "Maksim Yevmenkin" To: "Maxim Sobolev" In-Reply-To: <48D8196E.7020005@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_13317_11640650.1222134554266" References: <48D2F942.4070801@FreeBSD.org> <20080919084201.GD44330@wep4035.physik.uni-wuerzburg.de> <48D38DFF.8000803@FreeBSD.org> <20080919203310.GA34131@localhost.my.domain> <48D8196E.7020005@FreeBSD.org> Cc: Alexey Shuvaev , Kostik Belousov , freebsd-current@freebsd.org, Ed Schouten Subject: Re: Interface auto-cloning bug or feature? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Sep 2008 01:49:16 -0000 ------=_Part_13317_11640650.1222134554266 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline [...] >>> ok, how about attached patch. i put it together *very* quickly and >>> only gave it a light testing. its for tap(4), because i could compile >>> it as a module and tun(4) is compiled into kernel by default, but the >>> idea should identical for tun(4). should be even simpler for tun(4) >>> because it does not have to deal with 2 kind of devices (i.e. tap and >>> vmnet). give it a try, and see if it works. please try both cloning >>> paths, i.e. >>> >>> 1) cat /dev/tap (/dev/vmnet) with and/or without unit number >>> >>> and >>> >>> 2) ifconfig tapX (vmnetX) create/destroy >>> >>> in the mean time i will prepare something similar for tun(4). >> >> attached is similar patch for tun(4). i only made sure it compiles :) >> rebuilding kernel now... attached is a slightly better patch for tap(4). the idea is to use extra ALLOCATED flag that prevents the race Kostik pointed out. could you please give it a try? any review comments are greatly appreciated. if this is acceptable, i will prepare something similar for tun(4) thanks, max ------=_Part_13317_11640650.1222134554266 Content-Type: text/plain; name=if_tap.diff.txt Content-Transfer-Encoding: base64 X-Attachment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