Network interface RUNNING and UP flags
Maksim Yevmenkin
maksim.yevmenkin at savvis.net
Mon Aug 9 14:14:40 PDT 2004
Hello,
> Here, I pushed that section of code up before the prior
> mtx_unlock(&tp->tap_mtx) above it, then removed the splimp/splx
> calls. Is this what you were referring to (attached)? Also, I noticed
> splx and splimp are called in a number of other places in this
> driver, even under -CURRENT. You want those out too? The patch is a
> patch on the original -CURRENT version of the driver and not a patch
> to the previous patch I received.
ok, the "tap_mtx" lock is used to protect fields which belongs to the
"struct tap_softc". the IFF_xxx flags are set in the "if_flags" field,
which belongs to the "struct ifnet". note that other parts of the system
will access the same "struct ifnet", and, thus separate lock is required
to protect all fields inside the "struct ifnet". currently it is done
(or rather not done) with splimp(9)/splx(9) calls. i guess this will be
fixed some time in the future.
my original patch was not 100% correct. i have attached better (imo)
patch. please try it out, and, if there are no objections, i will commit it.
thanks,
max
-------------- next part --------------
--- if_tap.c.orig Fri Aug 6 15:02:06 2004
+++ if_tap.c Mon Aug 9 13:57:48 2004
@@ -340,7 +340,8 @@
struct thread *td;
{
struct tap_softc *tp = NULL;
- int error;
+ struct ifnet *ifp = NULL;
+ int error, s;
if ((error = suser(td)) != 0)
return (error);
@@ -368,10 +369,15 @@
bcopy(tp->arpcom.ac_enaddr, tp->ether_addr, sizeof(tp->ether_addr));
tp->tap_pid = td->td_proc->p_pid;
tp->tap_flags |= TAP_OPEN;
+ ifp = &tp->tap_if;
mtx_unlock(&tp->tap_mtx);
- TAPDEBUG("%s is open. minor = %#x\n",
- tp->tap_if.if_xname, minor(dev));
+ s = splimp();
+ ifp->if_flags |= IFF_RUNNING;
+ ifp->if_flags &= ~IFF_OACTIVE;
+ splx(s);
+
+ TAPDEBUG("%s is open. minor = %#x\n", ifp->if_xname, minor(dev));
return (0);
} /* tapopen */
More information about the freebsd-hackers
mailing list