Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp337160lqr; Wed, 5 Jun 2024 07:34:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUniMJ49lqGBZtLxe7v4TkpNtvIhD+HGXGO9+0X/ohzaRFL2wPjGFwwE9icIWBG8bMfqaGbMni/NGNUNBPcBUD9GnxxpirPY7GWIjO58w== X-Google-Smtp-Source: AGHT+IHSgS6QolgKnXs1kXcZKLrjUimk4o1KKiLNukXdfwzMUlMZ86NI2KPW41Ju2JpZYRX4wJme X-Received: by 2002:a05:620a:4146:b0:794:ef79:d9e2 with SMTP id af79cd13be357-79523b1c8f1mr416693985a.0.1717598045801; Wed, 05 Jun 2024 07:34:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717598045; cv=pass; d=google.com; s=arc-20160816; b=eiwm8jhG53vuK6pE/Qw8/VXb3KhiRg6nyYEhnEcGjSv7P7uQ90QTsFYK/OlyEZlCKZ OE68kGV6x44rJRgiso6Dg7+GHpP/jfxobzj5zQiIF+4IhhO+f/tPoeRrxmBAVHvLAIOE peUVGkePYIb3fUE46afaDwWcy3xiqEbXM2neW/0Vb9ujo1Z4bwPJcx7tZ1PF9s5CNOxW dFDpS9dux8oYbRMNPdeLMRHsSg4UoXoHJlVxHiTFfjZ/E5dBdnNPPXCx//M1NjqNJK0a tj2hzJCSofaGxxvx0QIoeFDB8OgsxMQsCxf9wpXSVG8EUUGpb4Kwpp1IXf74xg3p4k5K ktDA== 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=hApoMGX/rD8/MNsJYSqk7yu+D4j6eE8vGoqoBK4GcqE=; fh=6ouCi+De9Z8AZHD8endV9Jw6lhf9xneBVHw8V1ONNdo=; b=vJaszxvjduarfSCkJrdqjtS241SNrn5ygwh7AdXR0Gd/VfqnZaeLEhuF4QBhgLP9VA df9xhnhu+bmp8VVfsfJcYkpDO/QsnXkRaYrlyEJXXISz4E2npKRcqhiOaf0UXvckDxW+ Da9CjS63m1s65ytYDwIVXmZBauYNe+/XW54YKxY+bMAwRGvQz4/z/0qyvZYmM0r8dGzQ 1NFjauN/LJAR34+su+1RHDJghQ41WadYFb+DZFhs1Wo8IhjGgxej4nE0pyF2brEqdSew X2+7FXZ7Ak5uP9BKFVggc+BCUkjh+VSk39sEoJiLV6bWpyDKgtPSmBl6dSWnbW1cVNSw seKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sO3wRMLQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202778-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202778-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794f3064cf9si1262338685a.366.2024.06.05.07.34.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 07:34:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202778-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sO3wRMLQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202778-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202778-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7772F1C22DB6 for ; Wed, 5 Jun 2024 14:34:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15A1626AD7; Wed, 5 Jun 2024 14:33:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sO3wRMLQ" 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 1073319D8B1; Wed, 5 Jun 2024 14:33:52 +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=1717598033; cv=none; b=UcYV+vqYDKOoHDX1uprh7VL4WWO6/x27110+F5mMLYMnihH/UJ24merPlBIueHasDxLwVjDzPcSydDa8NAbXBJvYQLdntSuRve+DSoMzIkjuLT61jH8YEbbvOxTIrOWtpjtvhB041fAPxB304Y2SN3MwuuW9DGAhyMKNuYGNDx0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717598033; c=relaxed/simple; bh=YlKMrykXOHD/CY+5hLXKnWTfq+ZFZ4U0U4Ww7WX5qQk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=L/BklMPaZ0d5Q+5JqHkYduPGT/bp+PSgqAxPSNMBo5F1EUcEhH5OXMPmP+obUK0w0We9tsABfs0ACRadhUxPEfSajTD1F2ETCTOymStRfWnS3A60igGE1aSSMPMTy7OnCF7waipw5bItKLBNAayaq1eFc6hhfIYyy8prTMqThOo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sO3wRMLQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F08DCC2BD11; Wed, 5 Jun 2024 14:33:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717598032; bh=YlKMrykXOHD/CY+5hLXKnWTfq+ZFZ4U0U4Ww7WX5qQk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=sO3wRMLQ4FK4MkJrYo8Xcbsd5hi7Vwt2/zajyGrhSJSJ539UTmptqTtIpiQPUiSgO JIZoQliyswdaI377pz16wFEw69uc5KJrkTTQ9iLEttR/PMsCAOqeTtDbTCxxlrSXzH lkH0Nok9zjvc33o9ewEajiC6ln5XXvPVAhPATJtcqMZIk/NXr/tlb9X8//U6ZALdrk +GuqTgzA38WDy1GiTqRhbbo0HBDsb9zo/GNSDkMR/3RAzvCpmaGFVz4/pwrLUfn+hT BXUzbgEKV6vKgm4rccEllAsGAEVe//hRsTNpnZ+gMyq7dmW6jwEyQaYHxQDHEtmaa/ viu4wyUQnOFcw== Message-ID: <5e2faef6-c80d-4fde-8b15-029b687cdf4a@kernel.org> Date: Wed, 5 Jun 2024 16:33:48 +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> <0f85551f-dd67-4d88-abc2-cdf80293a604@kernel.org> <87h6e7796c.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 YWVydHMgPG1hdHR0YmVAa2VybmVsLm9yZz7CwZEEEwEIADsCGwMFCwkIBwIGFQoJCA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7CGxdzQoHaz lzVbFe7fduHbABmYz9cefQpO7wDE/Q== Organization: NGI0 Core In-Reply-To: <87h6e7796c.fsf@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 05/06/2024 16:30, Petr Machata wrote: > > Matthieu Baerts writes: > >> 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] :) > > All right. > > Reviewed-by: Petr Machata Thank you! Cheers, Matt -- Sponsored by the NGI0 Core fund.