🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19077

Re: [PATCH net v2 5/5] selftests: drv-net: stats: query timestamping stats while down

#19077
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 09:54
87 lines
10998 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In check_down_ts_stats()
  (tools/testing/selftests/drivers/net/stats.py), if a counter present…

--

selftests: drv-net: stats: query timestamping stats while down

This patch adds check_down_ts_stats() to the drv-net stats selftest. The
test reads timestamping stats over ethtool netlink before and after taking
the link down. It then checks that no counter went backwards.

> diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py
> index b08e4d48b15ce..e61db30b51817 100755
> --- a/tools/testing/selftests/drivers/net/stats.py
> +++ b/tools/testing/selftests/drivers/net/stats.py
> @@ -220,6 +220,28 @@ def check_down(cfg) -> None:

[ ... ]

> +    ip(f"link set dev {cfg.dev['ifname']} down")
> +    defer(ip, f"link set dev {cfg.dev['ifname']} up")
> +
> +    stats2 = ethnl.tsinfo_get(req).get("stats", {})
> +    for k in stats:
> +        ksft_ge(stats2[k], stats[k], comment=f"{k} went backwards on device down")

[Severity: Low]
What happens here if a counter that was reported while the link was up is
missing from the reply after ifdown?

The kernel only puts counters in the reply when the driver filled them in.
tsinfo_prepare_data() resets every counter on each query:

net/ethtool/tsinfo.c:tsinfo_prepare_data() {
    ...
	ethtool_stats_init((u64 *)&data->stats,
				   sizeof(data->stats) / sizeof(u64));
    ...
}

Then tsinfo_put_stat() skips any counter that is still unset:

net/ethtool/tsinfo.c:tsinfo_put_stat() {
	if (val == ETHTOOL_STAT_NOT_SET)
		return 0;
    ...
}

So the second reply can contain fewer keys than the first. When that
happens, stats2[k] raises KeyError before ksft_ge() runs.

This already happens with wangxun ngbe/txgbe. On ifdown, ngbe_close() and
txgbe_close() call wx_ptp_stop(), which does:

	if (wx->ptp_clock) {
		ptp_clock_unregister(wx->ptp_clock);
		wx->ptp_clock = NULL;
		...
	}

After that, wx_get_ptp_stats() fills nothing while the link is down:

	if (wx->ptp_clock) {
		ts_stats->pkts = wx->tx_hwtstamp_pkts;
		...
	}

ksft_run() catches the KeyError and still marks the test as failed. The
output is a Python traceback, though, and not the "went backwards on device
down" message.

Would it be better to check that the key is present first, for example
with ksft_in(k, stats2, ...), before calling ksft_ge()?

Also, when ETHTOOL_FLAG_STATS is set, tsinfo_fill_reply()->tsinfo_put_stats()
always adds the stats nest to the reply. The {} default in
.get("stats", {}) therefore never takes effect, and it can be dropped.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117215416.1901246-1-dimitri.daskalakis1%40gmail.com
Technical Details
Message-ID: <179508206338.3136.8445234401487583362@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366915-linux-kernel-netdev=dewy.ru
References: <20261117215416.1901246-6-dimitri.daskalakis1@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366915-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 5/5] selftests: drv-net: stats: query timestamping
 stats while down
Date: Thu, 19 Nov 2026 09:54:23 +0000
Organization: Usenet Network
Message-ID: <179508206338.3136.8445234401487583362@kernel.org>
References: <20261117215416.1901246-6-dimitri.daskalakis1@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2842241"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+L2z805n425xksAjVB1iPOnhGoE= sha256:28kQWYArC+gT0DIH/Jd64JbXe5uVLWWHPEjZvGSfB+w=
	sha1:xMQlwYdZf4eRdm8gGjQrQSnC4IE= sha256:LsQji+J3bekqVygnfouKcWrhpX0IxpDZhtAtEoKiKMA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1BB961155A8; Thu, 19 Nov 2026 12:54:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id P5XQnj3FcTR8;
	Thu, 19 Nov 2026 12:54:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-366915-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 0837C1155A5; Thu, 19 Nov 2026 12:54:32 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id C3D7565423; Thu, 19 Nov 2026 09:54:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795082066;
	b=fEX2z78Oscyeco6yS5gIRE3ilE++B/QhGIEHmyHakBp7JkC4gCqP4VOjlRguVwRelziR
	 7axkdEJbwBWcf4bg+hr0rviR3GJyLnSU/h69wDlelpZbk6d74spYuBsfo2mXgK7vf9V2c
	 Gxb37VnQARIAUlSitT0/uvMeAkys9SxqzWTnVImVYLig4lhoW97ELr8+3IgsNP61R5bW0
	 3vfzVkpghgh1PO6Ua95XUMA54f1q0/Xc8ve0TNf+xIChGb7Mjdg3QoOA5o1vxeqazEDfI
	 VtdGMB2DqBYn5FEC/S84GRwkX4vSf4D0QTUxxl4vpTc2xmP11gvEjqDn4dwMCAY26/Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795082066;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=iaaigDaoiSglzrhEIeaHh66YbhLhyJ2puYJ5HUmv1e0=;
	b=ggQsk4aWuLR7IkWK8vsQmiT/fDibmIUC13B02l59UtIPV+zIIxTVxWdnhmR0xuVbOTPe
	 yQRZSsqAw65xhqQkXfppM3wfHpfI/SZjrwfyf8XDCfHNKVsAjrtctq4+0AK70PY9Uah93
	 6vCjV1U9XydIstzijSOEyF90rGfzeLgZbbn3VyL9Z60Z12Fs6fFT/yzk0mDUZnIgaOltS
	 TqvjgOoVAdbxCjVsz+t7i+sVBmzC6BA5Skucogw9+UW6m8AHl63pM3MSWD2eCGOglr/mK
	 dHi9p1hqY+YN+U8b765WWNodpRfKSAmci8Cei8y5ZInpxnT1LtkhY+T1dK4AmOWDU4A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oEOnirph;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id EB565606A32A;
	Thu, 19 Nov 2026 09:54:25 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oEOnirph
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795082065;
	b=jc8owevNnu8a6WZUczLt1J3ytmDotdkbTXeeRD4IVMTxotnpXtfP1JdaxEq7n+JkY7Pj
	 yE6vh+Zqhox87pyNAG3fz0cHqESY/VkI72kDoxsJLrPFO+UBPbkkmsNgucmQeLD4/T6xU
	 hCLqcuVbyvhsVWjUI7dHQVV8Zpm9KZmORICly8ttZRUk8DGC+1IWyxkXtFhEaKUTBsy95
	 24TsjLhwxzfBXQwMhbR/qSY7jwDwhdCygG2LPwgPyDlNix1gY/8vqx0I0foxutS4VQaV3
	 oW5QttCs1vS8AT/XV/R1lSw4orvLGp+gMIIb0Fw8dyhTg+pgR0R1i3bArcrsBwQWMeQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795082065;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=iaaigDaoiSglzrhEIeaHh66YbhLhyJ2puYJ5HUmv1e0=;
	b=aIgMPhw8M+lVEFXGDsaxycjvsiPDaOR9U9NMlfx55dKv08ROSb6mKtr/RjXEwJkm4/eO
	 jA4vuwdD8AZn1T2sX7KQoHs9KLGDzXhKBQcLcSKsu3jEMUi1zNsEm+4yl2VSCUcRcBrZs
	 rr8S3S6gy9f3xLsDyblOy2na4NGlrP/BOL4OnknlrP2LgQo/JzjGJvOtLv0rVfaDUvOjD
	 c0RQjfSy4gCLkVeBKO2kvgR+1kigt5w+1vMoZ0XlPYLpeEchFO3GJS7t4vQSgWGBakt5G
	 /tnX3ExWTEEELccXKbiBD0/pyU2hw2W5ZCzuLquN0L6jfCGkxwfD4CnHt7h0piIf39g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oEOnirph;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1500C606A334;
	Thu, 19 Nov 2026 09:54:24 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C33711F000C4;
	Thu, 19 Nov 2026 09:54:23 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795082064;
	bh=iaaigDaoiSglzrhEIeaHh66YbhLhyJ2puYJ5HUmv1e0=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=oEOnirphtLD2ym8ndUD5y9NGkptBl4tKNArxdXKspI1a9DtmYp58Mra290JLMoIKn
	 7DNXNG9lsiZXTGUbc8OJpmErXaF8hKn04pQ9qT238U9NovGVPWmuETVwd+fI3TSdyP
	 9yk/3S1iSb5LdvG0DldDusuKJOtWE/nF8YYJ5YbiPKj3NojngtjNVHOmkK2gh3xE6h
	 cxisi27LS8Z7cFPkV8Gs7brSdQQkNeGDFNeLFj4rG74tO2MSTdk6MyLJgDv6p0ULX/
	 gshqrTF6JW9oh0E+Wd6fyWBzU9nB+QWtExxCoUXoJGP4VOvXZDLytb9p2oqH+a89+u
	 KII5WurvwVwhg==
X-Cc: davem@davemloft.net, alexanderduyck@fb.com, kuba@kernel.org,
 kernel-team@meta.com, andrew+netdev@lunn.ch, edumazet@kernel.org,
 pabeni@redhat.com, shuah@kernel.org, hmohsin@meta.com,
 mike.marciniszyn@gmail.com, sdf@fomichev.me, bobbyeshleman@meta.com,
 bjorn@kernel.org, leitao@debian.org, horms@kernel.org, almasrymina@google.com,
 vadim.fedorenko@linux.dev, daskald@meta.com, netdev@vger.kernel.org,
 linux-kselftest@vger.kernel.org
X-In-Reply-To: <20261117215416.1901246-6-dimitri.daskalakis1@gmail.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list