Interface auto-cloning bug or feature?
Maksim Yevmenkin
maksim.yevmenkin at gmail.com
Fri Sep 19 16:58:37 UTC 2008
On 9/18/08, Maxim Sobolev <sobomax at freebsd.org> wrote:
> Hi,
>
> I've noticed that stat/open call on /dev/tun always creates new
> interface, despite the fact that existing spare interfaces may be
> available. I believe that it's a bug, since the whole purpose of
> auto-cloning is to create new instance only when no existing one could
> be allocated. At least that's my reading of the manual page for the tun(4).
>
> <quote>
> If the sysctl(8) variable net.link.tun.devfs_cloning is non-zero,
> the tun
> interface permits opens on the special control device /dev/tun. When
> this device is opened, tun will return a handle for the lowest
> unused tun
> device (use devname(3) to determine which).
> </quote>
yes, that is a bug/feature depending on how you look at it. basically,
when /dev/tap,tun,vkbdctl is opened, unit is == -1. clone_create()
runs over clonedevs list and tries to match unit (and it cant because
unit is -1). so it end up allocating a new one. it would have been all
fine, except the clone is not destroyed when /dev/tap is closed. at
some point it used to be that tap/tun instances were removed as soon
as device was closed. and, of course, network interfaces were also
completely removed when character device was closed. i recall few
people complained about this. i think it also was causing problems
with some ports (vmware perhaps?)
thanks,
max
More information about the freebsd-current
mailing list