Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Resequence the activities in tapdetach() so that no ...



details:   https://anonhg.NetBSD.org/src/rev/9d7fddcc2ec3
branches:  trunk
changeset: 449823:9d7fddcc2ec3
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Mon Mar 25 09:32:25 2019 +0000

description:
Resequence the activities in tapdetach() so that no new units can be
created, either by opening /dev/tap or ifconfig tapx create, before
checking to see if we have any active units.

diffstat:

 sys/net/if_tap.c |  38 +++++++++++++++++++++++++-------------
 1 files changed, 25 insertions(+), 13 deletions(-)

diffs (62 lines):

diff -r a88d7bd7c6f3 -r 9d7fddcc2ec3 sys/net/if_tap.c
--- a/sys/net/if_tap.c  Mon Mar 25 09:20:46 2019 +0000
+++ b/sys/net/if_tap.c  Mon Mar 25 09:32:25 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tap.c,v 1.107 2018/09/03 16:29:35 riastradh Exp $   */
+/*     $NetBSD: if_tap.c,v 1.108 2019/03/25 09:32:25 pgoyette Exp $    */
 
 /*
  *  Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.107 2018/09/03 16:29:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.108 2019/03/25 09:32:25 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 
@@ -273,20 +273,32 @@
 {
        int error = 0;
 
-       if (tap_count != 0)
-               return EBUSY;
-
+       if_clone_detach(&tap_cloners);
 #ifdef _MODULE
-       if (error == 0)
-               error = devsw_detach(NULL, &tap_cdevsw);
+       error = devsw_detach(NULL, &tap_cdevsw);
+       if (error != 0)
+               goto out2;
 #endif
-       if (error == 0)
-               sysctl_teardown(&tap_sysctl_clog);
-       if (error == 0)
-               if_clone_detach(&tap_cloners);
+
+       if (tap_count != 0) {
+               error = EBUSY;
+               goto out1;
+       }
+
+       error = config_cfattach_detach(tap_cd.cd_name, &tap_ca);
+       if (error != 0)
+               goto out1;
 
-       if (error == 0)
-               error = config_cfattach_detach(tap_cd.cd_name, &tap_ca);
+       sysctl_teardown(&tap_sysctl_clog);
+
+       return 0;
+
+ out1:
+#ifdef _MODULE
+       devsw_attach("tap", NULL, &tap_bmajor, &tap_cdevsw, &tap_cmajor);
+#endif
+ out2:
+       if_clone_attach(&tap_cloners);
 
        return error;
 }



Home | Main Index | Thread Index | Old Index