Date: Mon, 22 Sep 2008 18:49:14 -0700 From: "Maksim Yevmenkin" <maksim.yevmenkin@gmail.com> To: "Maxim Sobolev" <sobomax@freebsd.org> Cc: Alexey Shuvaev <shuvaev@physik.uni-wuerzburg.de>, Kostik Belousov <kostikbel@gmail.com>, freebsd-current@freebsd.org, Ed Schouten <ed@80386.nl> Subject: Re: Interface auto-cloning bug or feature? Message-ID: <bb4a86c70809221849v640e66awa52a2b5d944ca0dc@mail.gmail.com> In-Reply-To: <48D8196E.7020005@FreeBSD.org> References: <48D2F942.4070801@FreeBSD.org> <20080919084201.GD44330@wep4035.physik.uni-wuerzburg.de> <48D38DFF.8000803@FreeBSD.org> <20080919203310.GA34131@localhost.my.domain> <bb4a86c70809191543y7f3d38ex73c48186dfd163c5@mail.gmail.com> <bb4a86c70809191551y774c233g5e664c431be62a50@mail.gmail.com> <48D8196E.7020005@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
------=_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-Id: f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QorI2RlZmluZSBUQVBfQUxMT0NBVEVECSgxIDw8IDUpCiAKIAl1X2ludDhfdCAJZXRo ZXJfYWRkcltFVEhFUl9BRERSX0xFTl07IC8qIGV0aGVyIGFkZHIgb2YgdGhlIHJlbW90ZSBzaWRl ICovCiAK ------=_Part_13317_11640650.1222134554266--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bb4a86c70809221849v640e66awa52a2b5d944ca0dc>