* [PATCH] netfilter: add __rcu annotations
@ 2010-11-15 17:21 Eric Dumazet
2010-11-15 17:26 ` Patrick McHardy
2010-11-15 17:44 ` Patrick McHardy
0 siblings, 2 replies; 5+ messages in thread
From: Eric Dumazet @ 2010-11-15 17:21 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Netfilter Development Mailinglist
Use helpers to reduce number of sparse warnings
(CONFIG_SPARSE_RCU_POINTER=y)
remove one variable in amanda, hiding a previous one.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 17 ++++++----
net/ipv4/netfilter/nf_nat_amanda.c | 2 -
net/ipv4/netfilter/nf_nat_core.c | 5 ++
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
index 37f8adb..ab9c05c 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
@@ -20,6 +20,7 @@
#include <net/netfilter/nf_conntrack_l4proto.h>
#include <net/netfilter/nf_conntrack_expect.h>
#include <net/netfilter/nf_conntrack_acct.h>
+#include <linux/rculist_nulls.h>
struct ct_iter_state {
struct seq_net_private p;
@@ -35,7 +36,8 @@ static struct hlist_nulls_node *ct_get_first(struct seq_file *seq)
for (st->bucket = 0;
st->bucket < net->ct.htable_size;
st->bucket++) {
- n = rcu_dereference(net->ct.hash[st->bucket].first);
+ n = rcu_dereference(
+ hlist_nulls_first_rcu(&net->ct.hash[st->bucket]));
if (!is_a_nulls(n))
return n;
}
@@ -48,13 +50,14 @@ static struct hlist_nulls_node *ct_get_next(struct seq_file *seq,
struct net *net = seq_file_net(seq);
struct ct_iter_state *st = seq->private;
- head = rcu_dereference(head->next);
+ head = rcu_dereference(hlist_nulls_next_rcu(head));
while (is_a_nulls(head)) {
if (likely(get_nulls_value(head) == st->bucket)) {
if (++st->bucket >= net->ct.htable_size)
return NULL;
}
- head = rcu_dereference(net->ct.hash[st->bucket].first);
+ head = rcu_dereference(
+ hlist_nulls_first_rcu(&net->ct.hash[st->bucket]));
}
return head;
}
@@ -217,7 +220,8 @@ static struct hlist_node *ct_expect_get_first(struct seq_file *seq)
struct hlist_node *n;
for (st->bucket = 0; st->bucket < nf_ct_expect_hsize; st->bucket++) {
- n = rcu_dereference(net->ct.expect_hash[st->bucket].first);
+ n = rcu_dereference(
+ hlist_first_rcu(&net->ct.expect_hash[st->bucket]));
if (n)
return n;
}
@@ -230,11 +234,12 @@ static struct hlist_node *ct_expect_get_next(struct seq_file *seq,
struct net *net = seq_file_net(seq);
struct ct_expect_iter_state *st = seq->private;
- head = rcu_dereference(head->next);
+ head = rcu_dereference(hlist_next_rcu(head));
while (head == NULL) {
if (++st->bucket >= nf_ct_expect_hsize)
return NULL;
- head = rcu_dereference(net->ct.expect_hash[st->bucket].first);
+ head = rcu_dereference(
+ hlist_first_rcu(&net->ct.expect_hash[st->bucket]));
}
return head;
}
diff --git a/net/ipv4/netfilter/nf_nat_amanda.c b/net/ipv4/netfilter/nf_nat_amanda.c
index 0f23b3f..3d1ac1d 100644
--- a/net/ipv4/netfilter/nf_nat_amanda.c
+++ b/net/ipv4/netfilter/nf_nat_amanda.c
@@ -44,8 +44,6 @@ static unsigned int help(struct sk_buff *skb,
/* Try to get same port: if not, try to change it. */
for (port = ntohs(exp->saved_proto.tcp.port); port != 0; port++) {
- int ret;
-
exp->tuple.dst.u.tcp.port = htons(port);
ret = nf_ct_expect_related(exp);
if (ret == 0)
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
index ab877ac..eb55835 100644
--- a/net/ipv4/netfilter/nf_nat_core.c
+++ b/net/ipv4/netfilter/nf_nat_core.c
@@ -502,7 +502,10 @@ int nf_nat_protocol_register(const struct nf_nat_protocol *proto)
int ret = 0;
spin_lock_bh(&nf_nat_lock);
- if (nf_nat_protos[proto->protonum] != &nf_nat_unknown_protocol) {
+ if (rcu_dereference_protected(
+ nf_nat_protos[proto->protonum],
+ lockdep_is_held(&nf_nat_lock)
+ ) != &nf_nat_unknown_protocol) {
ret = -EBUSY;
goto out;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] netfilter: add __rcu annotations
2010-11-15 17:21 [PATCH] netfilter: add __rcu annotations Eric Dumazet
@ 2010-11-15 17:26 ` Patrick McHardy
2010-11-15 17:32 ` Eric Dumazet
2010-11-15 17:44 ` Patrick McHardy
1 sibling, 1 reply; 5+ messages in thread
From: Patrick McHardy @ 2010-11-15 17:26 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Netfilter Development Mailinglist
On 15.11.2010 18:21, Eric Dumazet wrote:
> Use helpers to reduce number of sparse warnings
> (CONFIG_SPARSE_RCU_POINTER=y)
>
> remove one variable in amanda, hiding a previous one.
nf_ct_expect_related() returns negative errno codes. It still
works, but I prefer the clarity of actually using a signed
variable for this. Unless you have strong feelings about this,
I'll remove that part from the patch.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] netfilter: add __rcu annotations
2010-11-15 17:26 ` Patrick McHardy
@ 2010-11-15 17:32 ` Eric Dumazet
2010-11-15 17:45 ` Patrick McHardy
0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2010-11-15 17:32 UTC (permalink / raw)
To: Patrick McHardy; +Cc: Netfilter Development Mailinglist
Le lundi 15 novembre 2010 à 18:26 +0100, Patrick McHardy a écrit :
> On 15.11.2010 18:21, Eric Dumazet wrote:
> > Use helpers to reduce number of sparse warnings
> > (CONFIG_SPARSE_RCU_POINTER=y)
> >
> > remove one variable in amanda, hiding a previous one.
>
> nf_ct_expect_related() returns negative errno codes. It still
> works, but I prefer the clarity of actually using a signed
> variable for this. Unless you have strong feelings about this,
> I'll remove that part from the patch.
No problem, maybe rename the 2nd variable to avoid a sparse warning ?
net/ipv4/netfilter/nf_nat_amanda.c:47:7: warning: symbol 'ret' shadows
an earlier one
net/ipv4/netfilter/nf_nat_amanda.c:35:15: originally declared here
[PATCH] netfilter/amanda: rename a variable
Avoid a sparse warning about 'ret' variable shadowing
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
net/ipv4/netfilter/nf_nat_amanda.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/netfilter/nf_nat_amanda.c b/net/ipv4/netfilter/nf_nat_amanda.c
index 0f23b3f..703f366 100644
--- a/net/ipv4/netfilter/nf_nat_amanda.c
+++ b/net/ipv4/netfilter/nf_nat_amanda.c
@@ -44,13 +44,13 @@ static unsigned int help(struct sk_buff *skb,
/* Try to get same port: if not, try to change it. */
for (port = ntohs(exp->saved_proto.tcp.port); port != 0; port++) {
- int ret;
+ int res;
exp->tuple.dst.u.tcp.port = htons(port);
- ret = nf_ct_expect_related(exp);
- if (ret == 0)
+ res = nf_ct_expect_related(exp);
+ if (res == 0)
break;
- else if (ret != -EBUSY) {
+ else if (res != -EBUSY) {
port = 0;
break;
}
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] netfilter: add __rcu annotations
2010-11-15 17:21 [PATCH] netfilter: add __rcu annotations Eric Dumazet
2010-11-15 17:26 ` Patrick McHardy
@ 2010-11-15 17:44 ` Patrick McHardy
1 sibling, 0 replies; 5+ messages in thread
From: Patrick McHardy @ 2010-11-15 17:44 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Netfilter Development Mailinglist
Am 15.11.2010 18:21, schrieb Eric Dumazet:
> Use helpers to reduce number of sparse warnings
> (CONFIG_SPARSE_RCU_POINTER=y)
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-11-15 17:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-15 17:21 [PATCH] netfilter: add __rcu annotations Eric Dumazet
2010-11-15 17:26 ` Patrick McHardy
2010-11-15 17:32 ` Eric Dumazet
2010-11-15 17:45 ` Patrick McHardy
2010-11-15 17:44 ` Patrick McHardy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).