NetBSD-Bugs archive

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

Re: kern/49462: if_slowtimo callout mangled?



The following reply was made to PR kern/49462; it has been noted by GNATS.

From: Martin Husemann <martin%duskware.de@localhost>
To: Ryota Ozaki <ozaki-r%netbsd.org@localhost>
Cc: gnats-bugs%netbsd.org@localhost
Subject: Re: kern/49462: if_slowtimo callout mangled?
Date: Thu, 11 Dec 2014 10:38:07 +0100

 --Q68bSM7Ycu6FN28Q
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Ok, how about this change?
 Seems to fix it for me.
 
 Martin
 
 --Q68bSM7Ycu6FN28Q
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="if_slowtimo.patch"
 
 Index: if.c
 ===================================================================
 RCS file: /cvsroot/src/sys/net/if.c,v
 retrieving revision 1.304
 diff -u -p -r1.304 if.c
 --- if.c	8 Dec 2014 04:55:47 -0000	1.304
 +++ if.c	11 Dec 2014 09:36:53 -0000
 @@ -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);
  }
  
  /*
 
 --Q68bSM7Ycu6FN28Q--
 


Home | Main Index | Thread Index | Old Index