Source-Changes-HG archive

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

[src/trunk]: src/sys/net Avoid scheduling more slow timeouts while we are in ...



details:   https://anonhg.NetBSD.org/src/rev/786faf30b45c
branches:  trunk
changeset: 334855:786faf30b45c
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Dec 11 14:33:22 2014 +0000

description:
Avoid scheduling more slow timeouts while we are in the process of detaching
the interface: set if_slowtimo to NULL before doing the callout_halt()
and test for that in the callout. Fixes PR kern/49462.

diffstat:

 sys/net/if.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (49 lines):

diff -r 95aab4f6e869 -r 786faf30b45c sys/net/if.c
--- a/sys/net/if.c      Thu Dec 11 12:21:44 2014 +0000
+++ b/sys/net/if.c      Thu Dec 11 14:33:22 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.304 2014/12/08 04:55:47 ozaki-r Exp $ */
+/*     $NetBSD: if.c,v 1.305 2014/12/11 14:33:22 martin Exp $  */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.304 2014/12/08 04:55:47 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.305 2014/12/11 14:33:22 martin Exp $");
 
 #include "opt_inet.h"
 
@@ -745,6 +745,7 @@
        s = splnet();
 
        if (ifp->if_slowtimo != NULL) {
+               ifp->if_slowtimo = NULL;
                callout_halt(ifp->if_slowtimo_ch, NULL);
                callout_destroy(ifp->if_slowtimo_ch);
                kmem_free(ifp->if_slowtimo_ch, sizeof(*ifp->if_slowtimo_ch));
@@ -1515,15 +1516,19 @@
 if_slowtimo(void *arg)
 {
        struct ifnet *ifp = arg;
-       int s = splnet();
+       int s;
 
-       KASSERT(ifp->if_slowtimo != NULL);
+       if (__predict_false(ifp->if_slowtimo == NULL))
+               return;
 
+       s = splnet();
        if (ifp->if_timer != 0 && --ifp->if_timer == 0)
                (*ifp->if_slowtimo)(ifp);
 
        splx(s);
-       callout_schedule(ifp->if_slowtimo_ch, hz / IFNET_SLOWHZ);
+
+       if (__predict_true(ifp->if_slowtimo != NULL))
+               callout_schedule(ifp->if_slowtimo_ch, hz / IFNET_SLOWHZ);
 }
 
 /*



Home | Main Index | Thread Index | Old Index