From owner-cvs-src@FreeBSD.ORG Sat Dec 11 10:52:37 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CE63B16A4D0 for ; Sat, 11 Dec 2004 10:52:37 +0000 (GMT) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id C747143D5C for ; Sat, 11 Dec 2004 10:52:36 +0000 (GMT) (envelope-from andre@freebsd.org) Received: (qmail 1857 invoked from network); 11 Dec 2004 10:42:02 -0000 Received: from unknown (HELO freebsd.org) ([62.48.0.54]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 11 Dec 2004 10:42:02 -0000 Message-ID: <41BAD178.EFFB4D6F@freebsd.org> Date: Sat, 11 Dec 2004 11:52:40 +0100 From: Andre Oppermann X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Alfred Perlstein References: <200412100217.iBA2HI2L008474@repoman.freebsd.org> <20041211070959.GT20783@elvis.mu.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: "Christian S.J. Peron" cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/netinet ip_fw2.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Dec 2004 10:52:38 -0000 Alfred Perlstein wrote: > > * Christian S.J. Peron [041209 18:17] wrote: > > csjp 2004-12-10 02:17:18 UTC > > > > It should be noted that this locking mechanism does not guarantee > > fairness between read and write locks, and that it will favor > > firewall chain readers over writers. This seemed acceptable since > > write operations to firewall chains protected by this lock tend to > > be less frequent than reads. > > > > Reviewed by: andre, rwatson > > Tested by: myself, seanc > > Silence on: ipfw@ > > MFC after: 1 month > > > > Revision Changes Path > > 1.85 +69 -29 src/sys/netinet/ip_fw2.c > > The code I see doesn't appear to work right. > > Can you switch it using sx lock? see the sx_xlock(9) API. > > Specifically: > > static __inline void > IPFW_RLOCK(struct ip_fw_chain *chain) > { > mtx_lock(&chain->mtx); > chain->busy_count++; > mtx_unlock(&chain->mtx); > } > > What if there already is an WLOCK? It doesn't block the > reader. Have a look at IPFW_WLOCK(). It doesn't release the mutex and thus the busy_count++ will never be reached unless IPFW_WUNLOCK is called by the writer. -- Andre