--- if_tap.c.orig 2008-09-08 17:20:57.000000000 -0700 +++ if_tap.c 2008-09-19 15:35:02.000000000 -0700 @@ -94,6 +94,7 @@ static int tapifioctl(struct ifnet *, u_long, caddr_t); static void tapifinit(void *); +static int tap_clone_lookup(struct cdev **, u_short); static int tap_clone_create(struct if_clone *, int, caddr_t); static void tap_clone_destroy(struct ifnet *); static int vmnet_clone_create(struct if_clone *, int, caddr_t); @@ -176,6 +177,28 @@ DEV_MODULE(if_tap, tapmodevent, NULL); static int +tap_clone_lookup(struct cdev **dev, u_short extra) +{ + struct tap_softc *tp; + + mtx_lock(&tapmtx); + SLIST_FOREACH(tp, &taphead, tap_next) { + mtx_lock(&tp->tap_mtx); + if ((tp->tap_flags & (TAP_OPEN|extra)) == extra) { + *dev = tp->tap_dev; + mtx_unlock(&tp->tap_mtx); + mtx_unlock(&tapmtx); + + return (1); + } + mtx_unlock(&tp->tap_mtx); + } + mtx_unlock(&tapmtx); + + return (0); +} + +static int tap_clone_create(struct if_clone *ifc, int unit, caddr_t params) { struct cdev *dev; @@ -353,8 +376,18 @@ /* We're interested in only tap/vmnet devices. */ if (strcmp(name, TAP) == 0) { + if (tap_clone_lookup(dev, 0)) { + dev_ref(*dev); + return; + } + unit = -1; } else if (strcmp(name, VMNET) == 0) { + if (tap_clone_lookup(dev, TAP_VMNET)) { + dev_ref(*dev); + return; + } + unit = -1; extra = VMNET_DEV_MASK; } else if (dev_stdclone(name, NULL, TAP, &unit) != 1) {