Re: Interface auto-cloning bug or feature?

From: Maksim Yevmenkin <maksim.yevmenkin_at_gmail.com>
Date: Fri, 19 Sep 2008 09:58:35 -0700
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
Received on Fri Sep 19 2008 - 14:58:37 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:35 UTC