From patchwork Fri Aug 23 22:04:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov via B4 Relay X-Patchwork-Id: 13776070 X-Patchwork-Delegate: kuba@kernel.org 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 304C31C870D; Fri, 23 Aug 2024 22:05:18 +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=1724450719; cv=none; b=tbUSHc7mmYu9zGMmeDaS052lllDAmTdTej2ii9iD264dNfRzzyVS3WfE9M5V7kZZP/tD9MVfWjBv8sic/iFkIjuSerpEAI438UaTp8W26dUbQB8ovjwdvODmV2MJJiqmXfTZW1VGrRr+Ton7wO5z9FY+6QeeYFSHVFrozAYXCq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724450719; c=relaxed/simple; bh=ZqY2Sc3yU20kQFNWo25FG1geE3NRXJHM0WFmiQdSPI8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b8VfXbOsnH7PAoyckb92ZUTadYn8539WVho+cVkJc6yk3tPdWCw0F9R4d7FhObTmSqYT84Fxi+rY2loQYWbCdi+RWyvrEPIt/T6bb5g56+E57ylmRFubqRibubSHWy8PTNfb+4UlvdXJHQpbggzPRwe5GrWksTeXpeGJPKUbtFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=odrCV3Xt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="odrCV3Xt" Received: by smtp.kernel.org (Postfix) with ESMTPS id AC2A1C4AF13; Fri, 23 Aug 2024 22:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724450718; bh=ZqY2Sc3yU20kQFNWo25FG1geE3NRXJHM0WFmiQdSPI8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=odrCV3Xt93auH/i5PfdqFaAXxkfAWLVUnp8eZjvzT/Ey8OrvjvgNJUokFkLc9bMWO /rIfZY/f/oWoNFS2Oxr4IGa5hOybel8pT+gi+KhI42ybPhCvyahGLa70+UzWSMaL4V 2+1MTrNGmmm78pN0fzA0mpbc01RQDFXHjTODZPZgUOS5bIplAFAGhZEjMVMw6sMJYm NMOCyyHorcM9Nh4Rarf8GsQc/MLJs6Iy0jrJFKdR2ZekfVXBz50sV1yKLHnj2SZQLj qHiksU9dGVHFxX3tNc5hrFMH3aD13jMDOFoQew62Wum3yimDJnAwQJl+GPa1s2DP4W JRoVx3brrwkrA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3772C5321E; Fri, 23 Aug 2024 22:05:18 +0000 (UTC) From: Dmitry Safonov via B4 Relay Date: Fri, 23 Aug 2024 23:04:54 +0100 Subject: [PATCH net-next v4 4/8] selftests/net: Open /proc/thread-self in open_netns() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240823-tcp-ao-selftests-upd-6-12-v4-4-05623636fe8c@gmail.com> References: <20240823-tcp-ao-selftests-upd-6-12-v4-0-05623636fe8c@gmail.com> In-Reply-To: <20240823-tcp-ao-selftests-upd-6-12-v4-0-05623636fe8c@gmail.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: Mohammad Nassiri , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Safonov <0x7f454c46@gmail.com> X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724450716; l=1617; i=0x7f454c46@gmail.com; s=20240410; h=from:subject:message-id; bh=/DZmg+6IbPGdTOm+TsFWm6lsqGF2a6IiuioNpa7vVmQ=; b=1Qg0RIkvlr4xCpN/mwDo1APAEndDw0E+47mt2AWGvXv1mwRfJodBFE9XhTw3LmlbdkxFNVMD7 lK14JI02RjNB3+X3OR78MNrVdECc4Tw878BKlhg7ojtgt8qgIqSNQIi X-Developer-Key: i=0x7f454c46@gmail.com; a=ed25519; pk=cFSWovqtkx0HrT5O9jFCEC/Cef4DY8a2FPeqP4THeZQ= X-Endpoint-Received: by B4 Relay for 0x7f454c46@gmail.com/20240410 with auth_id=152 X-Original-From: Dmitry Safonov <0x7f454c46@gmail.com> Reply-To: 0x7f454c46@gmail.com X-Patchwork-Delegate: kuba@kernel.org From: Dmitry Safonov <0x7f454c46@gmail.com> It turns to be that open_netns() is called rarely from the child-thread and more often from parent-thread. Yet, on initialization of kconfig checks, either of threads may reach kconfig_lock mutex first. VRF-related checks do create a temporary ksft-check VRF in an unshare()'d namespace and than setns() back to the original. As original was opened from "/proc/self/ns/net", it's valid for thread-leader (parent), but it's invalid for the child, resulting in the following failure on tests that check has_vrfs() support: > # ok 54 TCP-AO required on socket + TCP-MD5 key: prefailed as expected: Key was rejected by service > # not ok 55 # error 381[unsigned-md5.c:24] Failed to add a VRF: -17 > # not ok 56 # error 383[unsigned-md5.c:33] Failed to add a route to VRF: -22: Key was rejected by service > not ok 1 selftests: net/tcp_ao: unsigned-md5_ipv6 # exit=1 Use "/proc/thread-self/ns/net" which is valid for any thread. Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com> --- tools/testing/selftests/net/tcp_ao/lib/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/tcp_ao/lib/setup.c b/tools/testing/selftests/net/tcp_ao/lib/setup.c index e408b9243b2c..d5212ffe9489 100644 --- a/tools/testing/selftests/net/tcp_ao/lib/setup.c +++ b/tools/testing/selftests/net/tcp_ao/lib/setup.c @@ -111,7 +111,7 @@ static void sig_int(int signo) int open_netns(void) { - const char *netns_path = "/proc/self/ns/net"; + const char *netns_path = "/proc/thread-self/ns/net"; int fd; fd = open(netns_path, O_RDONLY);