diff options
Diffstat (limited to 'net/sched/act_nat.c')
-rw-r--r-- | net/sched/act_nat.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c index 06ccb03f25da..8e8b0cc30704 100644 --- a/net/sched/act_nat.c +++ b/net/sched/act_nat.c | |||
@@ -32,13 +32,14 @@ | |||
32 | #define NAT_TAB_MASK 15 | 32 | #define NAT_TAB_MASK 15 |
33 | 33 | ||
34 | static int nat_net_id; | 34 | static int nat_net_id; |
35 | static struct tc_action_ops act_nat_ops; | ||
35 | 36 | ||
36 | static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = { | 37 | static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = { |
37 | [TCA_NAT_PARMS] = { .len = sizeof(struct tc_nat) }, | 38 | [TCA_NAT_PARMS] = { .len = sizeof(struct tc_nat) }, |
38 | }; | 39 | }; |
39 | 40 | ||
40 | static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | 41 | static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, |
41 | struct tc_action *a, int ovr, int bind) | 42 | struct tc_action **a, int ovr, int bind) |
42 | { | 43 | { |
43 | struct tc_action_net *tn = net_generic(net, nat_net_id); | 44 | struct tc_action_net *tn = net_generic(net, nat_net_id); |
44 | struct nlattr *tb[TCA_NAT_MAX + 1]; | 45 | struct nlattr *tb[TCA_NAT_MAX + 1]; |
@@ -59,18 +60,18 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
59 | 60 | ||
60 | if (!tcf_hash_check(tn, parm->index, a, bind)) { | 61 | if (!tcf_hash_check(tn, parm->index, a, bind)) { |
61 | ret = tcf_hash_create(tn, parm->index, est, a, | 62 | ret = tcf_hash_create(tn, parm->index, est, a, |
62 | sizeof(*p), bind, false); | 63 | &act_nat_ops, bind, false); |
63 | if (ret) | 64 | if (ret) |
64 | return ret; | 65 | return ret; |
65 | ret = ACT_P_CREATED; | 66 | ret = ACT_P_CREATED; |
66 | } else { | 67 | } else { |
67 | if (bind) | 68 | if (bind) |
68 | return 0; | 69 | return 0; |
69 | tcf_hash_release(a, bind); | 70 | tcf_hash_release(*a, bind); |
70 | if (!ovr) | 71 | if (!ovr) |
71 | return -EEXIST; | 72 | return -EEXIST; |
72 | } | 73 | } |
73 | p = to_tcf_nat(a); | 74 | p = to_tcf_nat(*a); |
74 | 75 | ||
75 | spin_lock_bh(&p->tcf_lock); | 76 | spin_lock_bh(&p->tcf_lock); |
76 | p->old_addr = parm->old_addr; | 77 | p->old_addr = parm->old_addr; |
@@ -82,7 +83,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
82 | spin_unlock_bh(&p->tcf_lock); | 83 | spin_unlock_bh(&p->tcf_lock); |
83 | 84 | ||
84 | if (ret == ACT_P_CREATED) | 85 | if (ret == ACT_P_CREATED) |
85 | tcf_hash_insert(tn, a); | 86 | tcf_hash_insert(tn, *a); |
86 | 87 | ||
87 | return ret; | 88 | return ret; |
88 | } | 89 | } |
@@ -90,7 +91,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, | |||
90 | static int tcf_nat(struct sk_buff *skb, const struct tc_action *a, | 91 | static int tcf_nat(struct sk_buff *skb, const struct tc_action *a, |
91 | struct tcf_result *res) | 92 | struct tcf_result *res) |
92 | { | 93 | { |
93 | struct tcf_nat *p = a->priv; | 94 | struct tcf_nat *p = to_tcf_nat(a); |
94 | struct iphdr *iph; | 95 | struct iphdr *iph; |
95 | __be32 old_addr; | 96 | __be32 old_addr; |
96 | __be32 new_addr; | 97 | __be32 new_addr; |
@@ -248,7 +249,7 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a, | |||
248 | int bind, int ref) | 249 | int bind, int ref) |
249 | { | 250 | { |
250 | unsigned char *b = skb_tail_pointer(skb); | 251 | unsigned char *b = skb_tail_pointer(skb); |
251 | struct tcf_nat *p = a->priv; | 252 | struct tcf_nat *p = to_tcf_nat(a); |
252 | struct tc_nat opt = { | 253 | struct tc_nat opt = { |
253 | .old_addr = p->old_addr, | 254 | .old_addr = p->old_addr, |
254 | .new_addr = p->new_addr, | 255 | .new_addr = p->new_addr, |
@@ -278,14 +279,14 @@ nla_put_failure: | |||
278 | 279 | ||
279 | static int tcf_nat_walker(struct net *net, struct sk_buff *skb, | 280 | static int tcf_nat_walker(struct net *net, struct sk_buff *skb, |
280 | struct netlink_callback *cb, int type, | 281 | struct netlink_callback *cb, int type, |
281 | struct tc_action *a) | 282 | const struct tc_action_ops *ops) |
282 | { | 283 | { |
283 | struct tc_action_net *tn = net_generic(net, nat_net_id); | 284 | struct tc_action_net *tn = net_generic(net, nat_net_id); |
284 | 285 | ||
285 | return tcf_generic_walker(tn, skb, cb, type, a); | 286 | return tcf_generic_walker(tn, skb, cb, type, ops); |
286 | } | 287 | } |
287 | 288 | ||
288 | static int tcf_nat_search(struct net *net, struct tc_action *a, u32 index) | 289 | static int tcf_nat_search(struct net *net, struct tc_action **a, u32 index) |
289 | { | 290 | { |
290 | struct tc_action_net *tn = net_generic(net, nat_net_id); | 291 | struct tc_action_net *tn = net_generic(net, nat_net_id); |
291 | 292 | ||
@@ -301,6 +302,7 @@ static struct tc_action_ops act_nat_ops = { | |||
301 | .init = tcf_nat_init, | 302 | .init = tcf_nat_init, |
302 | .walk = tcf_nat_walker, | 303 | .walk = tcf_nat_walker, |
303 | .lookup = tcf_nat_search, | 304 | .lookup = tcf_nat_search, |
305 | .size = sizeof(struct tcf_nat), | ||
304 | }; | 306 | }; |
305 | 307 | ||
306 | static __net_init int nat_init_net(struct net *net) | 308 | static __net_init int nat_init_net(struct net *net) |