selftests: tc: Test tc-flower's MPLS features
Subsystems (4)
cover selftests: tc: Test tc-flower's MPLS features
A couple of patches for exercising the MPLS filters of tc-flower.
Patch 1 tests basic MPLS matching features: those that only work on the first label stack entry (that is, the mpls_label, mpls_tc, mpls_bos and mpls_ttl options).
Patch 2 tests the more generic "mpls" and "lse" options, which allow matching MPLS fields beyond the first stack entry.
In both patches, special care is taken to skip these new tests for incompatible versions of tc.
Guillaume Nault (2):
selftests: tc: Add basic mpls_* matching support for tc-flower
selftests: tc: Add generic mpls matching support for tc-flower
tools/testing/selftests/net/forwarding/config | 1 + tools/testing/selftests/net/forwarding/lib.sh | 41 +++ .../selftests/net/forwarding/tc_flower.sh | 307 +++++++++++++++++- 3 files changed, 348 insertions(+), 1 deletion(-)
Signature · 1 line
2.21.3
PATCH 1/2 selftests: tc: Add basic mpls_* matching support for tc-flower
Add tests in tc_flower.sh for mpls_label, mpls_tc, mpls_bos and mpls_ttl. For each keyword, test the minimal and maximal values.
Selectively skip these new mpls tests for tc versions that don't support them.
--- tools/testing/selftests/net/forwarding/config | 1 + tools/testing/selftests/net/forwarding/lib.sh | 15 ++ .../selftests/net/forwarding/tc_flower.sh | 172 +++++++++++++++++- 3 files changed, 187 insertions(+), 1 deletion(-)
tools/testing/selftests/net/forwarding/config +1 -0
@@ -10,6 +10,7 @@ CONFIG_NET_ACT_MIRRED=m CONFIG_NET_ACT_MPLS=m CONFIG_NET_ACT_VLAN=m CONFIG_NET_CLS_FLOWER=m +CONFIG_NET_CLS_MATCHALL=m CONFIG_NET_SCH_INGRESS=m CONFIG_NET_ACT_GACT=m CONFIG_VETH=m
tools/testing/selftests/net/forwarding/lib.sh +15 -0
@@ -42,6 +42,21 @@ check_tc_version() fi } +# Old versions of tc don't understand "mpls_uc" +check_tc_mpls_support() +{ + local dev=$1; shift + + tc filter add dev $dev ingress protocol mpls_uc pref 1 handle 1 \ + matchall action pipe &> /dev/null + if [[ $? -ne 0 ]]; then + echo "SKIP: iproute2 too old; tc is missing MPLS support" + return 1 + fi + tc filter del dev $dev ingress protocol mpls_uc pref 1 handle 1 \ + matchall +} + check_tc_shblock_support() { tc filter help 2>&1 | grep block &> /dev/null
tools/testing/selftests/net/forwarding/tc_flower.sh +171 -1
184 lines not on this page · raw message
Signature · 1 line
2.21.3
PATCH 2/2 selftests: tc: Add generic mpls matching support for tc-flower
In reply to Guillaume NaultAdd 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.
--- tools/testing/selftests/net/forwarding/lib.sh | 26 ++++ .../selftests/net/forwarding/tc_flower.sh | 137 +++++++++++++++++- 2 files changed, 162 insertions(+), 1 deletion(-)
tools/testing/selftests/net/forwarding/lib.sh +26 -0
@@ -57,6 +57,32 @@ check_tc_mpls_support() matchall } +# Old versions of tc produce invalid json output for mpls lse statistics +check_tc_mpls_lse_stats() +{ + local dev=$1; shift + local ret; + + tc filter add dev $dev ingress protocol mpls_uc pref 1 handle 1 \ + flower mpls lse depth 2 \ + action continue &> /dev/null + + if [[ $? -ne 0 ]]; then + echo "SKIP: iproute2 too old; tc-flower is missing extended MPLS support" + return 1 + fi + + tc -j filter show dev $dev ingress protocol mpls_uc | jq . &> /dev/null + ret=$? + tc filter del dev $dev ingress protocol mpls_uc pref 1 handle 1 \ + flower + + if [[ $ret -ne 0 ]]; then + echo "SKIP: iproute2 too old; tc-flower produces invalid json output for extended MPLS filters" + return 1 + fi +} + check_tc_shblock_support() { tc filter help 2>&1 | grep block &> /dev/null
tools/testing/selftests/net/forwarding/tc_flower.sh +136 -1
149 lines not on this page · raw message
Signature · 1 line
2.21.3
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 10 lines · On Fri, 12 Feb 2021 20:05:33 +0100 you wrote:
A couple of patches for exercising the MPLS filters of tc-flower.
Patch 1 tests basic MPLS matching features: those that only work on the first label stack entry (that is, the
mpls_label,mpls_tc,mpls_bosandmpls_ttloptions).Patch 2 tests the more generic "mpls" and "lse" options, which allow matching MPLS fields beyond the first stack entry.
[...]
Here is the summary with links:
- [net-next,1/2] selftests: tc: Add basic mpls_* matching support for tc-flower
https://git.kernel.org/netdev/net-next/c/203ee5cd7235 - [net-next,2/2] selftests: tc: Add generic mpls matching support for tc-flower https://git.kernel.org/netdev/net-next/c/c09bfd9a5df9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html