[PATCH] Fix a few nits in ate(4)

John Baldwin jhb at freebsd.org
Thu Nov 19 22:01:38 UTC 2009


On Thursday 19 November 2009 4:19:17 pm M. Warner Losh wrote:
> In message: <200911191122.02975.jhb at freebsd.org>
>             John Baldwin <jhb at FreeBSD.org> writes:
> : @@ -1109,11 +1105,9 @@
> :  				    & (IFF_PROMISC | IFF_ALLMULTI)) != 0)
> :  					ate_rxfilter(sc);
> :  			} else {
> : -				if ((sc->flags & ATE_FLAG_DETACHING) == 0)
> : -					ateinit_locked(sc);
> : +				ateinit_locked(sc);
> 
> Here we reinitialize the device just before we detach it.  I put the
> detaching stuff in to prevent that.  With this change, are you saying
> this routine won't be called, so we don't need this check anymore?

Basically, yes.  More to the point, the previous order of calling atestop() 
before ether_ifdetach() opened up a race wherein userland (or bpf_detach() 
within if_detach()) could cause this to get invoked after atestop() had been 
called.  Now that we call ether_ifdetach() first, we know that neither bpf 
nor userland is going to mess with the device anymore, and at that time we 
can safely call atestop().  That now removes the need for doing this check.

> :  			}
> :  		} else if ((drv_flags & IFF_DRV_RUNNING) != 0) {
> : -			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
> :  			atestop(sc);
> :  		}
> :  		sc->if_flags = flags;
> 
> Why remove this line?  I think it is kinda needed.  I don't understand.

It is a duplicate of the first line of atestop().

-- 
John Baldwin


More information about the freebsd-arm mailing list