Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Dec 2004 11:52:40 +0100
From:      Andre Oppermann <andre@freebsd.org>
To:        Alfred Perlstein <alfred@freebsd.org>
Cc:        cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/netinet ip_fw2.c
Message-ID:  <41BAD178.EFFB4D6F@freebsd.org>
References:  <200412100217.iBA2HI2L008474@repoman.freebsd.org> <20041211070959.GT20783@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Alfred Perlstein wrote:
> 
> * Christian S.J. Peron <csjp@FreeBSD.org> [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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41BAD178.EFFB4D6F>