From patchwork Sun Jan 8 15:45:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 640507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91B10C53210 for ; Sun, 8 Jan 2023 15:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbjAHPql (ORCPT ); Sun, 8 Jan 2023 10:46:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231454AbjAHPqk (ORCPT ); Sun, 8 Jan 2023 10:46:40 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79609FD14 for ; Sun, 8 Jan 2023 07:45:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673192747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/njgGAVUPtXskzk1vLp20oMLbjhp3j4lH68KrNnwBwM=; b=a3MPBrpgvYrkl6d8DVZosiG1s5kGeSfiglquozlpt6lnuEre6jPkM9SXVj2/KiE9Fq2zPq ahI514v+SR/OJFJtOJr581AXBSMdntZm26mGtClOCOMgzRRyyXYTc5UKHQIrpxw8TC4BDY N7n8/CakdY3uAkH3bbEHBQBY9SNOy4A= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-325-LHR2pKc0PKa88nuHCuLycg-1; Sun, 08 Jan 2023 10:45:46 -0500 X-MC-Unique: LHR2pKc0PKa88nuHCuLycg-1 Received: by mail-qk1-f200.google.com with SMTP id m9-20020a05620a290900b0070596994c7eso4853160qkp.7 for ; Sun, 08 Jan 2023 07:45:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/njgGAVUPtXskzk1vLp20oMLbjhp3j4lH68KrNnwBwM=; b=grKJqGSxhQGO7FABsJMmd88DqEshpEd4QSuZTgkrvZAJ5p0ha3rhEIxCSZKLkGrb4Y e3EBkDpYdfNsB0+tLh5tEq+lEbs9jt3oE1QnkJoByuB7ArZl5K50cfSwmGHg6cLB/I77 lu8C9kmxykZ092TfXKzhc/BxCK1m5aynezNAOiQxTh6df46T6KNT5NwjwKHcUOBQBOt1 fb+fQC2ahTK2JnXuszELQQvw+LeU5Y+Xkmf6eO+Yaq3dVDe/YkjpS0qY5uerohGK65/j Ik9hkh9EmVzgedSr9irwcP9Y+sqPIx/Xu3xUCranP5sI8E/tHa2mCgy0u6PBUrpdT2Kc T5Zw== X-Gm-Message-State: AFqh2kr2XeUorq7Bv6M1POqvC7T4nwCU0kJy3StvWb7ig2xqpJQyi/JF 0Pjzi53n9lSo6OW2HlA5iLhrL2i6WHeZhpt79/gBpRLjf7wUPZMZIV6xqFeXvLlxCQ0jACErSRW w2V9YOxmC4qHe45QEIhAJE5v+S8dd X-Received: by 2002:a05:622a:4205:b0:3a5:3cb5:2485 with SMTP id cp5-20020a05622a420500b003a53cb52485mr84046992qtb.0.1673192745855; Sun, 08 Jan 2023 07:45:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXuv3RaKjIAXyDmemvxrKDMHR6xY19k16gFK4eI7Ku+wXBfLOlr7Kg8h3uL3/4j8pVvZ0zSyLA== X-Received: by 2002:a05:622a:4205:b0:3a5:3cb5:2485 with SMTP id cp5-20020a05622a420500b003a53cb52485mr84046980qtb.0.1673192745636; Sun, 08 Jan 2023 07:45:45 -0800 (PST) Received: from debian (2a01cb058918ce0098fed9113971adae.ipv6.abo.wanadoo.fr. [2a01:cb05:8918:ce00:98fe:d911:3971:adae]) by smtp.gmail.com with ESMTPSA id fz18-20020a05622a5a9200b003a591194221sm3385902qtb.7.2023.01.08.07.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 07:45:45 -0800 (PST) Date: Sun, 8 Jan 2023 16:45:41 +0100 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Shuah Khan , Matthias May , linux-kselftest@vger.kernel.org, Mirsad Goran Todorovac Subject: [PATCH net 1/3] selftests/net: l2_tos_ttl_inherit.sh: Set IPv6 addresses with "nodad". Message-ID: <1c40c3a46ec30731d45fbc7b33d71e8c711e310a.1673191942.git.gnault@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The ping command can run before DAD completes. In that case, ping may fail and break the selftest. We don't need DAD here since we're working on isolated device pairs. Fixes: b690842d12fd ("selftests/net: test l2 tunnel TOS/TTL inheriting") Signed-off-by: Guillaume Nault --- tools/testing/selftests/net/l2_tos_ttl_inherit.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/l2_tos_ttl_inherit.sh b/tools/testing/selftests/net/l2_tos_ttl_inherit.sh index dca1e6f777a8..e2574b08eabc 100755 --- a/tools/testing/selftests/net/l2_tos_ttl_inherit.sh +++ b/tools/testing/selftests/net/l2_tos_ttl_inherit.sh @@ -137,8 +137,8 @@ setup() { if [ "$type" = "gre" ]; then type="ip6gretap" fi - ip addr add fdd1:ced0:5d88:3fce::1/64 dev veth0 - $ns ip addr add fdd1:ced0:5d88:3fce::2/64 dev veth1 + ip addr add fdd1:ced0:5d88:3fce::1/64 dev veth0 nodad + $ns ip addr add fdd1:ced0:5d88:3fce::2/64 dev veth1 nodad ip link add name tep0 type $type $local_addr1 \ remote fdd1:ced0:5d88:3fce::2 tos $test_tos ttl $test_ttl \ $vxlan $geneve @@ -170,8 +170,8 @@ setup() { ip addr add 198.19.0.1/24 brd + dev ${parent}0 $ns ip addr add 198.19.0.2/24 brd + dev ${parent}1 elif [ "$inner" = "6" ]; then - ip addr add fdd4:96cf:4eae:443b::1/64 dev ${parent}0 - $ns ip addr add fdd4:96cf:4eae:443b::2/64 dev ${parent}1 + ip addr add fdd4:96cf:4eae:443b::1/64 dev ${parent}0 nodad + $ns ip addr add fdd4:96cf:4eae:443b::2/64 dev ${parent}1 nodad fi } From patchwork Sun Jan 8 15:45:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guillaume Nault X-Patchwork-Id: 640506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 821B1C54EBD for ; Sun, 8 Jan 2023 15:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233053AbjAHPq6 (ORCPT ); Sun, 8 Jan 2023 10:46:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231551AbjAHPq5 (ORCPT ); Sun, 8 Jan 2023 10:46:57 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B9D122B for ; Sun, 8 Jan 2023 07:45:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673192756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FtjyxBTyHgcMmUp4eECMrOwxInBVUuzyxbE0sO3oxjs=; b=CXDxjwpbULXVgSe90mOKLu5c39yEAboj4609uuwQ1HMswR9bhOjX+eYe58TR4hC/auZ6Bx I0uzJ7Q+TfE3NtRoyCzuatuq9OJQ5gtoPBuJ7N1DdbNfKW5bTgtxn1yqwYr75pF3WAgwnt PVsXPqssGnnCXQV8F9tzi7ktvoFlmTo= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-217-l3EKYAMfMnqIgqrpt_ouUQ-1; Sun, 08 Jan 2023 10:45:55 -0500 X-MC-Unique: l3EKYAMfMnqIgqrpt_ouUQ-1 Received: by mail-qk1-f199.google.com with SMTP id bp6-20020a05620a458600b006ffd3762e78so4858586qkb.13 for ; Sun, 08 Jan 2023 07:45:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FtjyxBTyHgcMmUp4eECMrOwxInBVUuzyxbE0sO3oxjs=; b=IHXGJe+shDKy2XUqTQPoCf4X6Cr15C+twXtMFEwYHpGvdgNN1rlWf6o9JtsmEUtP0V sl69Lo7SQgDP/9lGCrh9d5FsTjaYhdsgf/XQy1DlJyeIGcwqHA379iYByJ9zxOVS35XH wSvxIM+fKlfFcx5Vrs2y4Ve9siUN4CSwQ8Asm+7suOgROj3r7fRPf8riitdyw9eCTr8/ piW4FF3JzziRIOmEzhmZ3PmCng0SkmxmYDWly7iQg6L6dYIdyOygjuHm6UkgQSe6FQzL gxzggUEuJv/vzKFwD/eYfrQwMFB9U9r238LF23kiF3A7s5poNuvOVH78WHLv47wcvsYT zZFw== X-Gm-Message-State: AFqh2kpXmUZoJrHVKA09kWYZGxAycgTC7DrcVPXKuR6I+CHSbVsjj9oM M61Nn8jVE7pqmYgR2JJI0+OdqXo1S1XHkXLEQX6lFh74YgWf5GP2Yw/QnMqkCEsR6s+/QDKuGNK JflGrK/hSUceBCvFxQivRBpcTEley X-Received: by 2002:a05:6214:5f92:b0:532:b90:1993 with SMTP id ls18-20020a0562145f9200b005320b901993mr20786121qvb.11.1673192754252; Sun, 08 Jan 2023 07:45:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXsDbO0oNA6ey8fyoPjndADuq9SLkuSxCdXR9dYfR4KehLHX/0m9XDEUGayV889iIptyGs2GsQ== X-Received: by 2002:a05:6214:5f92:b0:532:b90:1993 with SMTP id ls18-20020a0562145f9200b005320b901993mr20786106qvb.11.1673192754037; Sun, 08 Jan 2023 07:45:54 -0800 (PST) Received: from debian (2a01cb058918ce0098fed9113971adae.ipv6.abo.wanadoo.fr. [2a01:cb05:8918:ce00:98fe:d911:3971:adae]) by smtp.gmail.com with ESMTPSA id p16-20020a05620a057000b006fafaac72a6sm3817988qkp.84.2023.01.08.07.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 07:45:53 -0800 (PST) Date: Sun, 8 Jan 2023 16:45:50 +0100 From: Guillaume Nault To: David Miller , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: netdev@vger.kernel.org, Shuah Khan , Matthias May , linux-kselftest@vger.kernel.org, Mirsad Goran Todorovac Subject: [PATCH net 3/3] selftests/net: l2_tos_ttl_inherit.sh: Ensure environment cleanup on failure. Message-ID: <1fdc9f2de958c8eb2c6bc435f149cf0adde72114.1673191942.git.gnault@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Use 'set -e' and an exit handler to stop the script if a command fails and ensure the test environment is cleaned up in any case. Also, handle the case where the script is interrupted by SIGINT. The only command that's expected to fail is 'wait $ping_pid', since it's killed by the script. Handle this case with '|| true' to make it play well with 'set -e'. Finally, return the Kselftest SKIP code (4) when the script breaks because of an environment problem or a command line failure. The 0 and 1 return codes should now reliably indicate that all tests have been run (0: all tests run and passed, 1: all tests run but at least one failed, 4: test script didn't run completely). Fixes: b690842d12fd ("selftests/net: test l2 tunnel TOS/TTL inheriting") Reported-by: Mirsad Goran Todorovac Tested-by: Mirsad Goran Todorovac Signed-off-by: Guillaume Nault --- .../selftests/net/l2_tos_ttl_inherit.sh | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/l2_tos_ttl_inherit.sh b/tools/testing/selftests/net/l2_tos_ttl_inherit.sh index cf56680d598f..f11756e7df2f 100755 --- a/tools/testing/selftests/net/l2_tos_ttl_inherit.sh +++ b/tools/testing/selftests/net/l2_tos_ttl_inherit.sh @@ -12,13 +12,16 @@ # In addition this script also checks if forcing a specific field in the # outer header is working. +# Return 4 by default (Kselftest SKIP code) +ERR=4 + if [ "$(id -u)" != "0" ]; then echo "Please run as root." - exit 0 + exit $ERR fi if ! which tcpdump > /dev/null 2>&1; then echo "No tcpdump found. Required for this test." - exit 0 + exit $ERR fi expected_tos="0x00" @@ -340,7 +343,7 @@ verify() { fi fi kill -9 $ping_pid - wait $ping_pid 2>/dev/null + wait $ping_pid 2>/dev/null || true result="FAIL" if [ "$outer" = "4" ]; then captured_ttl="$(get_field "ttl" "$out")" @@ -380,6 +383,31 @@ cleanup() { ip netns del "${NS1}" 2>/dev/null } +exit_handler() { + # Don't exit immediately if one of the intermediate commands fails. + # We might be called at the end of the script, when the network + # namespaces have already been deleted. So cleanup() may fail, but we + # still need to run until 'exit $ERR' or the script won't return the + # correct error code. + set +e + + cleanup + + exit $ERR +} + +# Restore the default SIGINT handler (just in case) and exit. +# The exit handler will take care of cleaning everything up. +interrupted() { + trap - INT + + exit $ERR +} + +set -e +trap exit_handler EXIT +trap interrupted INT + printf "┌────────┬───────┬───────┬──────────────┬" printf "──────────────┬───────┬────────┐\n" for type in gre vxlan geneve; do @@ -409,6 +437,10 @@ done printf "└────────┴───────┴───────┴──────────────┴" printf "──────────────┴───────┴────────┘\n" +# All tests done. +# Set ERR appropriately: it will be returned by the exit handler. if $failed; then - exit 1 + ERR=1 +else + ERR=0 fi