From 527e4a212528eb64553709ba0116c0b80968ec7e Mon Sep 17 00:00:00 2001 From: Alex Hornung Date: Sun, 30 Aug 2009 18:44:30 +0100 Subject: [PATCH] tap - Don't make_dev if dev already exists * If the unit already exists when calling tap_clone_create, find the corresponding cdev by calling devfs_find_device_by_name. * If the unit doesn't exist, call make_dev. * Assert that dev != NULL before calling tapcreate() Dragonfly-bug: http://bugs.dragonflybsd.org/issue1453 Reported-By: Rumko --- sys/net/tap/if_tap.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/net/tap/if_tap.c b/sys/net/tap/if_tap.c index 8fc6964400..7d2e160745 100644 --- a/sys/net/tap/if_tap.c +++ b/sys/net/tap/if_tap.c @@ -288,9 +288,15 @@ tap_clone_create(struct if_clone *ifc __unused, int unit) tp = tapfind(unit); if (tp == NULL) { - devfs_clone_bitmap_set(&DEVFS_CLONE_BITMAP(tap), unit); - dev = make_dev(&tap_ops, unit, UID_ROOT, GID_WHEEL, - 0600, "%s%d", TAP, unit); + if (!devfs_clone_bitmap_chk(&DEVFS_CLONE_BITMAP(tap), unit)) { + devfs_clone_bitmap_set(&DEVFS_CLONE_BITMAP(tap), unit); + dev = make_dev(&tap_ops, unit, UID_ROOT, GID_WHEEL, + 0600, "%s%d", TAP, unit); + } else { + dev = devfs_find_device_by_name("%s%d", TAP, unit); + } + + KKASSERT(dev != NULL); tp = tapcreate(unit, dev); } tp->tap_flags |= TAP_CLONE; -- 2.41.0