Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Sep 2008 09:58:35 -0700
From:      "Maksim Yevmenkin" <maksim.yevmenkin@gmail.com>
To:        "Maxim Sobolev" <sobomax@freebsd.org>
Cc:        "current@freebsd.org" <current@freebsd.org>
Subject:   Re: Interface auto-cloning bug or feature?
Message-ID:  <bb4a86c70809190958k6a231c33ida8840f1df56e2b5@mail.gmail.com>
In-Reply-To: <48D2F942.4070801@FreeBSD.org>
References:  <48D2F942.4070801@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 9/18/08, Maxim Sobolev <sobomax@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



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