diff options
Diffstat (limited to 'net/sched/act_bpf.c')
-rw-r--r-- | net/sched/act_bpf.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index ef74bffa6101..bfa870731e74 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c | |||
@@ -34,11 +34,12 @@ struct tcf_bpf_cfg { | |||
34 | }; | 34 | }; |
35 | 35 | ||
36 | static int bpf_net_id; | 36 | static int bpf_net_id; |
37 | static struct tc_action_ops act_bpf_ops; | ||
37 | 38 | ||
38 | static int tcf_bpf(struct sk_buff *skb, const struct tc_action *act, | 39 | static int tcf_bpf(struct sk_buff *skb, const struct tc_action *act, |
39 | struct tcf_result *res) | 40 | struct tcf_result *res) |
40 | { | 41 | { |
41 | struct tcf_bpf *prog = act->priv; | 42 | struct tcf_bpf *prog = to_bpf(act); |
42 | struct bpf_prog *filter; | 43 | struct bpf_prog *filter; |
43 | int action, filter_res; | 44 | int action, filter_res; |
44 | bool at_ingress = G_TC_AT(skb->tc_verd) & AT_INGRESS; | 45 | bool at_ingress = G_TC_AT(skb->tc_verd) & AT_INGRESS; |
@@ -134,7 +135,7 @@ static int tcf_bpf_dump(struct sk_buff *skb, struct tc_action *act, | |||
134 | int bind, int ref) | 135 | int bind, int ref) |
135 | { | 136 | { |
136 | unsigned char *tp = skb_tail_pointer(skb); | 137 | unsigned char *tp = skb_tail_pointer(skb); |
137 | struct tcf_bpf *prog = act->priv; | 138 | struct tcf_bpf *prog = to_bpf(act); |
138 | struct tc_act_bpf opt = { | 139 | struct tc_act_bpf opt = { |
139 | .index = prog->tcf_index, | 140 | .index = prog->tcf_index, |
140 | .refcnt = prog->tcf_refcnt - ref, | 141 | .refcnt = prog->tcf_refcnt - ref, |
@@ -270,7 +271,7 @@ static void tcf_bpf_prog_fill_cfg(const struct tcf_bpf *prog, | |||
270 | } | 271 | } |
271 | 272 | ||
272 | static int tcf_bpf_init(struct net *net, struct nlattr *nla, | 273 | static int tcf_bpf_init(struct net *net, struct nlattr *nla, |
273 | struct nlattr *est, struct tc_action *act, | 274 | struct nlattr *est, struct tc_action **act, |
274 | int replace, int bind) | 275 | int replace, int bind) |
275 | { | 276 | { |
276 | struct tc_action_net *tn = net_generic(net, bpf_net_id); | 277 | struct tc_action_net *tn = net_generic(net, bpf_net_id); |
@@ -295,7 +296,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, | |||
295 | 296 | ||
296 | if (!tcf_hash_check(tn, parm->index, act, bind)) { | 297 | if (!tcf_hash_check(tn, parm->index, act, bind)) { |
297 | ret = tcf_hash_create(tn, parm->index, est, act, | 298 | ret = tcf_hash_create(tn, parm->index, est, act, |
298 | sizeof(*prog), bind, true); | 299 | &act_bpf_ops, bind, true); |
299 | if (ret < 0) | 300 | if (ret < 0) |
300 | return ret; | 301 | return ret; |
301 | 302 | ||
@@ -305,7 +306,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, | |||
305 | if (bind) | 306 | if (bind) |
306 | return 0; | 307 | return 0; |
307 | 308 | ||
308 | tcf_hash_release(act, bind); | 309 | tcf_hash_release(*act, bind); |
309 | if (!replace) | 310 | if (!replace) |
310 | return -EEXIST; | 311 | return -EEXIST; |
311 | } | 312 | } |
@@ -325,7 +326,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, | |||
325 | if (ret < 0) | 326 | if (ret < 0) |
326 | goto out; | 327 | goto out; |
327 | 328 | ||
328 | prog = to_bpf(act); | 329 | prog = to_bpf(*act); |
329 | ASSERT_RTNL(); | 330 | ASSERT_RTNL(); |
330 | 331 | ||
331 | if (res != ACT_P_CREATED) | 332 | if (res != ACT_P_CREATED) |
@@ -343,7 +344,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, | |||
343 | rcu_assign_pointer(prog->filter, cfg.filter); | 344 | rcu_assign_pointer(prog->filter, cfg.filter); |
344 | 345 | ||
345 | if (res == ACT_P_CREATED) { | 346 | if (res == ACT_P_CREATED) { |
346 | tcf_hash_insert(tn, act); | 347 | tcf_hash_insert(tn, *act); |
347 | } else { | 348 | } else { |
348 | /* make sure the program being replaced is no longer executing */ | 349 | /* make sure the program being replaced is no longer executing */ |
349 | synchronize_rcu(); | 350 | synchronize_rcu(); |
@@ -353,7 +354,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, | |||
353 | return res; | 354 | return res; |
354 | out: | 355 | out: |
355 | if (res == ACT_P_CREATED) | 356 | if (res == ACT_P_CREATED) |
356 | tcf_hash_cleanup(act, est); | 357 | tcf_hash_cleanup(*act, est); |
357 | 358 | ||
358 | return ret; | 359 | return ret; |
359 | } | 360 | } |
@@ -362,20 +363,20 @@ static void tcf_bpf_cleanup(struct tc_action *act, int bind) | |||
362 | { | 363 | { |
363 | struct tcf_bpf_cfg tmp; | 364 | struct tcf_bpf_cfg tmp; |
364 | 365 | ||
365 | tcf_bpf_prog_fill_cfg(act->priv, &tmp); | 366 | tcf_bpf_prog_fill_cfg(to_bpf(act), &tmp); |
366 | tcf_bpf_cfg_cleanup(&tmp); | 367 | tcf_bpf_cfg_cleanup(&tmp); |
367 | } | 368 | } |
368 | 369 | ||
369 | static int tcf_bpf_walker(struct net *net, struct sk_buff *skb, | 370 | static int tcf_bpf_walker(struct net *net, struct sk_buff *skb, |
370 | struct netlink_callback *cb, int type, | 371 | struct netlink_callback *cb, int type, |
371 | struct tc_action *a) | 372 | const struct tc_action_ops *ops) |
372 | { | 373 | { |
373 | struct tc_action_net *tn = net_generic(net, bpf_net_id); | 374 | struct tc_action_net *tn = net_generic(net, bpf_net_id); |
374 | 375 | ||
375 | return tcf_generic_walker(tn, skb, cb, type, a); | 376 | return tcf_generic_walker(tn, skb, cb, type, ops); |
376 | } | 377 | } |
377 | 378 | ||
378 | static int tcf_bpf_search(struct net *net, struct tc_action *a, u32 index) | 379 | static int tcf_bpf_search(struct net *net, struct tc_action **a, u32 index) |
379 | { | 380 | { |
380 | struct tc_action_net *tn = net_generic(net, bpf_net_id); | 381 | struct tc_action_net *tn = net_generic(net, bpf_net_id); |
381 | 382 | ||
@@ -392,6 +393,7 @@ static struct tc_action_ops act_bpf_ops __read_mostly = { | |||
392 | .init = tcf_bpf_init, | 393 | .init = tcf_bpf_init, |
393 | .walk = tcf_bpf_walker, | 394 | .walk = tcf_bpf_walker, |
394 | .lookup = tcf_bpf_search, | 395 | .lookup = tcf_bpf_search, |
396 | .size = sizeof(struct tcf_bpf), | ||
395 | }; | 397 | }; |
396 | 398 | ||
397 | static __net_init int bpf_init_net(struct net *net) | 399 | static __net_init int bpf_init_net(struct net *net) |