Commit a3308d8f authored by Paul Blakey's avatar Paul Blakey Committed by David S. Miller

net/sched: cls_flower: Disallow duplicate internal elements

Flower currently allows having the same filter twice with the same
priority. Actions (and statistics update) will always execute on the
first inserted rule leaving the second rule unused.
This patch disallows that.
Signed-off-by: default avatarPaul Blakey <paulb@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a50a05f4
...@@ -134,6 +134,14 @@ static void fl_clear_masked_range(struct fl_flow_key *key, ...@@ -134,6 +134,14 @@ static void fl_clear_masked_range(struct fl_flow_key *key,
memset(fl_key_get_start(key, mask), 0, fl_mask_range(mask)); memset(fl_key_get_start(key, mask), 0, fl_mask_range(mask));
} }
static struct cls_fl_filter *fl_lookup(struct cls_fl_head *head,
struct fl_flow_key *mkey)
{
return rhashtable_lookup_fast(&head->ht,
fl_key_get_start(mkey, &head->mask),
head->ht_params);
}
static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
struct tcf_result *res) struct tcf_result *res)
{ {
...@@ -181,9 +189,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, ...@@ -181,9 +189,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
fl_set_masked_key(&skb_mkey, &skb_key, &head->mask); fl_set_masked_key(&skb_mkey, &skb_key, &head->mask);
f = rhashtable_lookup_fast(&head->ht, f = fl_lookup(head, &skb_mkey);
fl_key_get_start(&skb_mkey, &head->mask),
head->ht_params);
if (f && !tc_skip_sw(f->flags)) { if (f && !tc_skip_sw(f->flags)) {
*res = f->res; *res = f->res;
return tcf_exts_exec(skb, &f->exts, res); return tcf_exts_exec(skb, &f->exts, res);
...@@ -875,6 +881,11 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, ...@@ -875,6 +881,11 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
goto errout; goto errout;
if (!tc_skip_sw(fnew->flags)) { if (!tc_skip_sw(fnew->flags)) {
if (!fold && fl_lookup(head, &fnew->mkey)) {
err = -EEXIST;
goto errout;
}
err = rhashtable_insert_fast(&head->ht, &fnew->ht_node, err = rhashtable_insert_fast(&head->ht, &fnew->ht_node,
head->ht_params); head->ht_params);
if (err) if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment