From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 9 21:14:40 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 9F08216A4CE for ; Mon, 9 Aug 2004 21:14:40 +0000 (GMT) Received: from out001.email.savvis.net (out001.apptix.savvis.net [216.91.32.44]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3841343D2D for ; Mon, 9 Aug 2004 21:14:40 +0000 (GMT) (envelope-from Maksim.Yevmenkin@savvis.net) Received: from s228130hz1ew03.apptix-01.savvis.net ([10.146.4.28]) by out001.email.savvis.net with Microsoft SMTPSVC(6.0.3790.0); Mon, 9 Aug 2004 16:14:39 -0500 Received: from savvis.net ([66.35.239.94]) by s228130hz1ew03.apptix-01.savvis.net with Microsoft SMTPSVC(6.0.3790.0); Mon, 9 Aug 2004 16:14:39 -0500 Message-ID: <4117E93D.8060100@savvis.net> Date: Mon, 09 Aug 2004 14:14:37 -0700 From: Maksim Yevmenkin User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.5) Gecko/20031207 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Coleman References: <346a8022040806145018a5e18@mail.gmail.com> <41140139.5080803@savvis.net> <1091862376.7840.3.camel@berloga.shadowland> <20040807092347.GB39835@comp.chem.msu.su> <1092084486.65806.12.camel@schemer> In-Reply-To: <1092084486.65806.12.camel@schemer> Content-Type: multipart/mixed; boundary="------------080009080300040502030002" X-OriginalArrivalTime: 09 Aug 2004 21:14:39.0408 (UTC) FILETIME=[E1844B00:01C47E55] 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:14:40 -0000 This is a multi-part message in MIME format. --------------080009080300040502030002 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 --------------080009080300040502030002 Content-Type: text/plain; name="if_tap.c.diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="if_tap.c.diff.txt" --- 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 */ --------------080009080300040502030002--