From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pablo Neira Ayuso Subject: Re: [PATCH 2/2] netfilter: conntrack: optional reliable conntrack event delivery Date: Wed, 10 Jun 2009 12:36:55 +0200 Message-ID: <4A2F8CC7.2010708@netfilter.org> References: <20090604110307.6702.10147.stgit@Decadence> <20090604110841.6702.76228.stgit@Decadence> <4A292DB7.4000000@trash.net> <4A2EE3D2.1090007@netfilter.org> <4A2EE5A3.2000502@trash.net> <4A2EE610.9020207@trash.net> <4A2EE907.70609@netfilter.org> <4A2F09D9.7090507@gmail.com> <4A2F830C.9020403@trash.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Eric Dumazet , netfilter-devel@vger.kernel.org To: Patrick McHardy Return-path: Received: from mail.us.es ([193.147.175.20]:35948 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755668AbZFJKhD (ORCPT ); Wed, 10 Jun 2009 06:37:03 -0400 In-Reply-To: <4A2F830C.9020403@trash.net> Sender: netfilter-devel-owner@vger.kernel.org List-ID: Patrick McHardy wrote: > Eric Dumazet wrote: >> Pablo Neira Ayuso a =E9crit : >>> OK :). Eric, could you tell what if this patch is OK? It's based on= the >>> RCU version. >>> >> Sure, this patch is fine ! >> >> Acked-by: Eric Dumazet >=20 > Thanks Eric. Pablo, please send me those patch as soon as possible, > I plan to send my tree upstream today. Thanks! I'll do in a couple of minutes: I have another issue that you're going to notice in the new patchset, I put it here before posting them if you have time to look at it. I'd like to know if you're OK with this. events =3D xchg(&e->cache, 0); [...] - notify->fcn(events, &item); + ret =3D notify->fcn(events, &item); + if (likely(ret =3D=3D 0)) + delivered =3D 1; + } + if (unlikely(!delivered)) { + unsigned int old =3D 0; +retry: + /* restore undelivered events to the cache */ + ret =3D cmpxchg(&e->cache, old, events); + /* ... but we've got new events during delivery */ + if (unlikely(ret !=3D old)) { + old =3D ret; + events |=3D ret; + goto retry; + } } out_unlock: To avoid races between the cache clearing and event delivery: 1) I retrieve the event cache and clear it with xchg. 2) Then, if I fail to deliver the event, I restore the cache. However, if the event cache is not zero anymore, then some new events have been cached during the delivery, I use cmpxchg to conditionally restore the events without losing the new events. Can you see any problem with this optimistic approach? I know, it can potentially try to restore the cache, but this is very unlikely to happ= en? --=20 "Los honestos son inadaptados sociales" -- Les Luthiers -- To unsubscribe from this list: send the line "unsubscribe netfilter-dev= el" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html