From owner-freebsd-current@FreeBSD.ORG Fri Sep 19 00:58:42 2008 Return-Path: Delivered-To: current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 29FDC1065674 for ; Fri, 19 Sep 2008 00:58:42 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from sippysoft.com (gk1.360sip.com [72.236.70.240]) by mx1.freebsd.org (Postfix) with ESMTP id E9DBE8FC18 for ; Fri, 19 Sep 2008 00:58:41 +0000 (UTC) (envelope-from sobomax@FreeBSD.org) Received: from [192.168.0.61] ([204.244.149.125]) (authenticated bits=0) by sippysoft.com (8.13.8/8.13.8) with ESMTP id m8J0weuL020662 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 18 Sep 2008 17:58:41 -0700 (PDT) (envelope-from sobomax@FreeBSD.org) Message-ID: <48D2F942.4070801@FreeBSD.org> Date: Thu, 18 Sep 2008 17:58:42 -0700 From: Maxim Sobolev Organization: Sippy Software, Inc. User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: "current@freebsd.org" Content-Type: text/plain; charset=KOI8-U; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: Interface auto-cloning bug or feature? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Sep 2008 00:58:42 -0000 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). 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). -Maxim [root@sp1 /usr/home/sobomax]# ifconfig -a tun0: flags=8010 mtu 1500 [root@sp1 /usr/home/sobomax]# stat /dev/tun 67174144 96 crw------- 1 uucp dialer 96 0 "May 2 22:21:28 2008" "May 2 22:21:28 2008" "May 2 22:21:28 2008" "Dec 31 23:59:59 1969" 4096 0 0 /dev/tun [root@sp1 /usr/home/sobomax]# ifconfig -a tun0: flags=8010 mtu 1500 tun1: flags=8010 mtu 1500 [root@sp1 /usr/home/sobomax]# stat /dev/tun 67174144 99 crw------- 1 uucp dialer 99 0 "May 2 22:21:28 2008" "May 2 22:21:28 2008" "May 2 22:21:28 2008" "Dec 31 23:59:59 1969" 4096 0 0 /dev/tun [root@sp1 /usr/home/sobomax]# ifconfig -a tun0: flags=8010 mtu 1500 tun1: flags=8010 mtu 1500 tun2: flags=8010 mtu 1500 [root@sp1 /usr/home/sobomax]# stat /dev/tun 67174144 105 crw------- 1 uucp dialer 105 0 "May 2 22:21:28 2008" "May 2 22:21:28 2008" "May 2 22:21:28 2008" "Dec 31 23:59:59 1969" 4096 0 0 /dev/tun [root@sp1 /usr/home/sobomax]# ifconfig -a tun0: flags=8010 mtu 1500 tun1: flags=8010 mtu 1500 tun2: flags=8010 mtu 1500 tun3: flags=8010 mtu 1500