svn commit: r204843 - stable/7/sys/net

Konstantin Belousov kib at FreeBSD.org
Sun Mar 7 20:06:07 UTC 2010


Author: kib
Date: Sun Mar  7 20:06:06 2010
New Revision: 204843
URL: http://svn.freebsd.org/changeset/base/204843

Log:
  MFC r204464:
  Several fixes for miscellaneous clone handlers in if_tun and if_tap.
  
  Tested by:	Mikolaj Golub <to.my.trociny gmail com>

Modified:
  stable/7/sys/net/if_tap.c
  stable/7/sys/net/if_tun.c
Directory Properties:
  stable/7/sys/   (props changed)
  stable/7/sys/cddl/contrib/opensolaris/   (props changed)
  stable/7/sys/contrib/dev/acpica/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/sys/net/if_tap.c
==============================================================================
--- stable/7/sys/net/if_tap.c	Sun Mar  7 18:43:29 2010	(r204842)
+++ stable/7/sys/net/if_tap.c	Sun Mar  7 20:06:06 2010	(r204843)
@@ -192,10 +192,6 @@ tap_clone_create(struct if_clone *ifc, i
 	if (i) {
 		dev = make_dev(&tap_cdevsw, unit2minor(unit | extra),
 		     UID_ROOT, GID_WHEEL, 0600, "%s%d", ifc->ifc_name, unit);
-		if (dev != NULL) {
-			dev_ref(dev);
-			dev->si_flags |= SI_CHEAPCLONE;
-		}
 	}
 
 	tapcreate(dev);
@@ -300,6 +296,7 @@ tapmodevent(module_t mod, int type, void
 		EVENTHANDLER_DEREGISTER(dev_clone, eh_tag);
 		if_clone_detach(&tap_cloner);
 		if_clone_detach(&vmnet_cloner);
+		drain_dev_clone_events();
 
 		mtx_lock(&tapmtx);
 		while ((tp = SLIST_FIRST(&taphead)) != NULL) {
@@ -381,12 +378,9 @@ tapclone(void *arg, struct ucred *cred, 
 			name = devname;
 		}
 
-		*dev = make_dev(&tap_cdevsw, unit2minor(unit | extra),
-		     UID_ROOT, GID_WHEEL, 0600, "%s", name);
-		if (*dev != NULL) {
-			dev_ref(*dev);
-			(*dev)->si_flags |= SI_CHEAPCLONE;
-		}
+		*dev = make_dev_credf(MAKEDEV_REF, &tap_cdevsw,
+		     unit2minor(unit | extra),
+		     cred, UID_ROOT, GID_WHEEL, 0600, "%s", name);
 	}
 
 	if_clone_create(name, namelen, NULL);

Modified: stable/7/sys/net/if_tun.c
==============================================================================
--- stable/7/sys/net/if_tun.c	Sun Mar  7 18:43:29 2010	(r204842)
+++ stable/7/sys/net/if_tun.c	Sun Mar  7 20:06:06 2010	(r204843)
@@ -185,10 +185,6 @@ tun_clone_create(struct if_clone *ifc, i
 		/* No preexisting struct cdev *, create one */
 		dev = make_dev(&tun_cdevsw, unit2minor(unit),
 		    UID_UUCP, GID_DIALER, 0600, "%s%d", ifc->ifc_name, unit);
-		if (dev != NULL) {
-			dev_ref(dev);
-			dev->si_flags |= SI_CHEAPCLONE;
-		}
 	}
 	tuncreate(ifc->ifc_name, dev);
 
@@ -233,12 +229,8 @@ tunclone(void *arg, struct ucred *cred, 
 			name = devname;
 		}
 		/* No preexisting struct cdev *, create one */
-		*dev = make_dev(&tun_cdevsw, unit2minor(u),
-		    UID_UUCP, GID_DIALER, 0600, "%s", name);
-		if (*dev != NULL) {
-			dev_ref(*dev);
-			(*dev)->si_flags |= SI_CHEAPCLONE;
-		}
+		*dev = make_dev_credf(MAKEDEV_REF, &tun_cdevsw, unit2minor(u),
+		    cred, UID_UUCP, GID_DIALER, 0600, "%s", name);
 	}
 
 	if_clone_create(name, namelen, NULL);
@@ -292,6 +284,7 @@ tunmodevent(module_t mod, int type, void
 	case MOD_UNLOAD:
 		if_clone_detach(&tun_cloner);
 		EVENTHANDLER_DEREGISTER(dev_clone, tag);
+		drain_dev_clone_events();
 
 		mtx_lock(&tunmtx);
 		while ((tp = TAILQ_FIRST(&tunhead)) != NULL) {


More information about the svn-src-all mailing list