From owner-freebsd-current@FreeBSD.ORG Fri Sep 19 16:58:37 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 04024106566C for ; Fri, 19 Sep 2008 16:58:37 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.26]) by mx1.freebsd.org (Postfix) with ESMTP id 8ADF68FC08 for ; Fri, 19 Sep 2008 16:58:36 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: by ey-out-2122.google.com with SMTP id 6so147281eyi.7 for ; Fri, 19 Sep 2008 09:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=+muT3GQQRE4zXi4AN0OYfFtjFUaBS01kr1uGNs8W60g=; b=aIM1Cpjz+BSq3TR1xE/sb0XVRt7DDOm36evvVv/rVSL2SKyBJBeztKwJWARA14gbZz Z3IPQq3NrjvPsXv3hufeE9Mg+sjwFnRxJr4DqfFtL+STt87pkwJQijALQTHhvSPt8xwl 5mk2muyJmLa5UiU9mpHq9zGcApdM2MBbAdzHk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=jlvowLuO9EbI7GoF3ytdRtluPdioDZGA1iQ/cDLe8/WeXeazKgVMDKC84Qq2TVAAkP C8oUbxAtmIh8w5GK7sEnTEEqPqVoh1mBHSQYxwZL3JyODtiIn211CI6MFAhNmMkkVsEn /f5MZTCT/5v+SrFpF/4dSh/n1a25z4cInJMfQ= Received: by 10.86.79.19 with SMTP id c19mr2179278fgb.79.1221843515053; Fri, 19 Sep 2008 09:58:35 -0700 (PDT) Received: by 10.86.62.1 with HTTP; Fri, 19 Sep 2008 09:58:34 -0700 (PDT) Message-ID: Date: Fri, 19 Sep 2008 09:58:35 -0700 From: "Maksim Yevmenkin" To: "Maxim Sobolev" In-Reply-To: <48D2F942.4070801@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48D2F942.4070801@FreeBSD.org> Cc: "current@freebsd.org" Subject: Re: 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 16:58:37 -0000 On 9/18/08, Maxim Sobolev 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). > > > 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). > 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