Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jan 2013 10:34:51 +0400
From:      Roman Bogorodskiy <novel@FreeBSD.org>
To:        freebsd-hackers@freebsd.org
Subject:   Creating tap interface with custom name
Message-ID:  <20130122063450.GB39359@ritual.srt.mirantis.net>

next in thread | raw e-mail | index | archive | help

--/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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130122063450.GB39359>