Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

prestera: matchall: do not rollback if rule exists

If you try to create a 'mirror' ACL rule on a port that already has a
mirror rule, prestera_span_rule_add() will fail with EEXIST error.

This forces rollback procedure which destroys existing mirror rule on
hardware leaving it visible in linux.

Add an explicit check for EEXIST to prevent the deletion of the existing
rule but keep user seeing error message:

$ tc filter add dev sw1p1 ... skip_sw action mirred egress mirror dev sw1p2
$ tc filter add dev sw1p1 ... skip_sw action mirred egress mirror dev sw1p3
RTNETLINK answers: File exists
We have an error talking to the kernel

Fixes: 13defa275eef ("net: marvell: prestera: Add matchall support")
Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Signed-off-by: Maksym Glubokiy <maksym.glubokiy@plvision.eu>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Serhiy Boiko and committed by
David S. Miller
fb4a5dfc 61b91eb3

+2
+2
drivers/net/ethernet/marvell/prestera/prestera_matchall.c
··· 96 96 97 97 list_for_each_entry(binding, &block->binding_list, list) { 98 98 err = prestera_span_rule_add(binding, port, block->ingress); 99 + if (err == -EEXIST) 100 + return err; 99 101 if (err) 100 102 goto rollback; 101 103 }