From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 9 21:47:36 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6E75F16A4CE for ; Mon, 9 Aug 2004 21:47:36 +0000 (GMT) Received: from koala.domainit.com (koala.domainit.com [206.21.217.15]) by mx1.FreeBSD.org (Postfix) with SMTP id F33E143D2D for ; Mon, 9 Aug 2004 21:47:35 +0000 (GMT) (envelope-from cokane@cokane.org) Received: (qmail 17611 invoked by uid 85); 9 Aug 2004 21:50:30 -0000 X-Remote-IP: 216.196.247.106 Received: from ddsl-216-196-247-106.fuse.net (HELO ?192.168.2.251?) (216.196.247.106) by mail.domainit.com with SMTP; 9 Aug 2004 21:50:30 -0000 From: Coleman To: Maksim Yevmenkin In-Reply-To: <4117E93D.8060100@savvis.net> References: <346a8022040806145018a5e18@mail.gmail.com> <1091862376.7840.3.camel@berloga.shadowland> <20040807092347.GB39835@comp.chem.msu.su> <1092084486.65806.12.camel@schemer> <4117E93D.8060100@savvis.net> Content-Type: text/plain Message-Id: <1092088073.65806.29.camel@schemer> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 09 Aug 2004 17:47:54 -0400 Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Tue, 10 Aug 2004 11:40:49 +0000 cc: hackers@freebsd.org cc: Yar Tikhiy cc: Alex Lyashkov Subject: Re: Network interface RUNNING and UP flags X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Aug 2004 21:47:36 -0000 Ah yes, now I see. There is no mutex on struct ifnet then? And I suppose those splimp/splx calls should remain. I'll look at whats available and relay my findings to you guys. On Mon, 2004-08-09 at 17:14, Maksim Yevmenkin wrote: > 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 > > > ______________________________________________________________________ > --- 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 */