diff options
author | Patrick McHardy <kaber@trash.net> | 2007-07-08 01:39:16 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-07-11 01:18:19 -0400 |
commit | 342b7e3c8a3c84252799c4ac4d9a604b8903d2b4 (patch) | |
tree | c61ffbcbf24287df26a6dfc58684630289669c7f | |
parent | 91e8db80065d655ce1b6d74cadc921671e8d5285 (diff) |
[NETFILTER]: xt_helper: use RCU
The ->helper pointer is protected by RCU, no need to take
nf_conntrack_lock. Also remove excessive debugging.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/netfilter/xt_helper.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/net/netfilter/xt_helper.c b/net/netfilter/xt_helper.c index d03acb032cc8..0a1f4c6bcdef 100644 --- a/net/netfilter/xt_helper.c +++ b/net/netfilter/xt_helper.c | |||
@@ -22,11 +22,6 @@ MODULE_DESCRIPTION("iptables helper match module"); | |||
22 | MODULE_ALIAS("ipt_helper"); | 22 | MODULE_ALIAS("ipt_helper"); |
23 | MODULE_ALIAS("ip6t_helper"); | 23 | MODULE_ALIAS("ip6t_helper"); |
24 | 24 | ||
25 | #if 0 | ||
26 | #define DEBUGP printk | ||
27 | #else | ||
28 | #define DEBUGP(format, args...) | ||
29 | #endif | ||
30 | 25 | ||
31 | static bool | 26 | static bool |
32 | match(const struct sk_buff *skb, | 27 | match(const struct sk_buff *skb, |
@@ -41,38 +36,28 @@ match(const struct sk_buff *skb, | |||
41 | const struct xt_helper_info *info = matchinfo; | 36 | const struct xt_helper_info *info = matchinfo; |
42 | const struct nf_conn *ct; | 37 | const struct nf_conn *ct; |
43 | const struct nf_conn_help *master_help; | 38 | const struct nf_conn_help *master_help; |
39 | const struct nf_conntrack_helper *helper; | ||
44 | enum ip_conntrack_info ctinfo; | 40 | enum ip_conntrack_info ctinfo; |
45 | bool ret = info->invert; | 41 | bool ret = info->invert; |
46 | 42 | ||
47 | ct = nf_ct_get(skb, &ctinfo); | 43 | ct = nf_ct_get(skb, &ctinfo); |
48 | if (!ct) { | 44 | if (!ct || !ct->master) |
49 | DEBUGP("xt_helper: Eek! invalid conntrack?\n"); | ||
50 | return ret; | 45 | return ret; |
51 | } | ||
52 | |||
53 | if (!ct->master) { | ||
54 | DEBUGP("xt_helper: conntrack %p has no master\n", ct); | ||
55 | return ret; | ||
56 | } | ||
57 | 46 | ||
58 | read_lock_bh(&nf_conntrack_lock); | ||
59 | master_help = nfct_help(ct->master); | 47 | master_help = nfct_help(ct->master); |
60 | if (!master_help || !master_help->helper) { | 48 | if (!master_help) |
61 | DEBUGP("xt_helper: master ct %p has no helper\n", | 49 | return ret; |
62 | exp->expectant); | ||
63 | goto out_unlock; | ||
64 | } | ||
65 | 50 | ||
66 | DEBUGP("master's name = %s , info->name = %s\n", | 51 | /* rcu_read_lock()ed by nf_hook_slow */ |
67 | ct->master->helper->name, info->name); | 52 | helper = rcu_dereference(master_help->helper); |
53 | if (!helper) | ||
54 | return ret; | ||
68 | 55 | ||
69 | if (info->name[0] == '\0') | 56 | if (info->name[0] == '\0') |
70 | ret = !ret; | 57 | ret = !ret; |
71 | else | 58 | else |
72 | ret ^= !strncmp(master_help->helper->name, info->name, | 59 | ret ^= !strncmp(master_help->helper->name, info->name, |
73 | strlen(master_help->helper->name)); | 60 | strlen(master_help->helper->name)); |
74 | out_unlock: | ||
75 | read_unlock_bh(&nf_conntrack_lock); | ||
76 | return ret; | 61 | return ret; |
77 | } | 62 | } |
78 | 63 | ||