ether_ifdetach() races round 3(?)

From: John Baldwin (jhb_at_FreeBSD.org)
Date: 11/04/05

  • Next message: kylin: "3 quizz about the freebsd DD arch"
    To: arch@FreeBSD.org
    Date: Fri, 4 Nov 2005 07:52:29 -0500
    
    

    I had another moment of inspiration regarding the ether_ifdetach() races
    during my shower this morning. Maybe this will gives us a viable solution
    this time.

    The reason we are having races is that once we call foo_stop(), the driver
    state is out of sync with the ifnet state because IFF_UP is still set even
    though the driver effectively has marked the interface down. The obvious
    solution to that is to have the ifnet code "officially" mark the driver down
    by clearing IFF_UP. This would result in foo_ioctl() calling foo_stop()
    rather than foo_detach() calling it explicitly. I think this is actually
    cleaner in that drivers already rely on the ifnet layer calling foo_init()
    and don't call foo_init() in foo_attach(). Moving foo_stop() out of
    foo_detach() and into the ifnet layer would thus be more consistent.
    foo_detach() would go from:

            if (device_is_attached(sc)) {
                    FOO_LOCK(sc);
                    foo_stop(sc);
                    FOO_UNLOCK(sc);
                    callout_drain(&sc->sc_stat_callout);
                    ether_ifdetach(sc->sc_ifp);
            }

    to just:

            if (device_is_attached(sc)) {
                    ether_ifdetach(sc->sc_ifp);
                    callout_drain(&sc->sc_stat_callout);
            }

    The only question then is when should ether_ifdetach() mark the interface as
    down, and this actually ends up nice as it lets us fix all the other races
    with BPF and userland ioctls. Basically, we should detach the ifnet from
    userland so no more userland requests can come in, then tear down kernel
    consumers such as BPF, and mark the interface down resulting in an ioctl()
    that clears IFF_UP and calls foo_stop().

    -- 
    John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
    "Power Users Use the Power to Serve"  =  http://www.FreeBSD.org
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"
    

  • Next message: kylin: "3 quizz about the freebsd DD arch"

    Relevant Pages

    • Re: Most realistic physics?
      ... won races on was the FLMS 7-10 server. ... It 'guides' the car to the NR2003 virtual ... good driver and end up winning if things work out right. ... race open setups, ...
      (rec.autos.simulators)
    • Re: NASCAR scoring loop data
      ... Sum of driver position on each lap - divided by the laps run in the ... Rank Car No. Driver Races Started Avg place ... Positions improved in the last 10 percent of laps in each race. ... Rank Car No. Driver Average Spots Gained Positions Moved Up ...
      (rec.autos.sport.nascar.moderated)
    • Re: Most realistic physics?
      ... won races on was the FLMS 7-10 server. ... good driver and end up winning if things work out right. ... drafting forces the cars to be close and minimizes the differences in driver ... Having all the assists on reduces required skills even more. ...
      (rec.autos.simulators)
    • Re: Jeff Gordon Passes Out
      ... to match DE's 7 Championships because of the change to ... The Chase Reset of points (& now expansion to 12 drivers ... driver to win championships. ... leads dwindle through the last races of the year. ...
      (rec.autos.sport.nascar)
    • Re: Re:Ol Jeffer
      ... > driver, good crew chief, and good technology when the old timers between ... > car, downforce magically injected into the car during the race by bending ... How many races and championships did Dale Sr. ...
      (rec.autos.sport.nascar)