selftests: tc: Add generic mpls matching support for tc-flower
authorGuillaume Nault <gnault@redhat.com>
Fri, 12 Feb 2021 19:05:43 +0000 (20:05 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 13 Feb 2021 01:13:52 +0000 (17:13 -0800)
commitc09bfd9a5df933f614af909d33ada673485b46ac
treebee225453643595b9efd38d0d38061d7ccf2e97f
parent203ee5cd723502e88bac830a2478258f23bc4756
selftests: tc: Add generic mpls matching support for tc-flower

Add tests in tc_flower.sh for generic matching on MPLS Label Stack
Entries. The label, tc, bos and ttl fields are tested for the first
and second labels. For each field, the minimal and maximal values are
tested (the former at depth 1 and the later at depth 2).
There are also tests for matching the presence of a label stack entry
at a given depth.

In order to reduce the amount of code, all "lse" subcommands are tested
in match_mpls_lse_test(). Action "continue" is used, so that test
packets are evaluated by all filters. Then, we can verify if each
filter matched the expected number of packets.

Some versions of tc-flower produced invalid json output when dumping
MPLS filters with depth > 1. Skip the test if tc isn't recent enough.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/forwarding/lib.sh
tools/testing/selftests/net/forwarding/tc_flower.sh