Module Name:    src
Committed By:   martin
Date:           Tue Nov 11 12:20:28 UTC 2014

Modified Files:
        src/sys/net [netbsd-7]: if.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #205):
        sys/net/if.c: revision 1.292
PR/49373: Ryota Ozaki: Running if_clone_create and if_clone_destroy in
parallel causes panic
XXX: Pullup 7.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.290.2.1 src/sys/net/if.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.290 src/sys/net/if.c:1.290.2.1
--- src/sys/net/if.c:1.290	Sat Aug  9 05:33:01 2014
+++ src/sys/net/if.c	Tue Nov 11 12:20:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.290 2014/08/09 05:33:01 rtr Exp $	*/
+/*	$NetBSD: if.c,v 1.290.2.1 2014/11/11 12:20:28 martin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.290 2014/08/09 05:33:01 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.290.2.1 2014/11/11 12:20:28 martin Exp $");
 
 #include "opt_inet.h"
 
@@ -164,6 +164,7 @@ static u_int			if_index = 1;
 static size_t			if_indexlim = 0;
 static uint64_t			index_gen;
 static kmutex_t			index_gen_mtx;
+static kmutex_t			if_clone_mtx;
 
 static struct ifaddr **		ifnet_addrs = NULL;
 
@@ -252,6 +253,7 @@ void
 ifinit1(void)
 {
 	mutex_init(&index_gen_mtx, MUTEX_DEFAULT, IPL_NONE);
+	mutex_init(&if_clone_mtx, MUTEX_DEFAULT, IPL_NONE);
 	TAILQ_INIT(&ifnet_list);
 	if_indexlim = 8;
 
@@ -1833,6 +1835,7 @@ doifioctl(struct socket *so, u_long cmd,
 	struct ifreq ifrb;
 	struct oifreq *oifr = NULL;
 #endif
+	int r;
 
 	switch (cmd) {
 #ifdef COMPAT_OIFREQ
@@ -1874,9 +1877,12 @@ doifioctl(struct socket *so, u_long cmd,
 			if (error != 0)
 				return error;
 		}
-		return (cmd == SIOCIFCREATE) ?
+		mutex_enter(&if_clone_mtx);
+		r = (cmd == SIOCIFCREATE) ?
 			if_clone_create(ifr->ifr_name) :
 			if_clone_destroy(ifr->ifr_name);
+		mutex_exit(&if_clone_mtx);
+		return r;
 
 	case SIOCIFGCLONERS:
 		return if_clone_list((struct if_clonereq *)data);

Reply via email to