From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Yasuyuki KOZAKAI <yasuyuki.kozakai@toshiba.co.jp>
Cc: laforge@netfilter.org, netfilter-devel@lists.netfilter.org,
kaber@trash.net
Subject: Re: [PATCH 3/3][CONNTRACK] Fix race condition in early drop
Date: Tue, 22 Aug 2006 15:46:50 +0200 [thread overview]
Message-ID: <44EB0ACA.8080109@netfilter.org> (raw)
In-Reply-To: <200608220435.k7M4ZSLf001686@toshiba.co.jp>
Hi Yasuyuki,
Yasuyuki KOZAKAI wrote:
> From: Pablo Neira Ayuso <pablo@netfilter.org>
> Date: Mon, 21 Aug 2006 10:47:49 +0200
>
>>[CONNTRACK] Fix race condition in early drop
>>
>>On SMP environments the maximum number of conntracks can be overpassed
>>under heavy stress situations due to an existing race condition.
>>
>> CPU A CPU B
>> atomic_read() ...
>> early_drop() ...
>> ... atomic_read()
>> allocate conntrack allocate conntrack
>> atomic_inc() atomic_inc()
>>
[snip]
>
> I think there is unfair case like following.
>
> CPU A CPU B
> atomic_add_unless() == 0
> early_drop() ...
> ... atomic_add_unless() == 1
> atomic_add_unless() == 0
> early_drop()
>
> The right to allocate conntrack is stolen by CPU B in this case.
Yes, but we're under stress so I'm not sure if fairness is important here.
> And there is no assurance that CPU A can exits this loop in short time.
You are right, this seems important. Instead of looping we can just give
up if we lose race.
> How about incrementing {ip,nf}_conntrack_count at first ?
>
> 1. atomic_add()
> 2. if {ip,nf}_conntrack_count > {ip,nf}_conntrack_max (not '>=' )
> then early_drop()
> 3. if early_drop() failed, atomic_dec()
I thought about this possibility but then we can't guarantee the fixed
maximum number of conntracks in the system.
Any comments?
--
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
next prev parent reply other threads:[~2006-08-22 13:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-21 8:47 [PATCH 3/3][CONNTRACK] Fix race condition in early drop Pablo Neira Ayuso
2006-08-22 4:35 ` Yasuyuki KOZAKAI
[not found] ` <200608220435.k7M4ZSLf001686@toshiba.co.jp>
2006-08-22 13:46 ` Pablo Neira Ayuso [this message]
2006-08-22 14:39 ` Pablo Neira Ayuso
[not found] ` <200608230228.k7N2SDTf000802@toshiba.co.jp>
2006-08-23 4:38 ` Patrick McHardy
2006-08-23 2:28 ` Yasuyuki KOZAKAI
2006-08-24 11:47 ` Jarek Poplawski
2006-08-24 13:02 ` Jarek Poplawski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44EB0ACA.8080109@netfilter.org \
--to=pablo@netfilter.org \
--cc=kaber@trash.net \
--cc=laforge@netfilter.org \
--cc=netfilter-devel@lists.netfilter.org \
--cc=yasuyuki.kozakai@toshiba.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.