Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1160520lqt; Fri, 7 Jun 2024 09:34:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWx1gCworaGrzDlejYcsWqaX85wuL8QmHCDXo8MjUrmGPLltW+kldrE2tx2WpfWA8vOhk6jPlcPLSr8qhgfFzfTHxF4lJCMcnAkB+n7ww== X-Google-Smtp-Source: AGHT+IGeqygLf3M9jDwQ+LyHUUWXSHIWGgSNz9al6PPI06b/jWdUL/0TlRtIQdmPuLrG2sKePVAD X-Received: by 2002:a50:d603:0:b0:57c:5ec6:1466 with SMTP id 4fb4d7f45d1cf-57c5ec617d8mr1302221a12.25.1717778064047; Fri, 07 Jun 2024 09:34:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717778064; cv=pass; d=google.com; s=arc-20160816; b=ElYnDPBhzd/dWcDFaUrPXBK8i7rtxX5FzYNQBP0clriw1jUMKMGdfEtcJR3h2fbDoX Cv2iStcU1pDxnmqsgXQaDfZQ1QgPHAqL7c+j5qAtoLB1bP+c8xn1h4qx3vRMgYSBFXmz XNc4suDdU5/WQ6S6P6Fx3u2smAlvEiO3TPKKlwiNJWw2RUUi8jY2WafBWX+sXhj/zFLW 1fUyJxUJQATOFlB33PYIcVkhrX5CL76nZkWXFYtKMPPI8VL1JfwZ8cCzHZIZw4LBZvBT 4Eb9Bp0AKA72fTJlRM4IKzZ2H0p0Xw7Ri/BNPtT35jh3uiqL26bsqVphGhF/gbcH8F+A 49DQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=ijNteJ10YcqoLk1WZG5g9dtzEtHTWZXF5G3e2h92t68=; fh=yV+CyQQU5CQYm49L//2pSqWoqtTo9qDeAk2A8jCHhlA=; b=vyM5eBH6PgpvuL6JYBouLhhAYwIyJAzRf9n51eBJ/KxFxXEK/cONlH+swacfVYgJ2g xKD4avJVNzfUAl5CdDEihXuxHDyXVBI43ChTjcuycNhcA/TFefYSeX5bv8g7ndklET6X NamAj9J2oNPDJmmZhm/nPVwi7Aohow2/QqpjOozYTLVEAJJ1nOMji2d9YZBjWMiacwrd GS5S8UBXsmyGiMqRTbr9IvAonf6GrXl4G1rJt4xhvk3Avp1hlRHBwcbUFKzsLFKxmZHK +oU/oni6cOgqv+EY0xVcXRKf05ghFv1EB+1gb/lHeOFKkbJoRcKCn4YX8MSMiAP5qcAN Aq/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SzKgewzc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206487-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae0c6adfsi1954569a12.19.2024.06.07.09.34.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 09:34:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SzKgewzc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-206487-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206487-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AE3041F21ADD for ; Fri, 7 Jun 2024 16:34:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9892E19DF4A; Fri, 7 Jun 2024 16:31:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SzKgewzc" 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 B4C1619D086; Fri, 7 Jun 2024 16:31:23 +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=1717777883; cv=none; b=aAEH9OSQ5GM49CPxhYKAYYBVvhV2U8VjYElrZsygZ5scEN9UwDNlnzkVxQ6RzxRHJ+wl43xvjPaOuoyduj9M4zgixoO+nEjm4PtU34sgQJOc/tHw0OKa1sP8d/xTiYXNcaGMLmWNd594FUXMuVJvjZZ4iR2pzbnuVnidHG0k0hI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777883; c=relaxed/simple; bh=aPJpHAeNe0wKoflzT/D8579aR4XIiEdzgLQY7rq35Zw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WgCos98DK9yJUPtHRMZIIqW/uDU+aYiN/cLTOZoUKUJXHCcJi+lVElNexD1xlRJ6XImTa7LCaRitjJgZDVMWjBgfKyZG4O/A5Jk19ife+KGnnv+f9mESe8qoch2RlUnIIGA6e+K1t7oB1IFKj7LQEXEWVrpuLkZvcUd13nAuRYg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SzKgewzc; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E49FDC3277B; Fri, 7 Jun 2024 16:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717777883; bh=aPJpHAeNe0wKoflzT/D8579aR4XIiEdzgLQY7rq35Zw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SzKgewzcFNF32RlgUw6Umri7LeDgOGpHE6JurGv11qO0PQ7tlpHuXGZpMfKJGBJol rDaAQ0eNuAD8ixbfc9wWFr1eLLRdr4Z84u4conjQVIjHtO9Zf9eGVbh+L6fYlBToJ/ 4hO0G2ZUz/XQ0d8marXn3xoZEZaznnoJT7sRyueHJgUBeOGGN1F4RfESfGh5z88KN9 weZPmNst9snwy4/lLUMyhY0Y/x4av1b7E4UL7e6YyFQIL+o7da9gMzPMrBnjhRHkJu JwZ5d540XXyj+DG8TU5UQ9aXKPkNcNd1QXDvSFtI1nv1FEWEk6dgpTZax2GeAFxCkZ sWxzLzBSfP+ag== From: "Matthieu Baerts (NGI0)" Date: Fri, 07 Jun 2024 18:31:04 +0200 Subject: [PATCH net-next 3/6] selftests: net: lib: do not set ns var as readonly Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-3-e36986faac94@kernel.org> References: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> In-Reply-To: <20240607-upstream-net-next-20240607-selftests-mptcp-net-lib-v1-0-e36986faac94@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Mat Martineau , Geliang Tang Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1425; i=matttbe@kernel.org; h=from:subject:message-id; bh=aPJpHAeNe0wKoflzT/D8579aR4XIiEdzgLQY7rq35Zw=; b=kA0DAAgB9reCT0JpoHMByyZiAGZjNc+g+wpgVr54enYiE3MSQI9jbS1MMPC63CqfS0ScQ0nvy YkCMwQAAQgAHRYhBOjLhfdodwV6bif3eva3gk9CaaBzBQJmYzXPAAoJEPa3gk9CaaBzkcYP/Rzh 85Zlt1I6xcrSsf3+TPwS7H/AxPlVAV5RGb3na/7sbAx2SmbZPvjhjAqv1wPQ0g370JZnJ0bL6aD /NSCQQ/Us5lx05oJc7rI5uSrEyIbdAwXS4jgwaSMA7RSPmVMVN+rz8WgSe7HUU4NqY9P2q2Yrtb z+pBx7PP154tYLkoGUNupj94PCaE3jbkNXGLAxQv7bGJGfJyZvCu0VFF6n+nPmfWcad6sFMw959 BlZLyxZQcBTQ04J7TKs6Hjv3fUvcf+JqjP615+pKWp1mRNZJIwZppRyF1llO4Od2O54f01Agxsw bclkHb3CZ1eYKxJP1619yomF6F3+O4olglcI5vRk4bx9JZGxL36DR1sb2tbYqhw/DUtrwkO8HCU z+YILY+09zrEg92v01XS+/N/v82PB9xuFJcGID7lKN0jc3P7HHBe2bFAJGcx9R7cKL2vB8EYKk+ dte8g4xkqqrREJ11X2FcemVjQbNhLxsJws9szYnt7iBtS2LydgR8rg7Ws+ffNNLGMpE0X17ZkFX cQ0Iqtb55seWu4vfsRTCFV1OcGuhq1Qzznu+OoYpYEKmKiBgbcW2fYiAPHD5Bgjns6cCRkcQ/VG ftFDDPDQiWGMEPHSSNbWAPJdBb6sPI1biTwqhrIDp9Kqs0vhQeJgrkhCP6seRNuzxP1xWV3VqyY T4Wuh X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 It sounds good to mark the global netns variable as 'readonly', but Bash doesn't allow the creation of local variables with the same name. Because it looks like 'readonly' is mainly used here to check if a netns with that name has already been set, it sounds fine to check if a variable with this name has already been set instead. By doing that, we avoid having to modify helpers from MPTCP selftests using the same variable name as the one used to store the created netns name. While at it, also avoid an unnecessary call to 'eval' to set a local variable. Reviewed-by: Geliang Tang Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/lib.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index c7a8cfb477cc..114b927fee25 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -172,11 +172,11 @@ setup_ns() local ns_list=() for ns_name in "$@"; do # Some test may setup/remove same netns multi times - if unset ${ns_name} 2> /dev/null; then + if [ -z "${!ns_name}" ]; then ns="${ns_name,,}-$(mktemp -u XXXXXX)" - eval readonly ${ns_name}="$ns" + eval "${ns_name}=${ns}" else - eval ns='$'${ns_name} + ns="${!ns_name}" cleanup_ns "$ns" fi -- 2.43.0