Date: Tue, 9 Dec 2008 11:29:03 -0600 From: Christian Peron <csjp@freebsd.org> To: freebsd-net@freebsd.org Cc: imp@freebsd.org Subject: [patch] link state notifications for tun(4) Message-ID: <20081209172903.GA72817@jnz.sqrt.ca>
next in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081209172903.GA72817>