diff options
author | Vlad Buslov <vladbu@mellanox.com> | 2019-04-11 18:12:20 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-11 20:33:06 +0200 |
commit | 9e35552ae1eafd666e7388a1a94a321665d2f911 (patch) | |
tree | 223a5827f38bd0256a9bfd158114ff4f083b0604 /net/sched | |
parent | netns: read NETNSA_NSID as s32 attribute in rtnl_net_getid() (diff) | |
download | linux-9e35552ae1eafd666e7388a1a94a321665d2f911.tar.xz linux-9e35552ae1eafd666e7388a1a94a321665d2f911.zip |
net: sched: flower: use correct ht function to prevent duplicates
Implementation of function rhashtable_insert_fast() check if its internal
helper function __rhashtable_insert_fast() returns non-NULL pointer and
seemingly return -EEXIST in such case. However, since
__rhashtable_insert_fast() is called with NULL key pointer, it never
actually checks for duplicates, which means that -EEXIST is never returned
to the user. Use rhashtable_lookup_insert_fast() hash table API instead. In
order to verify that it works as expected and prevent the problem from
happening in future, extend tc-tests with new test that verifies that no
new filters with existing key can be inserted to flower classifier.
Fixes: 1f17f7742eeb ("net: sched: flower: insert filter to ht before offloading it to hw")
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r-- | net/sched/cls_flower.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 2763176e369c..9cd8122a5c38 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -1466,9 +1466,9 @@ static int fl_ht_insert_unique(struct cls_fl_filter *fnew, struct fl_flow_mask *mask = fnew->mask; int err; - err = rhashtable_insert_fast(&mask->ht, - &fnew->ht_node, - mask->filter_ht_params); + err = rhashtable_lookup_insert_fast(&mask->ht, + &fnew->ht_node, + mask->filter_ht_params); if (err) { *in_ht = false; /* It is okay if filter with same key exists when |