Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 Don't call find_pfxlist_reachable_router, which...



details:   https://anonhg.NetBSD.org/src/rev/5930f16e8b71
branches:  trunk
changeset: 365409:5930f16e8b71
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Tue Aug 14 01:10:58 2018 +0000

description:
Don't call find_pfxlist_reachable_router, which may sleep, in a pserialize read section

Found by knakahara@

diffstat:

 sys/netinet6/nd6_rtr.c |  25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diffs (82 lines):

diff -r b316396033f1 -r 5930f16e8b71 sys/netinet6/nd6_rtr.c
--- a/sys/netinet6/nd6_rtr.c    Tue Aug 14 01:10:47 2018 +0000
+++ b/sys/netinet6/nd6_rtr.c    Tue Aug 14 01:10:58 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nd6_rtr.c,v 1.143 2018/05/19 08:22:58 maxv Exp $       */
+/*     $NetBSD: nd6_rtr.c,v 1.144 2018/08/14 01:10:58 ozaki-r Exp $    */
 /*     $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $        */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.143 2018/05/19 08:22:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.144 2018/08/14 01:10:58 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1586,6 +1586,7 @@
                }
        }
 
+       int bound = curlwp_bind();
        /*
         * Changes on the prefix status might affect address status as well.
         * Make sure that all addresses derived from an attached prefix are
@@ -1596,6 +1597,9 @@
         */
        s = pserialize_read_enter();
        IN6_ADDRLIST_READER_FOREACH(ia) {
+               struct psref psref;
+               bool found;
+
                if (!(ia->ia6_flags & IN6_IFF_AUTOCONF))
                        continue;
 
@@ -1608,14 +1612,19 @@
                        continue;
                }
 
-               if (find_pfxlist_reachable_router(ia->ia6_ndpr))
+               ia6_acquire(ia, &psref);
+               pserialize_read_exit(s);
+
+               found = find_pfxlist_reachable_router(ia->ia6_ndpr) != NULL;
+
+               s = pserialize_read_enter();
+               ia6_release(ia, &psref);
+               if (found)
                        break;
        }
        pserialize_read_exit(s);
 
        if (ia) {
-               int bound = curlwp_bind();
-
                s = pserialize_read_enter();
                IN6_ADDRLIST_READER_FOREACH(ia) {
                        struct ifaddr *ifa = (struct ifaddr *)ia;
@@ -1652,11 +1661,8 @@
                        ia6_release(ia, &psref);
                }
                pserialize_read_exit(s);
-               curlwp_bindx(bound);
        }
        else {
-               int bound = curlwp_bind();
-
                s = pserialize_read_enter();
                IN6_ADDRLIST_READER_FOREACH(ia) {
                        if ((ia->ia6_flags & IN6_IFF_AUTOCONF) == 0)
@@ -1680,8 +1686,9 @@
                        }
                }
                pserialize_read_exit(s);
-               curlwp_bindx(bound);
        }
+
+       curlwp_bindx(bound);
 }
 
 static int



Home | Main Index | Thread Index | Old Index