From: Patrick McHardy <kaber@trash.net>
To: Krzysztof Piotr Oledzki <ole@ans.pl>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] netfilter: add locking for counters zeroing
Date: Wed, 24 Sep 2008 18:01:00 +0200 [thread overview]
Message-ID: <48DA643C.5000702@trash.net> (raw)
In-Reply-To: <4884bd82.Dh41l9jJY8sI8ajg%ole@ans.pl>
Krzysztof Piotr Oledzki wrote:
>>From 4407c0b11dde5235b1141ef63bc29f322a73c873 Mon Sep 17 00:00:00 2001
> From: Krzysztof Piotr Oledzki <ole@ans.pl>
> Date: Mon, 21 Jul 2008 17:20:45 +0200
> Subject: netfilter: add locking for counters zeroing
>
> The memset inside ctnetlink_dump_table() fuction needs locking.
> The lock shoud be grabbed outside the loop to avoid repeatedly
> taking and releasing it again.
>
> Also add similar locking inside xt_connbytes match where
> the counters get read.
Sorry for the delay. About the patch:
>
> diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
> index 9432da4..ff1bbb0 100644
> --- a/net/netfilter/nf_conntrack_netlink.c
> +++ b/net/netfilter/nf_conntrack_netlink.c
> @@ -545,6 +545,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
> u_int8_t l3proto = nfmsg->nfgen_family;
>
> rcu_read_lock();
> + spin_lock_bh(&nf_conntrack_lock);
We only need the spinlock. I'm not so happy about taking it
unconditionally even though we might not be zeroing the
counters. Moving it in the inner loop will greatly increase
the amount of locks/unlocks on the other hand.
How about moving the inner loop to a new function and adding
back the ctnetlink_dump_counterzero (or whatever it was called)
function? It would take the spinlock, while normal dumping
would only use rcu_read_lock().
next prev parent reply other threads:[~2008-09-24 16:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-21 16:46 [PATCH] netfilter: add locking for counters zeroing Krzysztof Piotr Oledzki
2008-09-24 16:01 ` Patrick McHardy [this message]
2008-09-24 16:08 ` Jan Engelhardt
2008-09-24 16:11 ` Patrick McHardy
2008-09-24 16:27 ` Jan Engelhardt
2008-09-24 16:42 ` Patrick McHardy
2008-09-24 16:57 ` Patrick McHardy
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=48DA643C.5000702@trash.net \
--to=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=ole@ans.pl \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox