Module Name: src Committed By: martin Date: Thu Dec 11 14:33:22 UTC 2014
Modified Files: src/sys/net: if.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.304 -r1.305 src/sys/net/if.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if.c diff -u src/sys/net/if.c:1.304 src/sys/net/if.c:1.305 --- src/sys/net/if.c:1.304 Mon Dec 8 04:55:47 2014 +++ src/sys/net/if.c Thu Dec 11 14:33:22 2014 @@ -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 @@ if_detach(struct ifnet *ifp) 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 @@ static void 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); } /*