net: sched: flower: use correct ht function to prevent duplicates
authorVlad Buslov <vladbu@mellanox.com>
Thu, 11 Apr 2019 16:12:20 +0000 (19:12 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Apr 2019 18:33:06 +0000 (11:33 -0700)
commit9e35552ae1eafd666e7388a1a94a321665d2f911
tree223a5827f38bd0256a9bfd158114ff4f083b0604
parentecce39ec10937fb0d9f34ab43c75482d6c243292
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>
net/sched/cls_flower.c
tools/testing/selftests/tc-testing/tc-tests/filters/tests.json