diff options
Diffstat (limited to 'net/sched/cls_u32.c')
-rw-r--r-- | net/sched/cls_u32.c | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 079b43b3c5d2..ffe593efe930 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
@@ -440,7 +440,7 @@ static void u32_remove_hw_knode(struct tcf_proto *tp, u32 handle) | |||
440 | offload.type = TC_SETUP_CLSU32; | 440 | offload.type = TC_SETUP_CLSU32; |
441 | offload.cls_u32 = &u32_offload; | 441 | offload.cls_u32 = &u32_offload; |
442 | 442 | ||
443 | if (tc_should_offload(dev, 0)) { | 443 | if (tc_should_offload(dev, tp, 0)) { |
444 | offload.cls_u32->command = TC_CLSU32_DELETE_KNODE; | 444 | offload.cls_u32->command = TC_CLSU32_DELETE_KNODE; |
445 | offload.cls_u32->knode.handle = handle; | 445 | offload.cls_u32->knode.handle = handle; |
446 | dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, | 446 | dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, |
@@ -457,20 +457,21 @@ static int u32_replace_hw_hnode(struct tcf_proto *tp, | |||
457 | struct tc_to_netdev offload; | 457 | struct tc_to_netdev offload; |
458 | int err; | 458 | int err; |
459 | 459 | ||
460 | if (!tc_should_offload(dev, tp, flags)) | ||
461 | return tc_skip_sw(flags) ? -EINVAL : 0; | ||
462 | |||
460 | offload.type = TC_SETUP_CLSU32; | 463 | offload.type = TC_SETUP_CLSU32; |
461 | offload.cls_u32 = &u32_offload; | 464 | offload.cls_u32 = &u32_offload; |
462 | 465 | ||
463 | if (tc_should_offload(dev, flags)) { | 466 | offload.cls_u32->command = TC_CLSU32_NEW_HNODE; |
464 | offload.cls_u32->command = TC_CLSU32_NEW_HNODE; | 467 | offload.cls_u32->hnode.divisor = h->divisor; |
465 | offload.cls_u32->hnode.divisor = h->divisor; | 468 | offload.cls_u32->hnode.handle = h->handle; |
466 | offload.cls_u32->hnode.handle = h->handle; | 469 | offload.cls_u32->hnode.prio = h->prio; |
467 | offload.cls_u32->hnode.prio = h->prio; | ||
468 | 470 | ||
469 | err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, | 471 | err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, |
470 | tp->protocol, &offload); | 472 | tp->protocol, &offload); |
471 | if (tc_skip_sw(flags)) | 473 | if (tc_skip_sw(flags)) |
472 | return err; | 474 | return err; |
473 | } | ||
474 | 475 | ||
475 | return 0; | 476 | return 0; |
476 | } | 477 | } |
@@ -484,7 +485,7 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) | |||
484 | offload.type = TC_SETUP_CLSU32; | 485 | offload.type = TC_SETUP_CLSU32; |
485 | offload.cls_u32 = &u32_offload; | 486 | offload.cls_u32 = &u32_offload; |
486 | 487 | ||
487 | if (tc_should_offload(dev, 0)) { | 488 | if (tc_should_offload(dev, tp, 0)) { |
488 | offload.cls_u32->command = TC_CLSU32_DELETE_HNODE; | 489 | offload.cls_u32->command = TC_CLSU32_DELETE_HNODE; |
489 | offload.cls_u32->hnode.divisor = h->divisor; | 490 | offload.cls_u32->hnode.divisor = h->divisor; |
490 | offload.cls_u32->hnode.handle = h->handle; | 491 | offload.cls_u32->hnode.handle = h->handle; |
@@ -507,27 +508,28 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, | |||
507 | offload.type = TC_SETUP_CLSU32; | 508 | offload.type = TC_SETUP_CLSU32; |
508 | offload.cls_u32 = &u32_offload; | 509 | offload.cls_u32 = &u32_offload; |
509 | 510 | ||
510 | if (tc_should_offload(dev, flags)) { | 511 | if (!tc_should_offload(dev, tp, flags)) |
511 | offload.cls_u32->command = TC_CLSU32_REPLACE_KNODE; | 512 | return tc_skip_sw(flags) ? -EINVAL : 0; |
512 | offload.cls_u32->knode.handle = n->handle; | 513 | |
513 | offload.cls_u32->knode.fshift = n->fshift; | 514 | offload.cls_u32->command = TC_CLSU32_REPLACE_KNODE; |
515 | offload.cls_u32->knode.handle = n->handle; | ||
516 | offload.cls_u32->knode.fshift = n->fshift; | ||
514 | #ifdef CONFIG_CLS_U32_MARK | 517 | #ifdef CONFIG_CLS_U32_MARK |
515 | offload.cls_u32->knode.val = n->val; | 518 | offload.cls_u32->knode.val = n->val; |
516 | offload.cls_u32->knode.mask = n->mask; | 519 | offload.cls_u32->knode.mask = n->mask; |
517 | #else | 520 | #else |
518 | offload.cls_u32->knode.val = 0; | 521 | offload.cls_u32->knode.val = 0; |
519 | offload.cls_u32->knode.mask = 0; | 522 | offload.cls_u32->knode.mask = 0; |
520 | #endif | 523 | #endif |
521 | offload.cls_u32->knode.sel = &n->sel; | 524 | offload.cls_u32->knode.sel = &n->sel; |
522 | offload.cls_u32->knode.exts = &n->exts; | 525 | offload.cls_u32->knode.exts = &n->exts; |
523 | if (n->ht_down) | 526 | if (n->ht_down) |
524 | offload.cls_u32->knode.link_handle = n->ht_down->handle; | 527 | offload.cls_u32->knode.link_handle = n->ht_down->handle; |
525 | 528 | ||
526 | err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, | 529 | err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, |
527 | tp->protocol, &offload); | 530 | tp->protocol, &offload); |
528 | if (tc_skip_sw(flags)) | 531 | if (tc_skip_sw(flags)) |
529 | return err; | 532 | return err; |
530 | } | ||
531 | 533 | ||
532 | return 0; | 534 | return 0; |
533 | } | 535 | } |
@@ -863,7 +865,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, | |||
863 | if (tb[TCA_U32_FLAGS]) { | 865 | if (tb[TCA_U32_FLAGS]) { |
864 | flags = nla_get_u32(tb[TCA_U32_FLAGS]); | 866 | flags = nla_get_u32(tb[TCA_U32_FLAGS]); |
865 | if (!tc_flags_valid(flags)) | 867 | if (!tc_flags_valid(flags)) |
866 | return err; | 868 | return -EINVAL; |
867 | } | 869 | } |
868 | 870 | ||
869 | n = (struct tc_u_knode *)*arg; | 871 | n = (struct tc_u_knode *)*arg; |
@@ -921,11 +923,17 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, | |||
921 | ht->divisor = divisor; | 923 | ht->divisor = divisor; |
922 | ht->handle = handle; | 924 | ht->handle = handle; |
923 | ht->prio = tp->prio; | 925 | ht->prio = tp->prio; |
926 | |||
927 | err = u32_replace_hw_hnode(tp, ht, flags); | ||
928 | if (err) { | ||
929 | kfree(ht); | ||
930 | return err; | ||
931 | } | ||
932 | |||
924 | RCU_INIT_POINTER(ht->next, tp_c->hlist); | 933 | RCU_INIT_POINTER(ht->next, tp_c->hlist); |
925 | rcu_assign_pointer(tp_c->hlist, ht); | 934 | rcu_assign_pointer(tp_c->hlist, ht); |
926 | *arg = (unsigned long)ht; | 935 | *arg = (unsigned long)ht; |
927 | 936 | ||
928 | u32_replace_hw_hnode(tp, ht, flags); | ||
929 | return 0; | 937 | return 0; |
930 | } | 938 | } |
931 | 939 | ||