From: Jiri Pirko Subject: [patch net-next v4 11/12] selftests: forwarding: add tests for TC chains creation adn destruction Date: Mon, 23 Jul 2018 09:24:06 +0200 Message-ID: <20180723072407.4235-2-jiri@resnulli.us> References: <20180723072312.4153-1-jiri@resnulli.us> Cc: davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jakub.kicinski@netronome.com, simon.horman@netronome.com, john.hurley@netronome.com, dsahern@gmail.com, mlxsw@mellanox.com, sridhar.samudrala@intel.com To: netdev@vger.kernel.org Return-path: Received: from mail-wm0-f66.google.com ([74.125.82.66]:40955 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387992AbeGWI0W (ORCPT ); Mon, 23 Jul 2018 04:26:22 -0400 Received: by mail-wm0-f66.google.com with SMTP id z13-v6so34242wma.5 for ; Mon, 23 Jul 2018 00:26:32 -0700 (PDT) In-Reply-To: <20180723072312.4153-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org List-ID: From: Jiri Pirko Add basic sanity tests for TC chains. Signed-off-by: Jiri Pirko --- v3->v4: - split from the originally single patch --- tools/testing/selftests/net/forwarding/lib.sh | 9 +++++++++ .../testing/selftests/net/forwarding/tc_chains.sh | 23 +++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index ec94395a54a7..158d59ffee40 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -44,6 +44,15 @@ check_tc_shblock_support() fi } +check_tc_chain_support() +{ + tc help 2>&1|grep chain &> /dev/null + if [[ $? -ne 0 ]]; then + echo "SKIP: iproute2 too old; tc is missing chain support" + exit 1 + fi +} + if [[ "$(id -u)" -ne 0 ]]; then echo "SKIP: need root privileges" exit 0 diff --git a/tools/testing/selftests/net/forwarding/tc_chains.sh b/tools/testing/selftests/net/forwarding/tc_chains.sh index d2c783e94df3..2730887a3b3a 100755 --- a/tools/testing/selftests/net/forwarding/tc_chains.sh +++ b/tools/testing/selftests/net/forwarding/tc_chains.sh @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 -ALL_TESTS="unreachable_chain_test gact_goto_chain_test" +ALL_TESTS="unreachable_chain_test gact_goto_chain_test create_destroy_chain" NUM_NETIFS=2 source tc_common.sh source lib.sh @@ -80,6 +80,25 @@ gact_goto_chain_test() log_test "gact goto chain ($tcflags)" } +create_destroy_chain() +{ + RET=0 + + tc chain add dev $h2 ingress + check_err $? "Failed to create default chain" + + tc chain add dev $h2 ingress chain 1 + check_err $? "Failed to create chain 1" + + tc chain del dev $h2 ingress + check_err $? "Failed to destroy default chain" + + tc chain del dev $h2 ingress chain 1 + check_err $? "Failed to destroy chain 1" + + log_test "create destroy chain" +} + setup_prepare() { h1=${NETIFS[p1]} @@ -103,6 +122,8 @@ cleanup() vrf_cleanup } +check_tc_chain_support + trap cleanup EXIT setup_prepare -- 2.14.4