svn commit: r185963 - head/sys/net

Christian S.J. Peron csjp at FreeBSD.org
Thu Dec 11 17:36:50 PST 2008


Author: csjp
Date: Fri Dec 12 01:36:50 2008
New Revision: 185963
URL: http://svn.freebsd.org/changeset/base/185963

Log:
  Consider processes attaching/detaching from tun(4) devices as being link
  state changes.  This change modifies tunopen and tunclose to call the
  if_link_state_change() function.  Among other things, this will result in
  devd(8) receiving events from devctl(4) for linkup/link down.  This allows
  us to do several useful things, including initializing tunnel parameters
  and adding routes.
  
  Discussed on:	freebsd-net@
  MFC after:	2 weeks

Modified:
  head/sys/net/if_tun.c

Modified: head/sys/net/if_tun.c
==============================================================================
--- head/sys/net/if_tun.c	Fri Dec 12 01:26:11 2008	(r185962)
+++ head/sys/net/if_tun.c	Fri Dec 12 01:36:50 2008	(r185963)
@@ -426,6 +426,7 @@ tunopen(struct cdev *dev, int flag, int 
 	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 @@ tunclose(struct cdev *dev, int foo, int 
 		ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 		splx(s);
 	}
+	if_link_state_change(ifp, LINK_STATE_DOWN);
 	CURVNET_RESTORE();
 
 	funsetown(&tp->tun_sigio);


More information about the svn-src-all mailing list