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 stuff in tundetach() to ensure that n...
details: https://anonhg.NetBSD.org/src/rev/5086fe7bff4c
branches: trunk
changeset: 449821:5086fe7bff4c
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Mon Mar 25 09:07:24 2019 +0000
description:
Resequence the stuff in tundetach() to ensure that no new device units
can be created by either 'ifconfig create' or 'open("/dev/tun0")' paths.
Note: previous efforts at fixing 'modunload if_tun' are abandoned, since
there is no bug. Just need to ensure that the cloned interface is both
close(1)d _and_ 'ifconfig tunx destroy' before trying to unload.
diffstat:
sys/net/if_tun.c | 31 +++++++++++++++++++------------
1 files changed, 19 insertions(+), 12 deletions(-)
diffs (55 lines):
diff -r 000a151421e2 -r 5086fe7bff4c sys/net/if_tun.c
--- a/sys/net/if_tun.c Mon Mar 25 07:34:13 2019 +0000
+++ b/sys/net/if_tun.c Mon Mar 25 09:07:24 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tun.c,v 1.153 2019/03/25 04:06:36 msaitoh Exp $ */
+/* $NetBSD: if_tun.c,v 1.154 2019/03/25 09:07:24 pgoyette Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo%cs.nott.ac.uk@localhost>
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.153 2019/03/25 04:06:36 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.154 2019/03/25 09:07:24 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -144,19 +144,26 @@
{
int error = 0;
- if (!LIST_EMPTY(&tun_softc_list) || !LIST_EMPTY(&tunz_softc_list))
- error = EBUSY;
-
+ if_clone_detach(&tun_cloner);
#ifdef _MODULE
- if (error == 0)
- error = devsw_detach(NULL, &tun_cdevsw);
+ error = devsw_detach(NULL, &tun_cdevsw);
+ if (error != 0) {
+ if_clone_attach(&tun_cloner);
+ return error;
+ }
#endif
- if (error == 0) {
- if_clone_detach(&tun_cloner);
- mutex_destroy(&tun_softc_lock);
- }
- return error;
+ if (!LIST_EMPTY(&tun_softc_list) || !LIST_EMPTY(&tunz_softc_list)) {
+#ifdef _MODULE
+ devsw_attach("tun", NULL, &tun_bmajor, &tun_cdevsw, &tun_cmajor);
+#endif
+ if_clone_attach(&tun_cloner);
+ return EBUSY;
+}
+
+ mutex_destroy(&tun_softc_lock);
+
+ return 0;
}
/*
Home |
Main Index |
Thread Index |
Old Index