Module Name:    src
Committed By:   ozaki-r
Date:           Tue Jan 24 07:09:25 UTC 2017

Modified Files:
        src/sys/netinet: if_arp.c igmp.c ip_icmp.c ip_input.c ip_mroute.c
            raw_ip.c tcp_usrreq.c udp_usrreq.c
        src/sys/netinet6: dccp6_usrreq.c frag6.c in6_ifattach.c ip6_mroute.c
            mld6.c raw_ip6.c udp6_usrreq.c

Log Message:
Tweak softnet_lock and NET_MPSAFE

- Don't hold softnet_lock in some functions if NET_MPSAFE
- Add softnet_lock to sysctl_net_inet_icmp_redirtimeout
- Add softnet_lock to expire_upcalls of ip_mroute.c
- Restore softnet_lock for in{,6}_pcbpurgeif{,0} if NET_MPSAFE
- Mark some softnet_lock for future work


To generate a diff of this commit:
cvs rdiff -u -r1.239 -r1.240 src/sys/netinet/if_arp.c
cvs rdiff -u -r1.63 -r1.64 src/sys/netinet/igmp.c
cvs rdiff -u -r1.154 -r1.155 src/sys/netinet/ip_icmp.c
cvs rdiff -u -r1.347 -r1.348 src/sys/netinet/ip_input.c
cvs rdiff -u -r1.145 -r1.146 src/sys/netinet/ip_mroute.c
cvs rdiff -u -r1.161 -r1.162 src/sys/netinet/raw_ip.c
cvs rdiff -u -r1.213 -r1.214 src/sys/netinet/tcp_usrreq.c
cvs rdiff -u -r1.229 -r1.230 src/sys/netinet/udp_usrreq.c
cvs rdiff -u -r1.10 -r1.11 src/sys/netinet6/dccp6_usrreq.c
cvs rdiff -u -r1.59 -r1.60 src/sys/netinet6/frag6.c
cvs rdiff -u -r1.109 -r1.110 src/sys/netinet6/in6_ifattach.c
cvs rdiff -u -r1.115 -r1.116 src/sys/netinet6/ip6_mroute.c
cvs rdiff -u -r1.79 -r1.80 src/sys/netinet6/mld6.c
cvs rdiff -u -r1.154 -r1.155 src/sys/netinet6/raw_ip6.c
cvs rdiff -u -r1.126 -r1.127 src/sys/netinet6/udp6_usrreq.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/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.239 src/sys/netinet/if_arp.c:1.240
--- src/sys/netinet/if_arp.c:1.239	Sat Jan 21 11:07:46 2017
+++ src/sys/netinet/if_arp.c	Tue Jan 24 07:09:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.239 2017/01/21 11:07:46 maxv Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.240 2017/01/24 07:09:24 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.239 2017/01/21 11:07:46 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.240 2017/01/24 07:09:24 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1676,8 +1676,10 @@ arp_dad_timer(struct ifaddr *ifa)
 	struct dadq *dp;
 	char ipbuf[INET_ADDRSTRLEN];
 
+#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
 	KERNEL_LOCK(1, NULL);
+#endif
 	mutex_enter(&arp_dad_lock);
 
 	/* Sanity check */
@@ -1767,8 +1769,10 @@ announce:
 
 done:
 	mutex_exit(&arp_dad_lock);
+#ifndef NET_MPSAFE
 	KERNEL_UNLOCK_ONE(NULL);
 	mutex_exit(softnet_lock);
+#endif
 }
 
 static void

Index: src/sys/netinet/igmp.c
diff -u src/sys/netinet/igmp.c:1.63 src/sys/netinet/igmp.c:1.64
--- src/sys/netinet/igmp.c:1.63	Wed Jan 11 13:08:29 2017
+++ src/sys/netinet/igmp.c	Tue Jan 24 07:09:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: igmp.c,v 1.63 2017/01/11 13:08:29 ozaki-r Exp $	*/
+/*	$NetBSD: igmp.c,v 1.64 2017/01/24 07:09:24 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -40,10 +40,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.63 2017/01/11 13:08:29 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igmp.c,v 1.64 2017/01/24 07:09:24 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
+#include "opt_net_mpsafe.h"
 #endif
 
 #include <sys/param.h>
@@ -541,8 +542,10 @@ igmp_fasttimo(void)
 		return;
 	}
 
+#ifndef NET_MPSAFE
 	/* XXX: Needed for ip_output(). */
 	mutex_enter(softnet_lock);
+#endif
 
 	in_multi_lock(RW_WRITER);
 	igmp_timers_on = false;
@@ -566,7 +569,9 @@ igmp_fasttimo(void)
 		inm = in_next_multi(&step);
 	}
 	in_multi_unlock();
+#ifndef NET_MPSAFE
 	mutex_exit(softnet_lock);
+#endif
 }
 
 void
@@ -649,7 +654,9 @@ igmp_sendpkt(struct in_multi *inm, int t
 	 * Note: IP_IGMP_MCAST indicates that in_multilock is held.
 	 * The caller must still acquire softnet_lock for ip_output().
 	 */
+#ifndef NET_MPSAFE
 	KASSERT(mutex_owned(softnet_lock));
+#endif
 	ip_output(m, NULL, NULL, IP_IGMP_MCAST, &imo, NULL);
 	IGMP_STATINC(IGMP_STAT_SND_REPORTS);
 }

Index: src/sys/netinet/ip_icmp.c
diff -u src/sys/netinet/ip_icmp.c:1.154 src/sys/netinet/ip_icmp.c:1.155
--- src/sys/netinet/ip_icmp.c:1.154	Mon Dec 12 03:55:57 2016
+++ src/sys/netinet/ip_icmp.c	Tue Jan 24 07:09:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_icmp.c,v 1.154 2016/12/12 03:55:57 ozaki-r Exp $	*/
+/*	$NetBSD: ip_icmp.c,v 1.155 2017/01/24 07:09:24 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -94,7 +94,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.154 2016/12/12 03:55:57 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.155 2017/01/24 07:09:24 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -105,6 +105,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 
 #include <sys/mbuf.h>
 #include <sys/protosw.h>
 #include <sys/socket.h>
+#include <sys/socketvar.h> /* For softnet_lock */
 #include <sys/kmem.h>
 #include <sys/time.h>
 #include <sys/kernel.h>
@@ -1012,6 +1013,9 @@ sysctl_net_inet_icmp_redirtimeout(SYSCTL
 		return (EINVAL);
 	icmp_redirtimeout = tmp;
 
+	/* XXX NOMPSAFE still need softnet_lock */
+	mutex_enter(softnet_lock);
+
 	/*
 	 * was it a *defined* side-effect that anyone even *reading*
 	 * this value causes these things to happen?
@@ -1029,6 +1033,8 @@ sysctl_net_inet_icmp_redirtimeout(SYSCTL
 		    rt_timer_queue_create(icmp_redirtimeout);
 	}
 
+	mutex_exit(softnet_lock);
+
 	return (0);
 }
 

Index: src/sys/netinet/ip_input.c
diff -u src/sys/netinet/ip_input.c:1.347 src/sys/netinet/ip_input.c:1.348
--- src/sys/netinet/ip_input.c:1.347	Mon Dec 12 03:55:57 2016
+++ src/sys/netinet/ip_input.c	Tue Jan 24 07:09:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.347 2016/12/12 03:55:57 ozaki-r Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.348 2017/01/24 07:09:24 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.347 2016/12/12 03:55:57 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.348 2017/01/24 07:09:24 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -866,13 +866,17 @@ void
 ip_slowtimo(void)
 {
 
+#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
 	KERNEL_LOCK(1, NULL);
+#endif
 
 	ip_reass_slowtimo();
 
+#ifndef NET_MPSAFE
 	KERNEL_UNLOCK_ONE(NULL);
 	mutex_exit(softnet_lock);
+#endif
 }
 
 /*
@@ -1603,6 +1607,7 @@ sysctl_net_inet_ip_pmtudto(SYSCTLFN_ARGS
 	if (tmp < 0)
 		return (EINVAL);
 
+	/* XXX NOMPSAFE still need softnet_lock */
 	mutex_enter(softnet_lock);
 
 	ip_mtudisc_timeout = tmp;

Index: src/sys/netinet/ip_mroute.c
diff -u src/sys/netinet/ip_mroute.c:1.145 src/sys/netinet/ip_mroute.c:1.146
--- src/sys/netinet/ip_mroute.c:1.145	Wed Jan 11 13:08:29 2017
+++ src/sys/netinet/ip_mroute.c	Tue Jan 24 07:09:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_mroute.c,v 1.145 2017/01/11 13:08:29 ozaki-r Exp $	*/
+/*	$NetBSD: ip_mroute.c,v 1.146 2017/01/24 07:09:24 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.145 2017/01/11 13:08:29 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.146 2017/01/24 07:09:24 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1561,9 +1561,10 @@ static void
 expire_upcalls(void *v)
 {
 	int i;
-	int s;
 
-	s = splsoftnet();
+	/* XXX NOMPSAFE still need softnet_lock */
+	mutex_enter(softnet_lock);
+	KERNEL_LOCK(1, NULL);
 
 	for (i = 0; i < MFCTBLSIZ; i++) {
 		struct mfc *rt, *nrt;
@@ -1599,9 +1600,11 @@ expire_upcalls(void *v)
 		}
 	}
 
-	splx(s);
 	callout_reset(&expire_upcalls_ch, EXPIRE_TIMEOUT,
 	    expire_upcalls, NULL);
+
+	KERNEL_UNLOCK_ONE(NULL);
+	mutex_exit(softnet_lock);
 }
 
 /*

Index: src/sys/netinet/raw_ip.c
diff -u src/sys/netinet/raw_ip.c:1.161 src/sys/netinet/raw_ip.c:1.162
--- src/sys/netinet/raw_ip.c:1.161	Thu Sep 29 12:19:47 2016
+++ src/sys/netinet/raw_ip.c	Tue Jan 24 07:09:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip.c,v 1.161 2016/09/29 12:19:47 roy Exp $	*/
+/*	$NetBSD: raw_ip.c,v 1.162 2017/01/24 07:09:24 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,13 +65,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.161 2016/09/29 12:19:47 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.162 2017/01/24 07:09:24 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
 #include "opt_compat_netbsd.h"
 #include "opt_ipsec.h"
 #include "opt_mrouting.h"
+#include "opt_net_mpsafe.h"
 #endif
 
 #include <sys/param.h>
@@ -806,7 +807,13 @@ rip_purgeif(struct socket *so, struct if
 	s = splsoftnet();
 	mutex_enter(softnet_lock);
 	in_pcbpurgeif0(&rawcbtable, ifp);
+#ifdef NET_MPSAFE
+	mutex_exit(softnet_lock);
+#endif
 	in_purgeif(ifp);
+#ifdef NET_MPSAFE
+	mutex_enter(softnet_lock);
+#endif
 	in_pcbpurgeif(&rawcbtable, ifp);
 	mutex_exit(softnet_lock);
 	splx(s);

Index: src/sys/netinet/tcp_usrreq.c
diff -u src/sys/netinet/tcp_usrreq.c:1.213 src/sys/netinet/tcp_usrreq.c:1.214
--- src/sys/netinet/tcp_usrreq.c:1.213	Fri Nov 18 06:50:04 2016
+++ src/sys/netinet/tcp_usrreq.c	Tue Jan 24 07:09:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_usrreq.c,v 1.213 2016/11/18 06:50:04 knakahara Exp $	*/
+/*	$NetBSD: tcp_usrreq.c,v 1.214 2017/01/24 07:09:24 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -99,7 +99,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.213 2016/11/18 06:50:04 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.214 2017/01/24 07:09:24 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1210,21 +1210,31 @@ tcp_purgeif(struct socket *so, struct if
 
 	s = splsoftnet();
 
-#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
-#endif
 	switch (so->so_proto->pr_domain->dom_family) {
 #ifdef INET
 	case PF_INET:
 		in_pcbpurgeif0(&tcbtable, ifp);
+#ifdef NET_MPSAFE
+		mutex_exit(softnet_lock);
+#endif
 		in_purgeif(ifp);
+#ifdef NET_MPSAFE
+		mutex_enter(softnet_lock);
+#endif
 		in_pcbpurgeif(&tcbtable, ifp);
 		break;
 #endif
 #ifdef INET6
 	case PF_INET6:
 		in6_pcbpurgeif0(&tcbtable, ifp);
+#ifdef NET_MPSAFE
+		mutex_exit(softnet_lock);
+#endif
 		in6_purgeif(ifp);
+#ifdef NET_MPSAFE
+		mutex_enter(softnet_lock);
+#endif
 		in6_pcbpurgeif(&tcbtable, ifp);
 		break;
 #endif
@@ -1232,9 +1242,7 @@ tcp_purgeif(struct socket *so, struct if
 		error = EAFNOSUPPORT;
 		break;
 	}
-#ifndef NET_MPSAFE
 	mutex_exit(softnet_lock);
-#endif
 	splx(s);
 
 	return error;

Index: src/sys/netinet/udp_usrreq.c
diff -u src/sys/netinet/udp_usrreq.c:1.229 src/sys/netinet/udp_usrreq.c:1.230
--- src/sys/netinet/udp_usrreq.c:1.229	Fri Nov 18 06:50:04 2016
+++ src/sys/netinet/udp_usrreq.c	Tue Jan 24 07:09:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: udp_usrreq.c,v 1.229 2016/11/18 06:50:04 knakahara Exp $	*/
+/*	$NetBSD: udp_usrreq.c,v 1.230 2017/01/24 07:09:24 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.229 2016/11/18 06:50:04 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.230 2017/01/24 07:09:24 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1140,15 +1140,17 @@ udp_purgeif(struct socket *so, struct if
 	int s;
 
 	s = splsoftnet();
-#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
-#endif
 	in_pcbpurgeif0(&udbtable, ifp);
+#ifdef NET_MPSAFE
+	mutex_exit(softnet_lock);
+#endif
 	in_purgeif(ifp);
+#ifdef NET_MPSAFE
+	mutex_enter(softnet_lock);
+#endif
 	in_pcbpurgeif(&udbtable, ifp);
-#ifndef NET_MPSAFE
 	mutex_exit(softnet_lock);
-#endif
 	splx(s);
 
 	return 0;

Index: src/sys/netinet6/dccp6_usrreq.c
diff -u src/sys/netinet6/dccp6_usrreq.c:1.10 src/sys/netinet6/dccp6_usrreq.c:1.11
--- src/sys/netinet6/dccp6_usrreq.c:1.10	Tue Dec 13 08:29:03 2016
+++ src/sys/netinet6/dccp6_usrreq.c	Tue Jan 24 07:09:25 2017
@@ -1,5 +1,5 @@
 /*	$KAME: dccp6_usrreq.c,v 1.13 2005/07/27 08:42:56 nishida Exp $	*/
-/*	$NetBSD: dccp6_usrreq.c,v 1.10 2016/12/13 08:29:03 ozaki-r Exp $ */
+/*	$NetBSD: dccp6_usrreq.c,v 1.11 2017/01/24 07:09:25 ozaki-r Exp $ */
 
 /*
  * Copyright (C) 2003 WIDE Project.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dccp6_usrreq.c,v 1.10 2016/12/13 08:29:03 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dccp6_usrreq.c,v 1.11 2017/01/24 07:09:25 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -318,15 +318,17 @@ dccp6_purgeif(struct socket *so, struct 
 	int s;
 
 	s = splsoftnet();
-#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
-#endif
 	in6_pcbpurgeif0(&dccpbtable, ifp);
+#ifdef NET_MPSAFE
+	mutex_exit(softnet_lock);
+#endif
 	in6_purgeif(ifp);
+#ifdef NET_MPSAFE
+	mutex_enter(softnet_lock);
+#endif
 	in6_pcbpurgeif(&dccpbtable, ifp);
-#ifndef NET_MPSAFE
 	mutex_exit(softnet_lock);
-#endif
 	splx(s);
 
 	return 0;

Index: src/sys/netinet6/frag6.c
diff -u src/sys/netinet6/frag6.c:1.59 src/sys/netinet6/frag6.c:1.60
--- src/sys/netinet6/frag6.c:1.59	Wed Jan 11 13:08:29 2017
+++ src/sys/netinet6/frag6.c	Tue Jan 24 07:09:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: frag6.c,v 1.59 2017/01/11 13:08:29 ozaki-r Exp $	*/
+/*	$NetBSD: frag6.c,v 1.60 2017/01/24 07:09:25 ozaki-r Exp $	*/
 /*	$KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $	*/
 
 /*
@@ -31,7 +31,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.59 2017/01/11 13:08:29 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.60 2017/01/24 07:09:25 ozaki-r Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_net_mpsafe.h"
+#endif
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -592,16 +596,21 @@ frag6_remque(struct ip6q *p6)
 void
 frag6_fasttimo(void)
 {
+
+#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
 	KERNEL_LOCK(1, NULL);
+#endif
 
 	if (frag6_drainwanted) {
 		frag6_drain();
 		frag6_drainwanted = 0;
 	}
 
+#ifndef NET_MPSAFE
 	KERNEL_UNLOCK_ONE(NULL);
 	mutex_exit(softnet_lock);
+#endif
 }
 
 /*
@@ -614,8 +623,10 @@ frag6_slowtimo(void)
 {
 	struct ip6q *q6;
 
+#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
 	KERNEL_LOCK(1, NULL);
+#endif
 
 	mutex_enter(&frag6_lock);
 	q6 = ip6q.ip6q_next;
@@ -642,8 +653,10 @@ frag6_slowtimo(void)
 	}
 	mutex_exit(&frag6_lock);
 
+#ifndef NET_MPSAFE
 	KERNEL_UNLOCK_ONE(NULL);
 	mutex_exit(softnet_lock);
+#endif
 
 #if 0
 	/*

Index: src/sys/netinet6/in6_ifattach.c
diff -u src/sys/netinet6/in6_ifattach.c:1.109 src/sys/netinet6/in6_ifattach.c:1.110
--- src/sys/netinet6/in6_ifattach.c:1.109	Wed Jan  4 19:37:14 2017
+++ src/sys/netinet6/in6_ifattach.c	Tue Jan 24 07:09:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_ifattach.c,v 1.109 2017/01/04 19:37:14 christos Exp $	*/
+/*	$NetBSD: in6_ifattach.c,v 1.110 2017/01/24 07:09:25 ozaki-r Exp $	*/
 /*	$KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.109 2017/01/04 19:37:14 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.110 2017/01/24 07:09:25 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -860,6 +860,7 @@ in6_tmpaddrtimer(void *ignored_arg)
 	struct ifnet *ifp;
 	int s;
 
+	/* XXX NOMPSAFE still need softnet_lock */
 	mutex_enter(softnet_lock);
 	KERNEL_LOCK(1, NULL);
 

Index: src/sys/netinet6/ip6_mroute.c
diff -u src/sys/netinet6/ip6_mroute.c:1.115 src/sys/netinet6/ip6_mroute.c:1.116
--- src/sys/netinet6/ip6_mroute.c:1.115	Mon Jan 16 15:44:47 2017
+++ src/sys/netinet6/ip6_mroute.c	Tue Jan 24 07:09:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6_mroute.c,v 1.115 2017/01/16 15:44:47 christos Exp $	*/
+/*	$NetBSD: ip6_mroute.c,v 1.116 2017/01/24 07:09:25 ozaki-r Exp $	*/
 /*	$KAME: ip6_mroute.c,v 1.49 2001/07/25 09:21:18 jinmei Exp $	*/
 
 /*
@@ -117,7 +117,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.115 2017/01/16 15:44:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_mroute.c,v 1.116 2017/01/24 07:09:25 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1310,6 +1310,7 @@ expire_upcalls(void *unused)
 	struct mf6c *mfc, **nptr;
 	int i;
 
+	/* XXX NOMPSAFE still need softnet_lock */
 	mutex_enter(softnet_lock);
 	KERNEL_LOCK(1, NULL);
 

Index: src/sys/netinet6/mld6.c
diff -u src/sys/netinet6/mld6.c:1.79 src/sys/netinet6/mld6.c:1.80
--- src/sys/netinet6/mld6.c:1.79	Mon Jan 16 15:44:47 2017
+++ src/sys/netinet6/mld6.c	Tue Jan 24 07:09:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mld6.c,v 1.79 2017/01/16 15:44:47 christos Exp $	*/
+/*	$NetBSD: mld6.c,v 1.80 2017/01/24 07:09:25 ozaki-r Exp $	*/
 /*	$KAME: mld6.c,v 1.25 2001/01/16 14:14:18 itojun Exp $	*/
 
 /*
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.79 2017/01/16 15:44:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.80 2017/01/24 07:09:25 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -229,6 +229,7 @@ mld_timeo(void *arg)
 {
 	struct in6_multi *in6m = arg;
 
+	/* XXX NOMPSAFE still need softnet_lock */
 	mutex_enter(softnet_lock);
 	KERNEL_LOCK(1, NULL);
 
@@ -792,11 +793,10 @@ in6_delmulti(struct in6_multi *in6m)
 
 		/* Tell mld_timeo we're halting the timer */
 		in6m->in6m_timer = IN6M_TIMER_UNDEF;
-#ifdef NET_MPSAFE
-		callout_halt(&in6m->in6m_timer_ch, NULL);
-#else
-		callout_halt(&in6m->in6m_timer_ch, softnet_lock);
-#endif
+		if (mutex_owned(softnet_lock))
+			callout_halt(&in6m->in6m_timer_ch, softnet_lock);
+		else
+			callout_halt(&in6m->in6m_timer_ch, NULL);
 		callout_destroy(&in6m->in6m_timer_ch);
 
 		free(in6m, M_IPMADDR);

Index: src/sys/netinet6/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.154 src/sys/netinet6/raw_ip6.c:1.155
--- src/sys/netinet6/raw_ip6.c:1.154	Tue Dec 13 08:29:03 2016
+++ src/sys/netinet6/raw_ip6.c	Tue Jan 24 07:09:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.154 2016/12/13 08:29:03 ozaki-r Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.155 2017/01/24 07:09:25 ozaki-r Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.154 2016/12/13 08:29:03 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.155 2017/01/24 07:09:25 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -935,15 +935,17 @@ static int
 rip6_purgeif(struct socket *so, struct ifnet *ifp)
 {
 
-#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
-#endif
 	in6_pcbpurgeif0(&raw6cbtable, ifp);
+#ifdef NET_MPSAFE
+	mutex_exit(softnet_lock);
+#endif
 	in6_purgeif(ifp);
+#ifdef NET_MPSAFE
+	mutex_enter(softnet_lock);
+#endif
 	in6_pcbpurgeif(&raw6cbtable, ifp);
-#ifndef NET_MPSAFE
 	mutex_exit(softnet_lock);
-#endif
 
 	return 0;
 }

Index: src/sys/netinet6/udp6_usrreq.c
diff -u src/sys/netinet6/udp6_usrreq.c:1.126 src/sys/netinet6/udp6_usrreq.c:1.127
--- src/sys/netinet6/udp6_usrreq.c:1.126	Fri Nov 18 06:50:04 2016
+++ src/sys/netinet6/udp6_usrreq.c	Tue Jan 24 07:09:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: udp6_usrreq.c,v 1.126 2016/11/18 06:50:04 knakahara Exp $	*/
+/*	$NetBSD: udp6_usrreq.c,v 1.127 2017/01/24 07:09:25 ozaki-r Exp $	*/
 /*	$KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.126 2016/11/18 06:50:04 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.127 2017/01/24 07:09:25 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -912,15 +912,17 @@ static int
 udp6_purgeif(struct socket *so, struct ifnet *ifp)
 {
 
-#ifndef NET_MPSAFE
 	mutex_enter(softnet_lock);
-#endif
 	in6_pcbpurgeif0(&udbtable, ifp);
+#ifdef NET_MPSAFE
+	mutex_exit(softnet_lock);
+#endif
 	in6_purgeif(ifp);
+#ifdef NET_MPSAFE
+	mutex_enter(softnet_lock);
+#endif
 	in6_pcbpurgeif(&udbtable, ifp);
-#ifndef NET_MPSAFE
 	mutex_exit(softnet_lock);
-#endif
 
 	return 0;
 }

Reply via email to