tap - Don't make_dev if dev already exists
authorAlex Hornung <ahornung@gmail.com>
Sun, 30 Aug 2009 17:44:30 +0000 (18:44 +0100)
committerAlex Hornung <ahornung@gmail.com>
Mon, 31 Aug 2009 09:29:28 +0000 (10:29 +0100)
* 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

index 8fc6964..7d2e160 100644 (file)
@@ -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;