Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2088457lqb; Mon, 27 May 2024 07:31:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMj+D+bh+WtFDBEq6OrMyx47TozGfLrZoNqhsuueTcIDu3CIgQLDsxhtgLuUqF3kp9K4iAp5EajloDcdQNaiS4BUymVXzlj7YxrD8pfA== X-Google-Smtp-Source: AGHT+IHHpSNUgMdRJ+WaNpKyPRkPYo9NCJpflMqT/TzHpRaH3RPE1Gd8Q27IE25Gp+Z1RgExvxvU X-Received: by 2002:a17:906:339b:b0:a62:28ce:4e98 with SMTP id a640c23a62f3a-a62642e96camr593405666b.23.1716820315334; Mon, 27 May 2024 07:31:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716820315; cv=pass; d=google.com; s=arc-20160816; b=zpaHu+9R8EI21WxVwUEatE6B0guqXNTqZZhvqilW2RgSjh4Cma50cL+yWR+lFf1dVr 2ySUOLkPSs/YJI8z0+YBu1PSpKwNYk1IU1ApaA7dIsX1WTar78bUAJMmAvoiqzcjoB8h 4PrgZ0+TmTbDTZ8AXrdQVR7jrAjONH3dwqH/prRnem7ibySvO3zHn3YgiNbnF0C42m7g nV7wpkYrGYcMxT7cZFRZ7UlLZYV+pLAu1oUVsfO9Y6E3OvJM6q4zORPkrTDuaJ1m7eNS hMB/ntC2YdDpT2cuTmjBwvAEpy9soMJdOX1/4/QJrKy9cB6BgaS8WnSVdpYTZXVwa18r N1vQ== 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=mceZk5+BHEnApt5MMvgj0EwbzgClJghI2+4hMz8wEyU=; fh=gdi3/V36dy5sDS3+pYuDOpoGAuXRvgmJXdDk/EX0ySM=; b=XHWW1ShT+pm1JesqDclvZQS2tCSgzr54nm3kDSIj48RzRAWxq/bOSvF1RQs/9N3SPF Rjpsr72hzb2yYn3tTPL49HR1qOC4VmjbRRbCswrr/F56DvH4+112m9ZH1Lro+eAEKryJ x32SEmLdksdmsIVoscM+AgMReUlpUcyv1Pd7uIe3UI7iHB81LyeD0+VHj2VxtR/9wXJT 9uW2sulpWTrdVsAg+UGk0VMhG5abSHzmdCcoCHQKzfNRw54Jwgm5sLUQoGh9K+aNaoi3 X8lEyGMBe+/6GrwujV0O3Hya6vXE94KyiWS/13ygQPHQwXxVIOzMyijH2JYhQqM/h8K/ RvJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FJTpAyUl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190872-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190872-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626c800ff4si382994966b.107.2024.05.27.07.31.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190872-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FJTpAyUl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190872-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190872-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 1DA931F22056 for ; Mon, 27 May 2024 14:31:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63C44181D1D; Mon, 27 May 2024 14:15:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FJTpAyUl" 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 8315C181D06; Mon, 27 May 2024 14:15:30 +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=1716819330; cv=none; b=JJpYFuHdYFIhGQyaxO2svEMcdpJ29D3sYFdU3uqWe8N9tJxulrGnbmmLT4L+ZEL0fpnTHx7nxMxyk9irl1df6gWJYCZGQE+TUIkkZ/4/ATzk75u7/kfulMzrPdWfRYXYFvruA5y7zLk0B75oJdi4vzoiHzW34NEKdL6LEbnLQ+0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819330; c=relaxed/simple; bh=s+lIrPPcCGvUZL3PbI5a5ZKTRpmk/nMe5exqy1s372s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o3IlJzS9QtMWBpBcGWWim6Iz+4qdNOsruexyGcR7n1fYcCDLKBKNE6lJEbTJ46obd44xX2Y8o+o0pMas8+3wO9sOPMIr6J5zHeOvFVXxKF5LhTx5j7Id/RsEeDBVG6GOO0M7FlkRHgxJj33Pedq7dhUAirw4rI1xTsuxHhI3Hzg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FJTpAyUl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E595CC4AF07; Mon, 27 May 2024 14:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716819330; bh=s+lIrPPcCGvUZL3PbI5a5ZKTRpmk/nMe5exqy1s372s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FJTpAyUlmTcOPgbv1Iom/IegijQaR5HVZ+AbGJ8bNP7MO29GhlKvTBgcIdAx17N4o RcTnRaZ7lj5M/Cv99jze9spVWDMdGmXhZEMXtvJUUMsqhllTRl2xStgywWBobFghDR c36k1nCMd7xn9TUD3fukt5ULLUz+jgVpwOSO3GyyczE59tdsXr3aCsCY5zdUB0GVpy 5dJnD/vvvp/rFMXuv+8ibHbgPYNaGB8EJHFz3nqOwSgzAwH1v+P0OztutvfRioTGta 2Wp/i5nVNSllOQu3K3KQUo4705Udignf0M6EwRBbQ+wHoq6vnRAz7eCs9mMuv8UMh4 iPa6fzlvjZRUA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jakub Kicinski , Willem de Bruijn , Sasha Levin , davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, shuah@kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH AUTOSEL 6.8 29/30] selftests: net: fix timestamp not arriving in cmsg_time.sh Date: Mon, 27 May 2024 10:13:38 -0400 Message-ID: <20240527141406.3852821-29-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527141406.3852821-1-sashal@kernel.org> References: <20240527141406.3852821-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.8.11 Content-Transfer-Encoding: 8bit From: Jakub Kicinski [ Upstream commit 2d3b8dfd82d76b1295167c6453d683ab99e50794 ] On slow machines the SND timestamp sometimes doesn't arrive before we quit. The test only waits as long as the packet delay, so it's easy for a race condition to happen. Double the wait but do a bit of polling, once the SND timestamp arrives there's no point to wait any longer. This fixes the "TXTIME abs" failures on debug kernels, like: Case ICMPv4 - TXTIME abs returned '', expected 'OK' Reviewed-by: Willem de Bruijn Link: https://lore.kernel.org/r/20240510005705.43069-1-kuba@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- tools/testing/selftests/net/cmsg_sender.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/net/cmsg_sender.c b/tools/testing/selftests/net/cmsg_sender.c index c79e65581dc37..161db24e3c409 100644 --- a/tools/testing/selftests/net/cmsg_sender.c +++ b/tools/testing/selftests/net/cmsg_sender.c @@ -333,16 +333,17 @@ static const char *cs_ts_info2str(unsigned int info) return "unknown"; } -static void +static unsigned long cs_read_cmsg(int fd, struct msghdr *msg, char *cbuf, size_t cbuf_sz) { struct sock_extended_err *see; struct scm_timestamping *ts; + unsigned long ts_seen = 0; struct cmsghdr *cmsg; int i, err; if (!opt.ts.ena) - return; + return 0; msg->msg_control = cbuf; msg->msg_controllen = cbuf_sz; @@ -396,8 +397,11 @@ cs_read_cmsg(int fd, struct msghdr *msg, char *cbuf, size_t cbuf_sz) printf(" %5s ts%d %lluus\n", cs_ts_info2str(see->ee_info), i, rel_time); + ts_seen |= 1 << see->ee_info; } } + + return ts_seen; } static void ca_set_sockopts(int fd) @@ -509,10 +513,16 @@ int main(int argc, char *argv[]) err = ERN_SUCCESS; if (opt.ts.ena) { - /* Make sure all timestamps have time to loop back */ - usleep(opt.txtime.delay); + unsigned long seen; + int i; - cs_read_cmsg(fd, &msg, cbuf, sizeof(cbuf)); + /* Make sure all timestamps have time to loop back */ + for (i = 0; i < 40; i++) { + seen = cs_read_cmsg(fd, &msg, cbuf, sizeof(cbuf)); + if (seen & (1 << SCM_TSTAMP_SND)) + break; + usleep(opt.txtime.delay / 20); + } } err_out: -- 2.43.0