diff options
Diffstat (limited to 'net/sched/act_nat.c')
-rw-r--r-- | net/sched/act_nat.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c index 81f0404bb335..ce9a3914ed4a 100644 --- a/net/sched/act_nat.c +++ b/net/sched/act_nat.c | |||
@@ -44,7 +44,6 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
44 | struct tc_nat *parm; | 44 | struct tc_nat *parm; |
45 | int ret = 0, err; | 45 | int ret = 0, err; |
46 | struct tcf_nat *p; | 46 | struct tcf_nat *p; |
47 | struct tcf_common *pc; | ||
48 | 47 | ||
49 | if (nla == NULL) | 48 | if (nla == NULL) |
50 | return -EINVAL; | 49 | return -EINVAL; |
@@ -57,20 +56,19 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
57 | return -EINVAL; | 56 | return -EINVAL; |
58 | parm = nla_data(tb[TCA_NAT_PARMS]); | 57 | parm = nla_data(tb[TCA_NAT_PARMS]); |
59 | 58 | ||
60 | pc = tcf_hash_check(parm->index, a, bind); | 59 | if (!tcf_hash_check(parm->index, a, bind)) { |
61 | if (!pc) { | 60 | ret = tcf_hash_create(parm->index, est, a, sizeof(*p), bind); |
62 | pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind); | 61 | if (ret) |
63 | if (IS_ERR(pc)) | 62 | return ret; |
64 | return PTR_ERR(pc); | ||
65 | ret = ACT_P_CREATED; | 63 | ret = ACT_P_CREATED; |
66 | } else { | 64 | } else { |
67 | if (bind) | 65 | if (bind) |
68 | return 0; | 66 | return 0; |
69 | tcf_hash_release(pc, bind, a->ops->hinfo); | 67 | tcf_hash_release(a, bind); |
70 | if (!ovr) | 68 | if (!ovr) |
71 | return -EEXIST; | 69 | return -EEXIST; |
72 | } | 70 | } |
73 | p = to_tcf_nat(pc); | 71 | p = to_tcf_nat(a); |
74 | 72 | ||
75 | spin_lock_bh(&p->tcf_lock); | 73 | spin_lock_bh(&p->tcf_lock); |
76 | p->old_addr = parm->old_addr; | 74 | p->old_addr = parm->old_addr; |
@@ -82,18 +80,11 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
82 | spin_unlock_bh(&p->tcf_lock); | 80 | spin_unlock_bh(&p->tcf_lock); |
83 | 81 | ||
84 | if (ret == ACT_P_CREATED) | 82 | if (ret == ACT_P_CREATED) |
85 | tcf_hash_insert(pc, a->ops->hinfo); | 83 | tcf_hash_insert(a); |
86 | 84 | ||
87 | return ret; | 85 | return ret; |
88 | } | 86 | } |
89 | 87 | ||
90 | static int tcf_nat_cleanup(struct tc_action *a, int bind) | ||
91 | { | ||
92 | struct tcf_nat *p = a->priv; | ||
93 | |||
94 | return tcf_hash_release(&p->common, bind, &nat_hash_info); | ||
95 | } | ||
96 | |||
97 | static int tcf_nat(struct sk_buff *skb, const struct tc_action *a, | 88 | static int tcf_nat(struct sk_buff *skb, const struct tc_action *a, |
98 | struct tcf_result *res) | 89 | struct tcf_result *res) |
99 | { | 90 | { |
@@ -298,7 +289,7 @@ static struct tc_action_ops act_nat_ops = { | |||
298 | .owner = THIS_MODULE, | 289 | .owner = THIS_MODULE, |
299 | .act = tcf_nat, | 290 | .act = tcf_nat, |
300 | .dump = tcf_nat_dump, | 291 | .dump = tcf_nat_dump, |
301 | .cleanup = tcf_nat_cleanup, | 292 | .cleanup = tcf_hash_release, |
302 | .init = tcf_nat_init, | 293 | .init = tcf_nat_init, |
303 | }; | 294 | }; |
304 | 295 | ||