From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 22 06:35:51 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1A699365 for ; Tue, 22 Jan 2013 06:35:51 +0000 (UTC) (envelope-from bogorodskiy@gmail.com) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by mx1.freebsd.org (Postfix) with ESMTP id 94FE07EA for ; Tue, 22 Jan 2013 06:35:50 +0000 (UTC) Received: by mail-la0-f41.google.com with SMTP id fo12so1544668lab.0 for ; Mon, 21 Jan 2013 22:35:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=iBP5r/cvTfqiyhWAuvvOFpsjhqqo97u317WmoaJgrZs=; b=QQI4XZgJqNizF89OMMAQhjnUvpW1s+s/+/rt1mWWliC8OEmeepKR3grBTrPK81CiuO Eoj4pVxmxd1hfdNRIxbvVQ4mgGkwa5RaITws/qcWO3DWJka1zfPrp6JTrKcFBQNUWAEl 8JmSgyB/Ou2arT8BeUnDhV3EYUUnYBBHT9Rm+spiVQ8ADfzsCIduDcJToaGoRRVIcpoC tv7r6jqTAwjKpfwFLSZZWAsXLgV+RtdWTZX1JhgD5Zaob7A7ziyNP6lXWALDnqmNKxRH UQ289uGjbTrKyJ7u3VVSzsIltYOxOhCr48M+CoAkPakfKuRcUwX0dTob+0p/eg3ijTit SFFw== X-Received: by 10.112.10.71 with SMTP id g7mr8633746lbb.70.1358836549115; Mon, 21 Jan 2013 22:35:49 -0800 (PST) Received: from ritual.srt.mirantis.net ([91.207.132.67]) by mx.google.com with ESMTPS id ee5sm6426596lbb.14.2013.01.21.22.35.47 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 21 Jan 2013 22:35:48 -0800 (PST) Sender: Roman Bogorodskiy Date: Tue, 22 Jan 2013 10:34:51 +0400 From: Roman Bogorodskiy To: freebsd-hackers@freebsd.org Subject: Creating tap interface with custom name Message-ID: <20130122063450.GB39359@ritual.srt.mirantis.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/WwmFnJnmDyWGHa4" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jan 2013 06:35:51 -0000 --/WwmFnJnmDyWGHa4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I have a thing I want to do and I'm not sure what's the best way to do it, hopefully somebody could suggest a solution. The idea is to create a 'tap' interfaces with a custom name, e.g. foobarN instead of tapN, from an application. So the current workflow looks this way: - a request comes to create new 'foobar' interface - 'tap' device is created via SIOCIFCREATE2 - code finds the first free interface name, that it could use by going from foobar0, foobar1 etc until it finds an unused name - code renames 'tap' device to the new 'foobarN' via SIOCSIFNAME As you can see, this code is not optimal and very fragile. It spends a lot of time trying to find an appropriate interface name and it will break if something happens while it's running (tap device will be deleted by user before it gets renamed, new foobarN will be created manually before the code will create it, etc). Is there any better to implement this? Roman Bogorodskiy --/WwmFnJnmDyWGHa4 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iQEcBAEBAgAGBQJQ/jMJAAoJEMltX/4IwiJq6sMH/A5lw1WCWzUxdI+SKU1Ay+AH t0HGcYxmMS8ybHF4ehahAFli0lrp5slvdEXQ90feaByah+5UYEJm++9pQRrXOe+n e3hL3Dsk/dabK+x0zTvy/0qs6/d8+R01v+Wt2qqIlJiTVkqsvY7pwNXZlJeimfMY 9x7hY4Ewu8EvvG8rQwkFQ9Q7SpiBKQvHMhDhliBiM1H5+uRF16iP3oFfD/3hJNa6 3Tt8EIVa3BuCLzD59ddi58WbgOdTTctcBoyJZnr0GKkBPkeMi27F5uE0U5SbCedI /WdtCx/3ZNZGSDWy6TE1VYkMoWqyeg4sfCM+U9xgMx40lDKK/awd49wkfvf/QYg= =1sJS -----END PGP SIGNATURE----- --/WwmFnJnmDyWGHa4--