From 3f765c212e8d1607437a6ce38b69268c39329443 Mon Sep 17 00:00:00 2001 From: ozaki-r Date: Wed, 21 Dec 2016 04:08:47 +0000 Subject: [PATCH] Hold the big locks only where they are needed --- sys/netinet6/nd6.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index c19baac95701..5a3cfce1c7d2 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $NetBSD: nd6.c,v 1.220 2016/12/19 07:51:34 ozaki-r Exp $ */ +/* $NetBSD: nd6.c,v 1.221 2016/12/21 04:08:47 ozaki-r Exp $ */ /* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.220 2016/12/19 07:51:34 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.221 2016/12/21 04:08:47 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -455,11 +455,6 @@ nd6_llinfo_timer(void *arg) bool send_ns = false; const struct in6_addr *daddr6 = NULL; -#ifndef NET_MPSAFE - mutex_enter(softnet_lock); - KERNEL_LOCK(1, NULL); -#endif - LLE_WLOCK(ln); if (ln->ln_ntick > 0) { nd6_llinfo_settimer(ln, ln->ln_ntick); @@ -513,9 +508,18 @@ nd6_llinfo_timer(void *arg) } nd6_free(ln, 0); ln = NULL; - if (m != NULL) + if (m != NULL) { +#ifndef NET_MPSAFE + mutex_enter(softnet_lock); + KERNEL_LOCK(1, NULL); +#endif icmp6_error2(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR, 0, ifp); +#ifndef NET_MPSAFE + KERNEL_UNLOCK_ONE(NULL); + mutex_exit(softnet_lock); +#endif + } } break; case ND6_LLINFO_REACHABLE: @@ -566,16 +570,20 @@ nd6_llinfo_timer(void *arg) psrc = nd6_llinfo_get_holdsrc(ln, &src); LLE_FREE_LOCKED(ln); ln = NULL; +#ifndef NET_MPSAFE + mutex_enter(softnet_lock); + KERNEL_LOCK(1, NULL); +#endif nd6_ns_output(ifp, daddr6, taddr6, psrc, 0); +#ifndef NET_MPSAFE + KERNEL_UNLOCK_ONE(NULL); + mutex_exit(softnet_lock); +#endif } out: if (ln != NULL) LLE_FREE_LOCKED(ln); -#ifndef NET_MPSAFE - KERNEL_UNLOCK_ONE(NULL); - mutex_exit(softnet_lock); -#endif } /*