Skip to content

Commit

Permalink
net/sched: cls_flower: Reject duplicated rules also under skip_sw
Browse files Browse the repository at this point in the history
Currently, duplicated rules are rejected only for skip_hw or "none",
hence allowing users to push duplicates into HW for no reason.

Use the flower tables to protect for that.

Signed-off-by: Or Gerlitz <[email protected]>
Signed-off-by: Paul Blakey <[email protected]>
Reported-by: Chris Mi <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ogerlitz authored and davem330 committed Dec 9, 2018
1 parent d4b60e9 commit 35cc3ce
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions net/sched/cls_flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,18 +1238,16 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
if (err)
goto errout_idr;

if (!tc_skip_sw(fnew->flags)) {
if (!fold && fl_lookup(fnew->mask, &fnew->mkey)) {
err = -EEXIST;
goto errout_mask;
}

err = rhashtable_insert_fast(&fnew->mask->ht, &fnew->ht_node,
fnew->mask->filter_ht_params);
if (err)
goto errout_mask;
if (!fold && fl_lookup(fnew->mask, &fnew->mkey)) {
err = -EEXIST;
goto errout_mask;
}

err = rhashtable_insert_fast(&fnew->mask->ht, &fnew->ht_node,
fnew->mask->filter_ht_params);
if (err)
goto errout_mask;

if (!tc_skip_hw(fnew->flags)) {
err = fl_hw_replace_filter(tp, fnew, extack);
if (err)
Expand Down Expand Up @@ -1303,9 +1301,8 @@ static int fl_delete(struct tcf_proto *tp, void *arg, bool *last,
struct cls_fl_head *head = rtnl_dereference(tp->root);
struct cls_fl_filter *f = arg;

if (!tc_skip_sw(f->flags))
rhashtable_remove_fast(&f->mask->ht, &f->ht_node,
f->mask->filter_ht_params);
rhashtable_remove_fast(&f->mask->ht, &f->ht_node,
f->mask->filter_ht_params);
__fl_delete(tp, f, extack);
*last = list_empty(&head->masks);
return 0;
Expand Down

0 comments on commit 35cc3ce

Please sign in to comment.