diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2013-12-15 23:15:08 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-18 12:52:07 -0500 |
commit | 369ba56787d7469c0afda70bb9ff76ad5faaead5 (patch) | |
tree | 58425d3d564e3255c6660185bf22c80b76305ff5 /net/sched/act_nat.c | |
parent | 5da57f422d89c504a1d72dadd4e19d3dca8e974e (diff) |
net_sched: init struct tcf_hashinfo at register time
It looks weird to store the lock out of the struct but
still points to a static variable. Just move them into the struct.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_nat.c')
-rw-r--r-- | net/sched/act_nat.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c index 6a15ace00241..409fe7181c5f 100644 --- a/net/sched/act_nat.c +++ b/net/sched/act_nat.c | |||
@@ -30,15 +30,9 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | #define NAT_TAB_MASK 15 | 32 | #define NAT_TAB_MASK 15 |
33 | static struct tcf_common *tcf_nat_ht[NAT_TAB_MASK + 1]; | ||
34 | static u32 nat_idx_gen; | 33 | static u32 nat_idx_gen; |
35 | static DEFINE_RWLOCK(nat_lock); | ||
36 | 34 | ||
37 | static struct tcf_hashinfo nat_hash_info = { | 35 | static struct tcf_hashinfo nat_hash_info; |
38 | .htab = tcf_nat_ht, | ||
39 | .hmask = NAT_TAB_MASK, | ||
40 | .lock = &nat_lock, | ||
41 | }; | ||
42 | 36 | ||
43 | static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = { | 37 | static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = { |
44 | [TCA_NAT_PARMS] = { .len = sizeof(struct tc_nat) }, | 38 | [TCA_NAT_PARMS] = { .len = sizeof(struct tc_nat) }, |
@@ -316,12 +310,16 @@ MODULE_LICENSE("GPL"); | |||
316 | 310 | ||
317 | static int __init nat_init_module(void) | 311 | static int __init nat_init_module(void) |
318 | { | 312 | { |
313 | int err = tcf_hashinfo_init(&nat_hash_info, NAT_TAB_MASK+1); | ||
314 | if (err) | ||
315 | return err; | ||
319 | return tcf_register_action(&act_nat_ops); | 316 | return tcf_register_action(&act_nat_ops); |
320 | } | 317 | } |
321 | 318 | ||
322 | static void __exit nat_cleanup_module(void) | 319 | static void __exit nat_cleanup_module(void) |
323 | { | 320 | { |
324 | tcf_unregister_action(&act_nat_ops); | 321 | tcf_unregister_action(&act_nat_ops); |
322 | tcf_hashinfo_destroy(&nat_hash_info); | ||
325 | } | 323 | } |
326 | 324 | ||
327 | module_init(nat_init_module); | 325 | module_init(nat_init_module); |