From owner-freebsd-net@FreeBSD.ORG Fri Mar 9 10:53:23 2007 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 31B5416A400 for ; Fri, 9 Mar 2007 10:53:23 +0000 (UTC) (envelope-from frank@pinky.sax.de) Received: from pinky.frank-behrens.de (pinky.frank-behrens.de [82.139.199.24]) by mx1.freebsd.org (Postfix) with ESMTP id 913A013C461 for ; Fri, 9 Mar 2007 10:53:22 +0000 (UTC) (envelope-from frank@pinky.sax.de) Received: from [192.168.20.32] (sun.behrens [192.168.20.32]) by pinky.frank-behrens.de (8.13.8/8.13.8) with ESMTP id l29AawwJ005466 for ; Fri, 9 Mar 2007 11:36:58 +0100 (CET) (envelope-from frank@pinky.sax.de) Message-Id: <200703091036.l29AawwJ005466@pinky.frank-behrens.de> From: "Frank Behrens" To: freebsd-net@freebsd.org Date: Fri, 09 Mar 2007 11:36:57 +0100 MIME-Version: 1.0 Priority: normal X-mailer: Pegasus Mail for Windows (4.31, DE v4.31 R1) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body Subject: tap(4) should go UP if opened X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Mar 2007 10:53:23 -0000 I want to diskuss the tap(4) behaviour before I create a PR: The tap(4) interface does not go automatically in UP state (IFF_UP) when opened by a process. Therefore an additional command "ifconfig tapx up" is necessary, which can execute root only. On the other site the interface goes down automatically when closed. I propose that tap(4) is set to UP when opened by an user process. This can be achieved with the following patch (on FreeBSD 6.2-STABLE-200703081613): --- sys/net/if_tap.c.orig Thu Mar 8 19:10:59 2007 +++ sys/net/if_tap.c Fri Mar 9 10:05:57 2007 @@ -501,6 +501,7 @@ s = splimp(); ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + ifp->if_flags |= IFF_UP; splx(s); TAPDEBUG("%s is open. minor = %#x\n", ifp->if_xname, minor(dev)); How does tun(4) handle this? tun(4) is also set to down, when closed. It is not set to up, when ist is opened, but when an address is assigned by the user process. This is fine, because it needs always an ip address. tap(4) as layer 2 tunnel device does not need an ip address, so setting it up on open is IMHO the best solution. Sound this reasonable or how should I handle the tap(4) open by an user process, when this process does not run as root? Regards, Frank -- Frank Behrens, Osterwieck, Germany PGP-key 0x5B7C47ED on public servers available.