Creating tap interface with custom name

Roman Bogorodskiy novel at FreeBSD.org
Tue Jan 22 06:35:51 UTC 2013


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20130122/f55bea53/attachment.sig>


More information about the freebsd-hackers mailing list