Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 nd6: Take ifnet psref around cprng_fast in nd6_...



details:   https://anonhg.NetBSD.org/src/rev/36f0d79351fe
branches:  trunk
changeset: 369806:36f0d79351fe
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Sep 01 18:32:17 2022 +0000

description:
nd6: Take ifnet psref around cprng_fast in nd6_slowtimo.

This may sleep on an adpative mutex, the global entropy lock, so
pserialize is forbidden.

diffstat:

 sys/netinet6/nd6.c |  9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diffs (44 lines):

diff -r a0953d78422a -r 36f0d79351fe sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c        Thu Sep 01 18:09:45 2022 +0000
+++ b/sys/netinet6/nd6.c        Thu Sep 01 18:32:17 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nd6.c,v 1.278 2021/12/31 12:41:50 andvar Exp $ */
+/*     $NetBSD: nd6.c,v 1.279 2022/09/01 18:32:17 riastradh 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.278 2021/12/31 12:41:50 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.279 2022/09/01 18:32:17 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1534,6 +1534,7 @@
 {
        struct nd_kifinfo *ndi;
        struct ifnet *ifp;
+       struct psref psref;
        int s;
 
        SOFTNET_KERNEL_LOCK_UNLESS_NET_MPSAFE();
@@ -1545,6 +1546,8 @@
                ndi = ND_IFINFO(ifp);
                if (ndi->basereachable && /* already initialized */
                    (ndi->recalctm -= ND6_SLOWTIMER_INTERVAL) <= 0) {
+                       if_acquire(ifp, &psref);
+                       pserialize_read_exit(s);
                        /*
                         * Since reachable time rarely changes by router
                         * advertisements, we SHOULD insure that a new random
@@ -1553,6 +1556,8 @@
                         */
                        ndi->recalctm = nd6_recalc_reachtm_interval;
                        ndi->reachable = ND_COMPUTE_RTIME(ndi->basereachable);
+                       s = pserialize_read_enter();
+                       if_release(ifp, &psref);
                }
        }
        pserialize_read_exit(s);



Home | Main Index | Thread Index | Old Index