diff options
Diffstat (limited to 'net/sched/act_ife.c')
-rw-r--r-- | net/sched/act_ife.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c index 845ab5119c05..141a06eeb1e5 100644 --- a/net/sched/act_ife.c +++ b/net/sched/act_ife.c | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | static int ife_net_id; | 38 | static int ife_net_id; |
39 | static int max_metacnt = IFE_META_MAX + 1; | 39 | static int max_metacnt = IFE_META_MAX + 1; |
40 | static struct tc_action_ops act_ife_ops; | ||
40 | 41 | ||
41 | static const struct nla_policy ife_policy[TCA_IFE_MAX + 1] = { | 42 | static const struct nla_policy ife_policy[TCA_IFE_MAX + 1] = { |
42 | [TCA_IFE_PARMS] = { .len = sizeof(struct tc_ife)}, | 43 | [TCA_IFE_PARMS] = { .len = sizeof(struct tc_ife)}, |
@@ -364,7 +365,7 @@ out_nlmsg_trim: | |||
364 | /* under ife->tcf_lock */ | 365 | /* under ife->tcf_lock */ |
365 | static void _tcf_ife_cleanup(struct tc_action *a, int bind) | 366 | static void _tcf_ife_cleanup(struct tc_action *a, int bind) |
366 | { | 367 | { |
367 | struct tcf_ife_info *ife = a->priv; | 368 | struct tcf_ife_info *ife = to_ife(a); |
368 | struct tcf_meta_info *e, *n; | 369 | struct tcf_meta_info *e, *n; |
369 | 370 | ||
370 | list_for_each_entry_safe(e, n, &ife->metalist, metalist) { | 371 | list_for_each_entry_safe(e, n, &ife->metalist, metalist) { |
@@ -382,7 +383,7 @@ static void _tcf_ife_cleanup(struct tc_action *a, int bind) | |||
382 | 383 | ||
383 | static void tcf_ife_cleanup(struct tc_action *a, int bind) | 384 | static void tcf_ife_cleanup(struct tc_action *a, int bind) |
384 | { | 385 | { |
385 | struct tcf_ife_info *ife = a->priv; | 386 | struct tcf_ife_info *ife = to_ife(a); |
386 | 387 | ||
387 | spin_lock_bh(&ife->tcf_lock); | 388 | spin_lock_bh(&ife->tcf_lock); |
388 | _tcf_ife_cleanup(a, bind); | 389 | _tcf_ife_cleanup(a, bind); |
@@ -417,7 +418,7 @@ static int populate_metalist(struct tcf_ife_info *ife, struct nlattr **tb, | |||
417 | } | 418 | } |
418 | 419 | ||
419 | static int tcf_ife_init(struct net *net, struct nlattr *nla, | 420 | static int tcf_ife_init(struct net *net, struct nlattr *nla, |
420 | struct nlattr *est, struct tc_action *a, | 421 | struct nlattr *est, struct tc_action **a, |
421 | int ovr, int bind) | 422 | int ovr, int bind) |
422 | { | 423 | { |
423 | struct tc_action_net *tn = net_generic(net, ife_net_id); | 424 | struct tc_action_net *tn = net_generic(net, ife_net_id); |
@@ -451,25 +452,25 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, | |||
451 | **/ | 452 | **/ |
452 | if (!tb[TCA_IFE_TYPE]) { | 453 | if (!tb[TCA_IFE_TYPE]) { |
453 | if (exists) | 454 | if (exists) |
454 | tcf_hash_release(a, bind); | 455 | tcf_hash_release(*a, bind); |
455 | pr_info("You MUST pass etherype for encoding\n"); | 456 | pr_info("You MUST pass etherype for encoding\n"); |
456 | return -EINVAL; | 457 | return -EINVAL; |
457 | } | 458 | } |
458 | } | 459 | } |
459 | 460 | ||
460 | if (!exists) { | 461 | if (!exists) { |
461 | ret = tcf_hash_create(tn, parm->index, est, a, sizeof(*ife), | 462 | ret = tcf_hash_create(tn, parm->index, est, a, &act_ife_ops, |
462 | bind, false); | 463 | bind, false); |
463 | if (ret) | 464 | if (ret) |
464 | return ret; | 465 | return ret; |
465 | ret = ACT_P_CREATED; | 466 | ret = ACT_P_CREATED; |
466 | } else { | 467 | } else { |
467 | tcf_hash_release(a, bind); | 468 | tcf_hash_release(*a, bind); |
468 | if (!ovr) | 469 | if (!ovr) |
469 | return -EEXIST; | 470 | return -EEXIST; |
470 | } | 471 | } |
471 | 472 | ||
472 | ife = to_ife(a); | 473 | ife = to_ife(*a); |
473 | ife->flags = parm->flags; | 474 | ife->flags = parm->flags; |
474 | 475 | ||
475 | if (parm->flags & IFE_ENCODE) { | 476 | if (parm->flags & IFE_ENCODE) { |
@@ -507,9 +508,9 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, | |||
507 | if (err) { | 508 | if (err) { |
508 | metadata_parse_err: | 509 | metadata_parse_err: |
509 | if (exists) | 510 | if (exists) |
510 | tcf_hash_release(a, bind); | 511 | tcf_hash_release(*a, bind); |
511 | if (ret == ACT_P_CREATED) | 512 | if (ret == ACT_P_CREATED) |
512 | _tcf_ife_cleanup(a, bind); | 513 | _tcf_ife_cleanup(*a, bind); |
513 | 514 | ||
514 | if (exists) | 515 | if (exists) |
515 | spin_unlock_bh(&ife->tcf_lock); | 516 | spin_unlock_bh(&ife->tcf_lock); |
@@ -529,7 +530,7 @@ metadata_parse_err: | |||
529 | err = use_all_metadata(ife); | 530 | err = use_all_metadata(ife); |
530 | if (err) { | 531 | if (err) { |
531 | if (ret == ACT_P_CREATED) | 532 | if (ret == ACT_P_CREATED) |
532 | _tcf_ife_cleanup(a, bind); | 533 | _tcf_ife_cleanup(*a, bind); |
533 | 534 | ||
534 | if (exists) | 535 | if (exists) |
535 | spin_unlock_bh(&ife->tcf_lock); | 536 | spin_unlock_bh(&ife->tcf_lock); |
@@ -541,7 +542,7 @@ metadata_parse_err: | |||
541 | spin_unlock_bh(&ife->tcf_lock); | 542 | spin_unlock_bh(&ife->tcf_lock); |
542 | 543 | ||
543 | if (ret == ACT_P_CREATED) | 544 | if (ret == ACT_P_CREATED) |
544 | tcf_hash_insert(tn, a); | 545 | tcf_hash_insert(tn, *a); |
545 | 546 | ||
546 | return ret; | 547 | return ret; |
547 | } | 548 | } |
@@ -550,7 +551,7 @@ static int tcf_ife_dump(struct sk_buff *skb, struct tc_action *a, int bind, | |||
550 | int ref) | 551 | int ref) |
551 | { | 552 | { |
552 | unsigned char *b = skb_tail_pointer(skb); | 553 | unsigned char *b = skb_tail_pointer(skb); |
553 | struct tcf_ife_info *ife = a->priv; | 554 | struct tcf_ife_info *ife = to_ife(a); |
554 | struct tc_ife opt = { | 555 | struct tc_ife opt = { |
555 | .index = ife->tcf_index, | 556 | .index = ife->tcf_index, |
556 | .refcnt = ife->tcf_refcnt - ref, | 557 | .refcnt = ife->tcf_refcnt - ref, |
@@ -623,7 +624,7 @@ struct meta_tlvhdr { | |||
623 | static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a, | 624 | static int tcf_ife_decode(struct sk_buff *skb, const struct tc_action *a, |
624 | struct tcf_result *res) | 625 | struct tcf_result *res) |
625 | { | 626 | { |
626 | struct tcf_ife_info *ife = a->priv; | 627 | struct tcf_ife_info *ife = to_ife(a); |
627 | int action = ife->tcf_action; | 628 | int action = ife->tcf_action; |
628 | struct ifeheadr *ifehdr = (struct ifeheadr *)skb->data; | 629 | struct ifeheadr *ifehdr = (struct ifeheadr *)skb->data; |
629 | u16 ifehdrln = ifehdr->metalen; | 630 | u16 ifehdrln = ifehdr->metalen; |
@@ -695,7 +696,7 @@ static int ife_get_sz(struct sk_buff *skb, struct tcf_ife_info *ife) | |||
695 | static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a, | 696 | static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a, |
696 | struct tcf_result *res) | 697 | struct tcf_result *res) |
697 | { | 698 | { |
698 | struct tcf_ife_info *ife = a->priv; | 699 | struct tcf_ife_info *ife = to_ife(a); |
699 | int action = ife->tcf_action; | 700 | int action = ife->tcf_action; |
700 | struct ethhdr *oethh; /* outer ether header */ | 701 | struct ethhdr *oethh; /* outer ether header */ |
701 | struct ethhdr *iethh; /* inner eth header */ | 702 | struct ethhdr *iethh; /* inner eth header */ |
@@ -799,7 +800,7 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a, | |||
799 | static int tcf_ife_act(struct sk_buff *skb, const struct tc_action *a, | 800 | static int tcf_ife_act(struct sk_buff *skb, const struct tc_action *a, |
800 | struct tcf_result *res) | 801 | struct tcf_result *res) |
801 | { | 802 | { |
802 | struct tcf_ife_info *ife = a->priv; | 803 | struct tcf_ife_info *ife = to_ife(a); |
803 | 804 | ||
804 | if (ife->flags & IFE_ENCODE) | 805 | if (ife->flags & IFE_ENCODE) |
805 | return tcf_ife_encode(skb, a, res); | 806 | return tcf_ife_encode(skb, a, res); |
@@ -819,14 +820,14 @@ static int tcf_ife_act(struct sk_buff *skb, const struct tc_action *a, | |||
819 | 820 | ||
820 | static int tcf_ife_walker(struct net *net, struct sk_buff *skb, | 821 | static int tcf_ife_walker(struct net *net, struct sk_buff *skb, |
821 | struct netlink_callback *cb, int type, | 822 | struct netlink_callback *cb, int type, |
822 | struct tc_action *a) | 823 | const struct tc_action_ops *ops) |
823 | { | 824 | { |
824 | struct tc_action_net *tn = net_generic(net, ife_net_id); | 825 | struct tc_action_net *tn = net_generic(net, ife_net_id); |
825 | 826 | ||
826 | return tcf_generic_walker(tn, skb, cb, type, a); | 827 | return tcf_generic_walker(tn, skb, cb, type, ops); |
827 | } | 828 | } |
828 | 829 | ||
829 | static int tcf_ife_search(struct net *net, struct tc_action *a, u32 index) | 830 | static int tcf_ife_search(struct net *net, struct tc_action **a, u32 index) |
830 | { | 831 | { |
831 | struct tc_action_net *tn = net_generic(net, ife_net_id); | 832 | struct tc_action_net *tn = net_generic(net, ife_net_id); |
832 | 833 | ||
@@ -843,6 +844,7 @@ static struct tc_action_ops act_ife_ops = { | |||
843 | .init = tcf_ife_init, | 844 | .init = tcf_ife_init, |
844 | .walk = tcf_ife_walker, | 845 | .walk = tcf_ife_walker, |
845 | .lookup = tcf_ife_search, | 846 | .lookup = tcf_ife_search, |
847 | .size = sizeof(struct tcf_ife_info), | ||
846 | }; | 848 | }; |
847 | 849 | ||
848 | static __net_init int ife_init_net(struct net *net) | 850 | static __net_init int ife_init_net(struct net *net) |