Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp331126lqr; Wed, 5 Jun 2024 07:24:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXvs/Ss9H5gwLj1rfp9P6ttUJexWFOtfSKa7UrBwMs37FEb0QVqII6VYA1S6fJJnBg4Vp9xOeZ3LLpZ2xBD7Wd90o/1gNLghAKgz0bAUA== X-Google-Smtp-Source: AGHT+IHh+l823jcglzwhKrpjZLq8ozHr6+FXzAPGSyS7+Y/kzUwLkhscif+MHZgvXF4GT39rwXhL X-Received: by 2002:a17:902:ea02:b0:1f6:3429:69d7 with SMTP id d9443c01a7336-1f6a5a6bd4amr35657275ad.52.1717597444562; Wed, 05 Jun 2024 07:24:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717597444; cv=pass; d=google.com; s=arc-20160816; b=X3t6+XczznDbEwd5ixW15eYWxruUZA5XbrjwRIKX3OAXwcNaFfmwdlH1TVBkiCDYKf DdCn9mFV7Dfr+qkWtLJvge2UHM5Q0RYqwocRR3jPGSVgGtiaBHPUMp/3bcSMj7QSnf0i y7V9tRx5VvOumQe6nzmSO5iqqO0+Yq6dZDO5GggKBexZf+3Mgt6z0WOEYKr3nDcRmPiC /fG3nJQnE596hJrxESajQ/YvkjsSIy7Zkl27e8cZ6JSfoZDj7uuITUf5Y/8b+G+VUKwl CSwIqnyiY4jEjRXNzPLXSgShp+dcFuZqskpSSMKOT88nGlRnzB0ynMEfzsAUwLYque6p 0eHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :references:cc:to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=eJBRCTuaLxjp7U53m9kB762f2BNHW1kEM6+KaRnq+cg=; fh=6ouCi+De9Z8AZHD8endV9Jw6lhf9xneBVHw8V1ONNdo=; b=wf1mzmbjuhliYRX4TKzsiOmreO7fVroUWhcSholwqxWQxDG/Rm+vaNAEZPholT9E9F Py0/lJMW2ODzkCVRqwSjqk+1saGQHD1EfLNXgltx7dep5pEtifAqaFHISiwXsY2Ytm7Z 20wXddHuNG44zTsVXFsv8udYdKpgIGED/xt2N7ACdXOz41I34nN2/OjdvX8dAnNJ/dhu mFSnPMLOXrfABEbqJWTsPZaY3yK4kj+Xegn3+URcNmdkfVzBUD+y1tEdgHW4dk9xDDZK 1EiE4yXSqKmlb7GrUq/4WZtBWKMw+9NwflUjMZy3IGU4nCvsJbqDO1VErHpEQKVN1tFg RTEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UrnsKbt+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202761-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202761-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f63233d132si4652715ad.6.2024.06.05.07.24.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 07:24:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202761-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UrnsKbt+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202761-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202761-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 25D9528A250 for ; Wed, 5 Jun 2024 14:13:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1F051BDDF; Wed, 5 Jun 2024 14:12:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UrnsKbt+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABE8A6FB0; Wed, 5 Jun 2024 14:12:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717596777; cv=none; b=V1jT3HnwDJ50oyh9P3myghYs+Vy7mY0GMBjVwujBQyP//TJF/IxzhYIT0BsikKvym3Pb/PNk9t3TeFQpCQPIWehBb+q9miKLGvbWmYb9aRHxofMujN1/pGWbsBTdD9g5BDLgp3VbkR1RTLFiqhrFXA/6k49rOWnW9/n6N0Aden0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717596777; c=relaxed/simple; bh=ozvkOGgUaxgxta5ytOJ2UVPWZSX57s6TLs8ldu0HwZQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=p+keQyTm2+TYerIlJK9WvtpawBYQNHkw4lSBWbsO/fDy5o5rl0niOwrAP1egzJLDiTqa50ynt/z9jyacoFdDXO7hXRd5pxvOnNdrO29F1kuuSfPLX05mJQTz3sY/ls/YCEBD3zlCUQNCymldbviLkskEhYEUvfmC7Zx8tG3RKC4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UrnsKbt+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A920C2BD11; Wed, 5 Jun 2024 14:12:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717596777; bh=ozvkOGgUaxgxta5ytOJ2UVPWZSX57s6TLs8ldu0HwZQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=UrnsKbt+4SxFIHs9D7s0CLZz9RiwVy9uaPxcmHYlp8AO7wBrkAnAsiSWkBqnR8rAr ZFHnnMzUWLEpGNnoqLbWVMHsZwOE2VMqe8ujTBVCDjFCbuCE+HeL45a6qALbWxQd2U CZ1yVJ4i9TkWCZlKp3z/5Op32xwZdUR0tYhxAJqPw5WdlyPTl9E4P2dX9VC1gss8cc gk3xXKvbR4FU3Khm8+yZmSsX1rHlVVLCBk3gKH1O+ZiV3DsDhhRnq5iTDcxzafjKb8 d7/JDIa5zfAKyCvrM1fgwzje/2comJeg91ZR65SEOFYSLljurnqludiVTkQQf5LaLq HsMx4QCGUDvEw== Message-ID: <0f85551f-dd67-4d88-abc2-cdf80293a604@kernel.org> Date: Wed, 5 Jun 2024 16:12:52 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH net 2/3] selftests: net: lib: avoid error removing empty netns name Content-Language: en-GB To: Petr Machata Cc: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Hangbin Liu , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Geliang Tang References: <20240605-upstream-net-20240605-selftests-net-lib-fixes-v1-0-b3afadd368c9@kernel.org> <20240605-upstream-net-20240605-selftests-net-lib-fixes-v1-2-b3afadd368c9@kernel.org> <877cf38yg5.fsf@nvidia.com> From: Matthieu Baerts Autocrypt: addr=matttbe@kernel.org; keydata= xsFNBFXj+ekBEADxVr99p2guPcqHFeI/JcFxls6KibzyZD5TQTyfuYlzEp7C7A9swoK5iCvf YBNdx5Xl74NLSgx6y/1NiMQGuKeu+2BmtnkiGxBNanfXcnl4L4Lzz+iXBvvbtCbynnnqDDqU c7SPFMpMesgpcu1xFt0F6bcxE+0ojRtSCZ5HDElKlHJNYtD1uwY4UYVGWUGCF/+cY1YLmtfb WdNb/SFo+Mp0HItfBC12qtDIXYvbfNUGVnA5jXeWMEyYhSNktLnpDL2gBUCsdbkov5VjiOX7 CRTkX0UgNWRjyFZwThaZADEvAOo12M5uSBk7h07yJ97gqvBtcx45IsJwfUJE4hy8qZqsA62A nTRflBvp647IXAiCcwWsEgE5AXKwA3aL6dcpVR17JXJ6nwHHnslVi8WesiqzUI9sbO/hXeXw TDSB+YhErbNOxvHqCzZEnGAAFf6ges26fRVyuU119AzO40sjdLV0l6LE7GshddyazWZf0iac nEhX9NKxGnuhMu5SXmo2poIQttJuYAvTVUNwQVEx/0yY5xmiuyqvXa+XT7NKJkOZSiAPlNt6 VffjgOP62S7M9wDShUghN3F7CPOrrRsOHWO/l6I/qJdUMW+MHSFYPfYiFXoLUZyPvNVCYSgs 3oQaFhHapq1f345XBtfG3fOYp1K2wTXd4ThFraTLl8PHxCn4ywARAQABzSRNYXR0aGlldSBC YWVydHMgPG1hdHR0YmVAa2VybmVsLm9yZz7CwZEEEwEIADsCGwMFCwkIBwIGFQoJCAsCBBYC AwECHgECF4AWIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZUDpDAIZAQAKCRD2t4JPQmmgcz33 EACjROM3nj9FGclR5Aly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mAPznyKyXEfG+0rrVseZSEssKmY01IsgwwbmN9ZcqUKYNhjv67WMX7tNwiVbSrGLZoqf Xlgw4aAdnIMQyTW8nE6hH/Iwqay4S2str4HZtWwyWLitk7N+e+vxuK5qto4AxtB7VdimvKUs x6kQO5F3YWcC3vCXCgPwyV8133+fIR2L81R1L1q3swaEuh95vWj6iskxeNWSTyFAVKYYVskG V+OTtB71P1XCnb6AJCW9cKpC25+zxQqD2Zy0dK3u2RuKErajKBa/YWzuSaKAOkneFxG3LJIv Hl7iqPF+JDCjB5sAEQEAAcLBXwQYAQIACQUCVeP56QIbDAAKCRD2t4JPQmmgc5VnD/9YgbCr HR1FbMbm7td54UrYvZV/i7m3dIQNXK2e+Cbv5PXf19ce3XluaE+wA8D+vnIW5mbAAiojt3Mb 6p0WJS3QzbObzHNgAp3zy/L4lXwc6WW5vnpWAzqXFHP8D9PTpqvBALbXqL06smP47JqbyQxj Xf7D2rrPeIqbYmVY9da1KzMOVf3gReazYa89zZSdVkMojfWsbq05zwYU+SCWS3NiyF6QghbW voxbFwX1i/0xRwJiX9NNbRj1huVKQuS4W7rbWA87TrVQPXUAdkyd7FRYICNW+0gddysIwPoa KrLfx3Ba6Rpx0JznbrVOtXlihjl4KV8mtOPjYDY9u+8x412xXnlGl6AC4HLu2F3ECkamY4G6 UxejX+E6vW6Xe4n7H+rEX5UFgPRdYkS1TA/X3nMen9bouxNsvIJv7C6adZmMHqu/2azX7S7I vrxxySzOw9GxjoVTuzWMKWpDGP8n71IFeOot8JuPZtJ8omz+DZel+WCNZMVdVNLPOd5frqOv mpz0VhFAlNTjU1Vy0CnuxX3AM51J8dpdNyG0S8rADh6C8AKCDOfUstpq28/6oTaQv7QZdge0 JY6dglzGKnCi/zsmp2+1w559frz4+IC7j/igvJGX4KDDKUs0mlld8J2u2sBXv7CGxdzQoHaz lzVbFe7fduHbABmYz9cefQpO7wDE/Q== Organization: NGI0 Core In-Reply-To: <877cf38yg5.fsf@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Petr, Thank you for the review! On 05/06/2024 12:38, Petr Machata wrote: > > "Matthieu Baerts (NGI0)" writes: > >> If there is an error to create the first netns with 'setup_ns()', >> 'cleanup_ns()' will be called with an empty string as first parameter. >> >> The consequences is that 'cleanup_ns()' will try to delete an invalid >> netns, and wait 20 seconds if the netns list is empty. >> >> Instead of just checking if the name is not empty, convert the string >> separated by spaces to an array. Manipulating the array is cleaner, and >> calling 'cleanup_ns()' with an empty array will be a no-op. >> >> Fixes: 25ae948b4478 ("selftests/net: add lib.sh") >> Cc: stable@vger.kernel.org >> Acked-by: Geliang Tang >> Signed-off-by: Matthieu Baerts (NGI0) >> --- >> tools/testing/selftests/net/lib.sh | 13 +++++++------ >> 1 file changed, 7 insertions(+), 6 deletions(-) >> >> diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh >> index a422e10d3d3a..e2f51102d7e1 100644 >> --- a/tools/testing/selftests/net/lib.sh >> +++ b/tools/testing/selftests/net/lib.sh >> @@ -15,7 +15,7 @@ ksft_xfail=2 >> ksft_skip=4 >> >> # namespace list created by setup_ns >> -NS_LIST="" >> +NS_LIST=() >> >> ############################################################################## >> # Helpers >> @@ -137,6 +137,7 @@ cleanup_ns() >> fi >> >> for ns in "$@"; do >> + [ -z "${ns}" ] && continue > > I think this is now irrelevant though? Now cleanup_ns() will be called > with no arguments for an empty NS list, so the loop does not even kick in. If you don't mind, I think it is "safer" to keep it: some selftests are using 'cleanup_ns()' directly, not via 'cleanup_all_ns()', e.g. netns-name.sh, cmsg-*.sh, fib-*.sh, etc. which can call it with the variables not set if 'setup_ns' failed during the init phase. For the moment, all these selftests are calling 'cleanup_ns()' with parameters added without double quotes: so it is fine. Until someone changes that to please shellcheck, like we did on our side with MPTCP selftests. So this line will be useful soon when we will publish the rest of our patches to use 'lib.sh' [1] :) Link: https://lore.kernel.org/mptcp/5f4615c3-0621-43c5-ad25-55747a4350ce@kernel.org/T/ [1] Cheers, Matt -- Sponsored by the NGI0 Core fund.