Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 Hold the big locks only where they are needed



details:   https://anonhg.NetBSD.org/src/rev/814dfff01140
branches:  trunk
changeset: 819876:814dfff01140
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Dec 21 04:08:47 2016 +0000

description:
Hold the big locks only where they are needed

diffstat:

 sys/netinet6/nd6.c |  32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)

diffs (75 lines):

diff -r b36536196f84 -r 814dfff01140 sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c        Wed Dec 21 04:01:57 2016 +0000
+++ b/sys/netinet6/nd6.c        Wed Dec 21 04:08:47 2016 +0000
@@ -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 <sys/cdefs.h>
-__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 @@
        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_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 @@
                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
 }
 
 /*



Home | Main Index | Thread Index | Old Index