From owner-freebsd-net@FreeBSD.ORG Tue Dec 9 17:46:59 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3081B1065673; Tue, 9 Dec 2008 17:46:59 +0000 (UTC) (envelope-from csjp@freebsd.org) Received: from mx-02queue01.mts.net (mx-02queue01.mts.net [142.161.131.10]) by mx1.freebsd.org (Postfix) with ESMTP id AB4AE8FC08; Tue, 9 Dec 2008 17:46:58 +0000 (UTC) (envelope-from csjp@freebsd.org) Received: from wnpgmb021pw-sp03.mts.net ([10.204.128.23]) by mx-02mtaout02.mts.net with ESMTP id <20081209172904.KEHE3962.mx-02mtaout02.mts.net@wnpgmb021pw-sp03.mts.net>; Tue, 9 Dec 2008 11:29:04 -0600 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au4EAK05PkmOoT/O/2dsb2JhbACBbM9ggwc X-IronPort-AV: E=Sophos;i="4.33,742,1220245200"; d="diff'?scan'208";a="49824639" Received: from wnpgmb1309w-ad05-63-206.dynamic.mts.net (HELO jnz.my.domain) ([142.161.63.206]) by wnpgmb021pw-sp03.mts.net with ESMTP; 09 Dec 2008 11:29:04 -0600 Received: from jnz.my.domain (localhost [127.0.0.1]) by jnz.my.domain (8.14.2/8.14.2) with ESMTP id mB9HT3iV072942; Tue, 9 Dec 2008 11:29:04 -0600 (CST) (envelope-from csjp@jnz.my.domain) Received: (from csjp@localhost) by jnz.my.domain (8.14.2/8.14.2/Submit) id mB9HT350072941; Tue, 9 Dec 2008 11:29:03 -0600 (CST) (envelope-from csjp) Date: Tue, 9 Dec 2008 11:29:03 -0600 From: Christian Peron To: freebsd-net@freebsd.org Message-ID: <20081209172903.GA72817@jnz.sqrt.ca> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: imp@freebsd.org Subject: [patch] link state notifications for tun(4) 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: Tue, 09 Dec 2008 17:46:59 -0000 --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I would like to propose a change for tun(4) but before I do, I would like to read any feedback this list might have. Basically we have a situation where we need to manually configure tunnel interfaces when a process opens them. We would like to hook into devd(8) for this. i.e. when we see tunX "linkup" call ifconfig as well, add some routes. The trouble is, tun(4) does not generate linkup/linkdown events. We would consider the tun device to be linked up when a process has it open, and linked down when the process closes it. Thoughts? --gBBFr7Ir9EOA20Yy Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="tun.diff" Index: if_tun.c =================================================================== --- if_tun.c (revision 185712) +++ if_tun.c (working copy) @@ -426,6 +426,7 @@ tp->tun_flags |= TUN_OPEN; mtx_unlock(&tp->tun_mtx); ifp = TUN2IFP(tp); + if_link_state_change(ifp, LINK_STATE_UP); TUNDEBUG(ifp, "open\n"); return (0); @@ -482,6 +483,7 @@ ifp->if_drv_flags &= ~IFF_DRV_RUNNING; splx(s); } + if_link_state_change(ifp, LINK_STATE_DOWN); CURVNET_RESTORE(); funsetown(&tp->tun_sigio); --gBBFr7Ir9EOA20Yy--