Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp307469rbb; Sat, 24 Feb 2024 01:08:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUROE3MBVDdqX0lT1EbFKF5XuwLlljhbvJDSQF6El7kh1UvG1b67ykMYJaGk8PsC9ssgOjfsccFVf693xGttHJmg+cvqbgvfM+scUNmSQ== X-Google-Smtp-Source: AGHT+IEwjpOKNDGhB0Xw/DjelhZrLthOd7XkedqzAj+1fHMTb6+pVRFMWkJLwNQu/VdI6G/THsyb X-Received: by 2002:a05:622a:353:b0:42e:7856:2134 with SMTP id r19-20020a05622a035300b0042e78562134mr126639qtw.57.1708765679973; Sat, 24 Feb 2024 01:07:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708765679; cv=pass; d=google.com; s=arc-20160816; b=J+ZPKbP6WBFBqQVWqj27FlMygorQ8ZnLsf1yZcwq4/gLdnE4nr9ezk4rc3pRc4tOXH uaa0ISLDQJE1a2Zo/A6q7rHBBRXNX0AY01i1TSjkBNSPlvEkJrhuzWc4c88TNrmhvbJx WaYWiEjkzu0LmAH16+8rUYBVU1WMouKrDdwF7PxVlH/z3z8ifhrZ1x4i4fHkuO2BJCiy 7/G7ewG5tQnBPZznUjfYKp9P+Ixuakyr/NQ9LK+i996qctsel18FjqzwnT+g2/H/+2aG rXUAyUEO+DcdJPj9KaXC4GFX7BpWWPm22f60IAEPkdot8C5QQtC9BoPD4przTgHPqKNi eD+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=x86i2bLvLQ8s2ekOK4n+eRSdBkIkaafdJNLN4ekEok0=; fh=QdXNwV1Tx9KDcA/3cwlY+fwamoPtTVxMqLCt7AdGDVg=; b=OionT0WCUCNG5Vr1yv+XnMdByqvmmquMh8Z57gEL04pZFl62Cw/HkowYqwuApXrmGK 1UeOhQTGR8dspWWr+JzDkXdTHRU0Zc8tI/qz60xjE1EWyUA5W1rbXe/aUttzDZZ0AHj1 tAsZfa789F1X8FWd2Qtm5q1KNNZbx3gmKnLLLjnbM2F21o7iGHQVpphbnviF1eaHNN47 U7sKzJ59cfFqjIUqP0TAFNHTzUpHwbTV3RWYMbOFU2Am7nJ7TH0p5Ws7dQD3Bv+ij0/v LYA0641RNThR4pdq4//AOlO0Kn8E9C4xkRN+ZWIzJaHidAru4gxpp+d4GTnWObpXew4M HTFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=fVAsJOCx; arc=pass (i=1 spf=pass spfdomain=arista.com dkim=pass dkdomain=arista.com dmarc=pass fromdomain=arista.com); spf=pass (google.com: domain of linux-kernel+bounces-79529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t13-20020ac8760d000000b0042e4ad8a83dsi700092qtq.779.2024.02.24.01.07.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 01:07:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=fVAsJOCx; arc=pass (i=1 spf=pass spfdomain=arista.com dkim=pass dkdomain=arista.com dmarc=pass fromdomain=arista.com); spf=pass (google.com: domain of linux-kernel+bounces-79529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com 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 9181B1C21A1D for ; Sat, 24 Feb 2024 09:07:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C92345BF0; Sat, 24 Feb 2024 09:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b="fVAsJOCx" Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC84E3F9E0 for ; Sat, 24 Feb 2024 09:04:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708765500; cv=none; b=kJ3rSiRve5aTt2z8OJuOvVF/e/+SlejOWxWgc7P+KpnZsDPvgr+hiOBS5CfuEQQQufzAgbcb8iXaxVyRMxSsoZ4EUKorYfGqrr5E8L65fmSfeWYJepP2EZA1nbWISeK/yHMzamNGNosfQLuJlwNSL749yraWIyiP/izhdwb5QXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708765500; c=relaxed/simple; bh=W2t1gDt0S4a1/HW/6/kG7xzEKfo9X9H0YdqgUGLKJyM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ESU2mUt7gxTqB31dAC3F8cIEnl0U5HE529/z0fR/KMg1MPpDaabs2T72+n6fSr2rRGSG+9CSKYAYqeyMlJ5Gym9ASMmUmcE3dCzf/tpOrr4yBq5Mh/K8UaQZBvqfy0W5SmeTasTrR8G3E/NDQxx/fORdIe2yr5zR0OF1Uxy+lCg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=arista.com; spf=pass smtp.mailfrom=arista.com; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b=fVAsJOCx; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=arista.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arista.com Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4129ee52503so753025e9.1 for ; Sat, 24 Feb 2024 01:04:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1708765497; x=1709370297; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x86i2bLvLQ8s2ekOK4n+eRSdBkIkaafdJNLN4ekEok0=; b=fVAsJOCxmCUI1Kxw29LiXfG+xui/HzyYCAVQpMHLm5MC0zVM88loKBF6sVav42jEwt o8NUDMVCz4AiHIblhZE3AulVB1kXI34JlvY+v32TitlwKxnjN+E13eUXZzWXGdyBF6V2 m1OaGm3Fc1XoK+V8F6t8F1lcLRsJD5cO9wco/Yi3KUq54yBBKpEukTkCWNGYh80Exfim mrCifyxfaSfmbzBlUMMkFqNNxk/br5T6fCct5AL/VIK60RWNvqRwWBRMn8pOq+XQ8hhv d1E9mgOXkpVeY2pT8XFLSv/v50O3gphVy2lxtgxTSzssbJNhU8u6rdfgwbKkXicEUHFA CVgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708765497; x=1709370297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x86i2bLvLQ8s2ekOK4n+eRSdBkIkaafdJNLN4ekEok0=; b=pe6Z+Cp6H25NyxR2AC2dboT5iv4kAoeYOsQkDoj+XkCUGxOE1RG2gw/jder5c6KtPJ Jn0zUFwphfsWV+lkad23QiYOmRtSOrpQ6etvdyjuqXj4HHwxisvH0HBSFepZE6UPthfe YM4Z4ASmvfpfXAVCJo4kM1BTt2MH12o8yEAyrixuEJeFeHo8eiAwGcJllWIUHviesUl6 hEz8RiuwPfRpit3J3hgC9az4BHQWYuM0aSS83FgeJQuuv7yjXkXC1rvvfj/hL87Z4W1G sDxvv0ATgU3ZNPimirmk+iXKG4A0WlfFDnuVF1iceiF4jmPtmliSGXTUFfKOYV4rGcO4 ou2A== X-Forwarded-Encrypted: i=1; AJvYcCVeZc/OAjKp3OIJTNkD/P3+X1eVEnc2JeQi9kzBWiQ34M5noPt9hQiCgc2xW/QfMmqTrsqma8uqCEQXz0LUQuQAzbnksh/qKnabIDi6 X-Gm-Message-State: AOJu0Yy9dC/XX+92BoILeDwTbs7VoMTusaOUiYQITxTVvTEI+eN4oASN aOWK/70G5PdSA2fmKA6NkTlJJbgOB0R+OnL7D2C9h5Q221am+rCylyECXvFdpQ== X-Received: by 2002:a05:600c:4f52:b0:412:8872:e8f4 with SMTP id m18-20020a05600c4f5200b004128872e8f4mr1491142wmq.1.1708765497395; Sat, 24 Feb 2024 01:04:57 -0800 (PST) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id m6-20020a7bce06000000b00410bca333b7sm5320593wmc.27.2024.02.24.01.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 01:04:56 -0800 (PST) From: Dmitry Safonov To: Eric Dumazet , "David S. Miller" , Jakub Kicinski , Paolo Abeni , David Ahern , Shuah Khan , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: Dmitry Safonov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Dmitry Safonov <0x7f454c46@gmail.com> Subject: [PATCH net-next 09/10] selftests/net: Don't forget to close nsfd after switch_save_ns() Date: Sat, 24 Feb 2024 09:04:17 +0000 Message-ID: <20240224-tcp-ao-tracepoints-v1-9-15f31b7f30a7@arista.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240224-tcp-ao-tracepoints-v1-0-15f31b7f30a7@arista.com> References: <20240224-tcp-ao-tracepoints-v1-0-15f31b7f30a7@arista.com> 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" X-Mailer: b4 0.13-dev-b6b4b X-Developer-Signature: v=1; a=ed25519-sha256; t=1708765347; l=1645; i=dima@arista.com; s=20231212; h=from:subject:message-id; bh=W2t1gDt0S4a1/HW/6/kG7xzEKfo9X9H0YdqgUGLKJyM=; b=HrtiK7tVw/bjSYWfjeueAiyqfvuMn5IWHQgF7i/oeeqthLP8sDdHMXQ2ky8sLEotB7YM5TdU3 8MnzdiddrQEDEnm5kK5GLfccXOWIvziIgaef9UzqhAamDJrH9nnxroF X-Developer-Key: i=dima@arista.com; a=ed25519; pk=hXINUhX25b0D/zWBKvd6zkvH7W2rcwh/CH6cjEa3OTk= Content-Transfer-Encoding: 8bit The switch_save_ns() helper suppose to help switching to another namespace for some action and to return back to original namespace. The fd should be closed. Signed-off-by: Dmitry Safonov --- tools/testing/selftests/net/tcp_ao/lib/setup.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/tcp_ao/lib/setup.c b/tools/testing/selftests/net/tcp_ao/lib/setup.c index 92276f916f2f..f80120bef3dc 100644 --- a/tools/testing/selftests/net/tcp_ao/lib/setup.c +++ b/tools/testing/selftests/net/tcp_ao/lib/setup.c @@ -142,6 +142,13 @@ int switch_save_ns(int new_ns) return ret; } +void switch_close_ns(int fd) +{ + if (setns(fd, CLONE_NEWNET)) + test_error("setns()"); + close(fd); +} + static int nsfd_outside = -1; static int nsfd_parent = -1; static int nsfd_child = -1; @@ -296,7 +303,7 @@ static bool is_optmem_namespaced(void) int old_ns = switch_save_ns(nsfd_child); optmem_ns = !access(optmem_file, F_OK); - switch_ns(old_ns); + switch_close_ns(old_ns); } return !!optmem_ns; } @@ -317,7 +324,7 @@ size_t test_get_optmem(void) test_error("can't read from %s", optmem_file); fclose(foptmem); if (!is_optmem_namespaced()) - switch_ns(old_ns); + switch_close_ns(old_ns); return ret; } @@ -339,7 +346,7 @@ static void __test_set_optmem(size_t new, size_t *old) test_error("can't write %zu to %s", new, optmem_file); fclose(foptmem); if (!is_optmem_namespaced()) - switch_ns(old_ns); + switch_close_ns(old_ns); } static void test_revert_optmem(void) -- 2.43.0