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?
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);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to