Use devname() if available to support devfs cloning on BSD.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 9 Apr 2016 16:39:40 +0000 (18:39 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 9 Apr 2016 16:39:40 +0000 (18:39 +0200)
Some BSD flavors allow opening /dev/tun and/or /dev/tap, which automatically
create a new tun or tap interface with an unused number. To find out which
number the interface got, you have to call devname() on the device file
that was opened.

The semantics are different from the way Linux's /dev/tun works though.
In particular, after closing the device, the interface will continue to exist.
Restarting tincd would cause the old interface to stay around, and a new
one to be created. One could add a tinc-down script with the following line:

ifconfig $INTERFACE destroy

But that is still no guarantee that restarting tinc will give you the same
interface. So the default tun and tap device will stay /dev/tun0 and /dev/tap0
for all BSD flavors to avoid surprises for existing users.


No differences found