Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp307376rbb; Sat, 24 Feb 2024 01:07:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVRo9EiqzBt4YIneAt0F029yVFVjGydG1K3pOrVHFq737BL8Ue8lERqV9vRoG81Sx8XW7ekOBy+Lv91DDxiF6EKVKXMzZD8NDk8upCmZQ== X-Google-Smtp-Source: AGHT+IGLQwrsU9fKU422yXGcj5Mxy+kNsnWS9tuo+uOt4kfkBe8ebmgUsdN1WUQimY0cmCnCbVP+ X-Received: by 2002:a05:6a20:c792:b0:1a0:de6e:ccf0 with SMTP id hk18-20020a056a20c79200b001a0de6eccf0mr1781711pzb.34.1708765660288; Sat, 24 Feb 2024 01:07:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708765660; cv=pass; d=google.com; s=arc-20160816; b=C5jzcHUEw6atU3wLxzEg7DQM1Tz8a+7XTXvS+1KYzQmuPgQucSE0A7+52zCXZe3vIl 1OVipNmAlxVnxZVqE4SlvjIDLOC01B4kcfvMyDBbldT5utBIA2LCnRN82/fF4IkIDbz7 ZsfgeiypUdyuig/T0LxR8m06C9BnmHpJJn9+TkFB3nPQdDb8IsiXTT/g4/3u/GOeAHvI +mPaRCkskjlbGHW/6PPp08GtLx0r6QANQi+48KTZoO4bp03kO5918OnMqBGFlOp6MWvC 6+FcrG+v58aHtlcVtRV46cq2sUFoJB5ofMABlsMR5NpJxueo1thd8smL+b5URsLQBDcA 6m3A== 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=rRIDgmvdBuy4FEMojsFBGRvXRNCtma2xryE9RPsDnfQ=; fh=IxiJlu319nx4ipPNT7mFLBLZOjs5NHo4hKw4FNA9KPM=; b=UhjrHS7IaddJyex3cdI/mbJwslfajNfMloQHDGb80feUctCtEtrQ/yObEJ7DZz6jS2 QM973vOrDwLewAA4vflO7ymqkERncMDKaC+tS+s/K8d1N4KDlXjyZQzVOlfmHGn0FIOa cJRRrXGQZ1fUq9VlmM7SIJTDr7urBWD3NSZwwFyqlmuAL6IPFf0U7X1tT1tpmMC4JLuW a5Eny4Lro013d0FdVvSZKvKsHvix9SaLVcUqipnTuyFypryPUfARc6L6AyrgGrVKOAAk KpVpqns8egUIIn37N5nQmhWQkSu6O7XMvYWETAL+h0wBYsZXI8UjpFiwv2N9GPbrbNWd mcjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=A9oEuHl6; 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-79528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id qn15-20020a17090b3d4f00b002997c936f30si676222pjb.113.2024.02.24.01.07.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 01:07:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=A9oEuHl6; 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-79528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79528-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3F459B22FCA for ; Sat, 24 Feb 2024 09:07:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0507442074; Sat, 24 Feb 2024 09:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b="A9oEuHl6" Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 D0DF43C490 for ; Sat, 24 Feb 2024 09:04:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708765498; cv=none; b=GeOV3GH8eESJYsyNoQU/jXs/XZaYCiVj82zi3Yiki9VdRVSHKUM6RFrMV0WrWfsjGudz1cVjYu0yT7qZoizpiOlEVV/rLPaA+4rLynEYOwX6G7HvWw5DEi64XfK8OjKbuX/D+gdLn0xkAW+Nz1mKJE9UihwVL3354FV9aVghPSU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708765498; c=relaxed/simple; bh=4jErwg55G7DEzjwCRCrWJtVME975m5guzjG380jeS9k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JxAiknRUd8Cw+u3M44qBfKZP6v3hUFeH7kaukI4T8Q2YblW8QEvSb10SgiN4jJEYXX2WRpnUp31EnsNke5eqXcj4UftXmkGUDPWbOxfbFMgIkJSUeve8nCMg9wB8eHUKNo+LDu9qWN6MhsvScdpBO89TKeqV2V1yQAb4Zbb99sg= 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=A9oEuHl6; arc=none smtp.client-ip=209.85.128.52 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-f52.google.com with SMTP id 5b1f17b1804b1-4129e8bc6c8so936555e9.2 for ; Sat, 24 Feb 2024 01:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1708765495; x=1709370295; 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=rRIDgmvdBuy4FEMojsFBGRvXRNCtma2xryE9RPsDnfQ=; b=A9oEuHl6sjxlDeml6V8i/R62ztS4OWgUMKsJepuxR51nisyApnBYf9G+8kVEGU2pOf azqCend3/dTMws3379Zkgt7K7Ww0akbyABF5XffOUo0S1vxgC69JTSEaDqormuRexh5e XD3azSuERnJoLlWKygy3aVWyDxpFvlLHzEnAK1H9UoUmtXa6P1oKXwESPpWD5JiikbMQ GPMpjCtTNoVzmkNDfNwNv/gPvaq+mXhs92AI1cIoXqU745hLpqi1vdzagH6D5QkO3dcJ cnTpa5IqoytEWpJnUGoEhiU5UoHMBIWCQBW/QLQtqMGG7MhpHaOTIimtK4d3n4mOYzOc qLag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708765495; x=1709370295; 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=rRIDgmvdBuy4FEMojsFBGRvXRNCtma2xryE9RPsDnfQ=; b=bHTU5YOPV/jxHeBPFW8fEy+8VG5LuA5SbHAW8Hs8X9F0bwgBzJev7XYVGJyIs8u3i/ /w9iZPpTPZl3MLBN6nOIg7vPsAIUIAuvHYUP9L2Xk2Ep1zIqbdIvldNgMKStYj46C0y1 SqSVAtxZo4YY7QkvAE/FbejG+BPnw9CD6egtYvWFV7IinX4PeJH3SAj8xmybQFH2694y UtSprchtZZwulH2rZoLq+nDiKXpcKlLomWvB+w/dFjXh4hXCQ3E1mjD+vWCkxH+6ReUa 6vlpyntY2A0GT+54uyksKP1WZ+UEX/ybRYs56LFm9jw6TNS4rqDbh5uxg7chN/HJAsec 4W3Q== X-Forwarded-Encrypted: i=1; AJvYcCVrsoWJbJi4fW0Y2Fk6MdtFvOgR2LsnsQwK11AVaNdGGXjvUO7a3ia8BvLQgL3oyl7Bp+bJFjK18wXp7on9bhJckWNLTQmk2ypekjft X-Gm-Message-State: AOJu0YzaQP8yAxKj9kFwM/IOtsQcBJZcx1tkEiSn6Esxydqm3RPxzEYB NrGh82inYJU2DiCoQvF0yWRSoNrNBYBatHPkozRUk7eNCq/FscWEfC/yu5h6ehmvHIx1mBRzE/0 = X-Received: by 2002:a05:600c:2e04:b0:410:a039:ed5d with SMTP id o4-20020a05600c2e0400b00410a039ed5dmr1673611wmf.33.1708765495316; Sat, 24 Feb 2024 01:04:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 01:04:54 -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 08/10] selftests/net: Be consistnat in kconfig checks Date: Sat, 24 Feb 2024 09:04:16 +0000 Message-ID: <20240224-tcp-ao-tracepoints-v1-8-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=2695; i=dima@arista.com; s=20231212; h=from:subject:message-id; bh=4jErwg55G7DEzjwCRCrWJtVME975m5guzjG380jeS9k=; b=afMpsCOt6xNpXARvG8bjI9wO61Dv76Tvjx05gMcpY6lZY365igt8bIUOsSzqko7QzMKAYLvny 2rTLQQQC9xyAQ3Viq8xdsZkk+BnMO5EjWEgG53r6fqakvaQFtEiZlQz X-Developer-Key: i=dima@arista.com; a=ed25519; pk=hXINUhX25b0D/zWBKvd6zkvH7W2rcwh/CH6cjEa3OTk= Content-Transfer-Encoding: 8bit Most of the functions in tcp-ao lib/ return negative errno or -1 in case of a failure. That creates inconsistencies in lib/kconfig, which saves what was the error code. As well as the uninitialized kconfig value is -1, which also may be the result of a check. Define KCONFIG_UNKNOWN and save negative return code, rather than libc-style errno. Signed-off-by: Dmitry Safonov --- tools/testing/selftests/net/tcp_ao/lib/kconfig.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/net/tcp_ao/lib/kconfig.c b/tools/testing/selftests/net/tcp_ao/lib/kconfig.c index f279ffc3843b..3bf4a7e4b3c9 100644 --- a/tools/testing/selftests/net/tcp_ao/lib/kconfig.c +++ b/tools/testing/selftests/net/tcp_ao/lib/kconfig.c @@ -6,7 +6,7 @@ #include "aolib.h" struct kconfig_t { - int _errno; /* the returned error if not supported */ + int _error; /* negative errno if not supported */ int (*check_kconfig)(int *error); }; @@ -62,7 +62,7 @@ static int has_tcp_ao(int *err) memcpy(&tmp.addr, &addr, sizeof(addr)); *err = 0; if (setsockopt(sk, IPPROTO_TCP, TCP_AO_ADD_KEY, &tmp, sizeof(tmp)) < 0) { - *err = errno; + *err = -errno; if (errno != ENOPROTOOPT) ret = -errno; } @@ -87,7 +87,7 @@ static int has_tcp_md5(int *err) */ *err = 0; if (test_set_md5(sk, addr_any, 0, -1, DEFAULT_TEST_PASSWORD)) { - *err = errno; + *err = -errno; if (errno != ENOPROTOOPT && errno == ENOMEM) { test_print("setsockopt(TCP_MD5SIG_EXT): %m"); ret = -errno; @@ -116,13 +116,14 @@ static int has_vrfs(int *err) return ret; } +#define KCONFIG_UNKNOWN 1 static pthread_mutex_t kconfig_lock = PTHREAD_MUTEX_INITIALIZER; static struct kconfig_t kconfig[__KCONFIG_LAST__] = { - { -1, has_net_ns }, - { -1, has_veth }, - { -1, has_tcp_ao }, - { -1, has_tcp_md5 }, - { -1, has_vrfs }, + { KCONFIG_UNKNOWN, has_net_ns }, + { KCONFIG_UNKNOWN, has_veth }, + { KCONFIG_UNKNOWN, has_tcp_ao }, + { KCONFIG_UNKNOWN, has_tcp_md5 }, + { KCONFIG_UNKNOWN, has_vrfs }, }; const char *tests_skip_reason[__KCONFIG_LAST__] = { @@ -138,11 +139,11 @@ bool kernel_config_has(enum test_needs_kconfig k) bool ret; pthread_mutex_lock(&kconfig_lock); - if (kconfig[k]._errno == -1) { - if (kconfig[k].check_kconfig(&kconfig[k]._errno)) + if (kconfig[k]._error == KCONFIG_UNKNOWN) { + if (kconfig[k].check_kconfig(&kconfig[k]._error)) test_error("Failed to initialize kconfig %u", k); } - ret = kconfig[k]._errno == 0; + ret = kconfig[k]._error == 0; pthread_mutex_unlock(&kconfig_lock); return ret; } -- 2.43.0