Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp648156pxb; Tue, 2 Feb 2021 14:18:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzex8VldWlHLW1YIDFRiD4q+RDz/dFzT8eSe5BmyLmStqJu47LkwTss0mJcZjbOhvqwoGjs X-Received: by 2002:a17:906:5e45:: with SMTP id b5mr137574eju.69.1612304279990; Tue, 02 Feb 2021 14:17:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612304279; cv=none; d=google.com; s=arc-20160816; b=Xq1wa/1FxddviznNehNwaSeZf40U5ld0yZbS1jEUWAvHXxPLA70PsYKvvFUrJqXIom o//zH6EqRKkZL0Z8MUZvEgNEOtiPn+NZ6I6PLJN5b0tF7SpXaFqmaDNDemgzEtIiVA+x 9/f5h5Svfa/NfJQigNO5/W8wmIpGtzUOh/hBBLYpgjhugomcqOqexxN7FXFnTfR3n3T4 DBeER1I76hKrmKPLv7hZQr3mmQmCaoBUPkEm9tKAPY4mbPJwnTJCXS1G9u1TokccY0jv xeJoki2UJYTPfJsiGrn8Lkjd4DQ/vEpIQD7T5S7isHC+Vx+g0xiuAWvOeiK4l2Ky6J5X jkSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H4rHNlGPyIVOL1aYDfnlb3hrpk1k6UK4ugVv2qVl/WU=; b=wNGjcB4aaQzsLGwy39KZaeIixvfs8Qcg13hbTN6RW8uKP9YCU7JAe6aiuSq7+OzaFS ZnIwADWqSLB7WKdYf7Xo2eOLsWcTkS03aMcDKNoNWp78B5bDE1H0DxZpdbXONCZK3BoR I9O5tIIJGtSebNI/8v8h919E17zwaZ4YRamDiYC/dGNektZl/jarVrUB8K50MC8mhItD IpDZ3pp6ixpygc216UZ5d6qTK+lv84xPsHv0oqk5hGk4ftSQMuUBrKlLy2TerBtJIAvW S8rfk9T3iR0l7esxLtfL53bNkukZS3T590KqZtwRQd2VOZ8J/fGcUhk3t5+TkwHMD6Nw pYHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Tz9/8gNZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q26si36847edt.415.2021.02.02.14.17.35; Tue, 02 Feb 2021 14:17:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Tz9/8gNZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233554AbhBBN7n (ORCPT + 99 others); Tue, 2 Feb 2021 08:59:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:41022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233289AbhBBNxr (ORCPT ); Tue, 2 Feb 2021 08:53:47 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BFA3064FCD; Tue, 2 Feb 2021 13:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273452; bh=Sa6tYb4IWmrl1JerSSQA4Px3w1Hsran4E+EIK/mwfYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tz9/8gNZaDHQ2pGOh7A7PuN0yirxNDVNoiuFevih3ev5DbBCqiyTvoBsbAO2tfu+9 CG7ETyESahkC9ioCZpqTq29QbjRSChoeZSfh5eb+zU7jf+s6zA3QTDwiuJDCDXA78E WGzPSVndju9j21IY9OaKwKsuZL+p0K1oo6QxhXEE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Po-Hsu Lin , Florian Westphal , Steffen Klassert , Sasha Levin Subject: [PATCH 5.10 080/142] selftests: xfrm: fix test return value override issue in xfrm_policy.sh Date: Tue, 2 Feb 2021 14:37:23 +0100 Message-Id: <20210202133001.004840935@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Po-Hsu Lin [ Upstream commit f6e9ceb7a7fc321a31a9dde93a99b7b4b016a3b3 ] When running this xfrm_policy.sh test script, even with some cases marked as FAIL, the overall test result will still be PASS: $ sudo ./xfrm_policy.sh PASS: policy before exception matches FAIL: expected ping to .254 to fail (exceptions) PASS: direct policy matches (exceptions) PASS: policy matches (exceptions) FAIL: expected ping to .254 to fail (exceptions and block policies) PASS: direct policy matches (exceptions and block policies) PASS: policy matches (exceptions and block policies) FAIL: expected ping to .254 to fail (exceptions and block policies after hresh changes) PASS: direct policy matches (exceptions and block policies after hresh changes) PASS: policy matches (exceptions and block policies after hresh changes) FAIL: expected ping to .254 to fail (exceptions and block policies after hthresh change in ns3) PASS: direct policy matches (exceptions and block policies after hthresh change in ns3) PASS: policy matches (exceptions and block policies after hthresh change in ns3) FAIL: expected ping to .254 to fail (exceptions and block policies after htresh change to normal) PASS: direct policy matches (exceptions and block policies after htresh change to normal) PASS: policy matches (exceptions and block policies after htresh change to normal) PASS: policies with repeated htresh change $ echo $? 0 This is because the $lret in check_xfrm() is not a local variable. Therefore when a test failed in check_exceptions(), the non-zero $lret will later get reset to 0 when the next test calls check_xfrm(). With this fix, the final return value will be 1. Make it easier for testers to spot this failure. Fixes: 39aa6928d462d0 ("xfrm: policy: fix netlink/pf_key policy lookups") Signed-off-by: Po-Hsu Lin Acked-by: Florian Westphal Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- tools/testing/selftests/net/xfrm_policy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/xfrm_policy.sh b/tools/testing/selftests/net/xfrm_policy.sh index 7a1bf94c5bd38..5922941e70c6c 100755 --- a/tools/testing/selftests/net/xfrm_policy.sh +++ b/tools/testing/selftests/net/xfrm_policy.sh @@ -202,7 +202,7 @@ check_xfrm() { # 1: iptables -m policy rule count != 0 rval=$1 ip=$2 - lret=0 + local lret=0 ip netns exec ns1 ping -q -c 1 10.0.2.$ip > /dev/null -- 2.27.0