diff options
Diffstat (limited to 'net/sched/act_pedit.c')
-rw-r--r-- | net/sched/act_pedit.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index 82d3c1479029..b54d56d4959b 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c | |||
@@ -26,13 +26,14 @@ | |||
26 | #define PEDIT_TAB_MASK 15 | 26 | #define PEDIT_TAB_MASK 15 |
27 | 27 | ||
28 | static int pedit_net_id; | 28 | static int pedit_net_id; |
29 | static struct tc_action_ops act_pedit_ops; | ||
29 | 30 | ||
30 | static const struct nla_policy pedit_policy[TCA_PEDIT_MAX + 1] = { | 31 | static const struct nla_policy pedit_policy[TCA_PEDIT_MAX + 1] = { |
31 | [TCA_PEDIT_PARMS] = { .len = sizeof(struct tc_pedit) }, | 32 | [TCA_PEDIT_PARMS] = { .len = sizeof(struct tc_pedit) }, |
32 | }; | 33 | }; |
33 | 34 | ||
34 | static int tcf_pedit_init(struct net *net, struct nlattr *nla, | 35 | static int tcf_pedit_init(struct net *net, struct nlattr *nla, |
35 | struct nlattr *est, struct tc_action *a, | 36 | struct nlattr *est, struct tc_action **a, |
36 | int ovr, int bind) | 37 | int ovr, int bind) |
37 | { | 38 | { |
38 | struct tc_action_net *tn = net_generic(net, pedit_net_id); | 39 | struct tc_action_net *tn = net_generic(net, pedit_net_id); |
@@ -61,23 +62,23 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, | |||
61 | if (!parm->nkeys) | 62 | if (!parm->nkeys) |
62 | return -EINVAL; | 63 | return -EINVAL; |
63 | ret = tcf_hash_create(tn, parm->index, est, a, | 64 | ret = tcf_hash_create(tn, parm->index, est, a, |
64 | sizeof(*p), bind, false); | 65 | &act_pedit_ops, bind, false); |
65 | if (ret) | 66 | if (ret) |
66 | return ret; | 67 | return ret; |
67 | p = to_pedit(a); | 68 | p = to_pedit(*a); |
68 | keys = kmalloc(ksize, GFP_KERNEL); | 69 | keys = kmalloc(ksize, GFP_KERNEL); |
69 | if (keys == NULL) { | 70 | if (keys == NULL) { |
70 | tcf_hash_cleanup(a, est); | 71 | tcf_hash_cleanup(*a, est); |
71 | return -ENOMEM; | 72 | return -ENOMEM; |
72 | } | 73 | } |
73 | ret = ACT_P_CREATED; | 74 | ret = ACT_P_CREATED; |
74 | } else { | 75 | } else { |
75 | if (bind) | 76 | if (bind) |
76 | return 0; | 77 | return 0; |
77 | tcf_hash_release(a, bind); | 78 | tcf_hash_release(*a, bind); |
78 | if (!ovr) | 79 | if (!ovr) |
79 | return -EEXIST; | 80 | return -EEXIST; |
80 | p = to_pedit(a); | 81 | p = to_pedit(*a); |
81 | if (p->tcfp_nkeys && p->tcfp_nkeys != parm->nkeys) { | 82 | if (p->tcfp_nkeys && p->tcfp_nkeys != parm->nkeys) { |
82 | keys = kmalloc(ksize, GFP_KERNEL); | 83 | keys = kmalloc(ksize, GFP_KERNEL); |
83 | if (keys == NULL) | 84 | if (keys == NULL) |
@@ -96,13 +97,13 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, | |||
96 | memcpy(p->tcfp_keys, parm->keys, ksize); | 97 | memcpy(p->tcfp_keys, parm->keys, ksize); |
97 | spin_unlock_bh(&p->tcf_lock); | 98 | spin_unlock_bh(&p->tcf_lock); |
98 | if (ret == ACT_P_CREATED) | 99 | if (ret == ACT_P_CREATED) |
99 | tcf_hash_insert(tn, a); | 100 | tcf_hash_insert(tn, *a); |
100 | return ret; | 101 | return ret; |
101 | } | 102 | } |
102 | 103 | ||
103 | static void tcf_pedit_cleanup(struct tc_action *a, int bind) | 104 | static void tcf_pedit_cleanup(struct tc_action *a, int bind) |
104 | { | 105 | { |
105 | struct tcf_pedit *p = a->priv; | 106 | struct tcf_pedit *p = to_pedit(a); |
106 | struct tc_pedit_key *keys = p->tcfp_keys; | 107 | struct tc_pedit_key *keys = p->tcfp_keys; |
107 | kfree(keys); | 108 | kfree(keys); |
108 | } | 109 | } |
@@ -110,7 +111,7 @@ static void tcf_pedit_cleanup(struct tc_action *a, int bind) | |||
110 | static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, | 111 | static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, |
111 | struct tcf_result *res) | 112 | struct tcf_result *res) |
112 | { | 113 | { |
113 | struct tcf_pedit *p = a->priv; | 114 | struct tcf_pedit *p = to_pedit(a); |
114 | int i; | 115 | int i; |
115 | unsigned int off; | 116 | unsigned int off; |
116 | 117 | ||
@@ -177,7 +178,7 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a, | |||
177 | int bind, int ref) | 178 | int bind, int ref) |
178 | { | 179 | { |
179 | unsigned char *b = skb_tail_pointer(skb); | 180 | unsigned char *b = skb_tail_pointer(skb); |
180 | struct tcf_pedit *p = a->priv; | 181 | struct tcf_pedit *p = to_pedit(a); |
181 | struct tc_pedit *opt; | 182 | struct tc_pedit *opt; |
182 | struct tcf_t t; | 183 | struct tcf_t t; |
183 | int s; | 184 | int s; |
@@ -216,14 +217,14 @@ nla_put_failure: | |||
216 | 217 | ||
217 | static int tcf_pedit_walker(struct net *net, struct sk_buff *skb, | 218 | static int tcf_pedit_walker(struct net *net, struct sk_buff *skb, |
218 | struct netlink_callback *cb, int type, | 219 | struct netlink_callback *cb, int type, |
219 | struct tc_action *a) | 220 | const struct tc_action_ops *ops) |
220 | { | 221 | { |
221 | struct tc_action_net *tn = net_generic(net, pedit_net_id); | 222 | struct tc_action_net *tn = net_generic(net, pedit_net_id); |
222 | 223 | ||
223 | return tcf_generic_walker(tn, skb, cb, type, a); | 224 | return tcf_generic_walker(tn, skb, cb, type, ops); |
224 | } | 225 | } |
225 | 226 | ||
226 | static int tcf_pedit_search(struct net *net, struct tc_action *a, u32 index) | 227 | static int tcf_pedit_search(struct net *net, struct tc_action **a, u32 index) |
227 | { | 228 | { |
228 | struct tc_action_net *tn = net_generic(net, pedit_net_id); | 229 | struct tc_action_net *tn = net_generic(net, pedit_net_id); |
229 | 230 | ||
@@ -240,6 +241,7 @@ static struct tc_action_ops act_pedit_ops = { | |||
240 | .init = tcf_pedit_init, | 241 | .init = tcf_pedit_init, |
241 | .walk = tcf_pedit_walker, | 242 | .walk = tcf_pedit_walker, |
242 | .lookup = tcf_pedit_search, | 243 | .lookup = tcf_pedit_search, |
244 | .size = sizeof(struct tcf_pedit), | ||
243 | }; | 245 | }; |
244 | 246 | ||
245 | static __net_init int pedit_init_net(struct net *net) | 247 | static __net_init int pedit_init_net(struct net *net) |