public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Tomasz Torcz <tomek@pipebreaker.pl>
To: git-commits@fedoraproject.org
Subject: [rpms/nicstat] f44: add patch fixing high-speed interfaces reporting
Date: Wed, 03 Jun 2026 08:07:22 GMT [thread overview]
Message-ID: <178047404276.1.11495631908867444085.rpms-nicstat-e69b6ec7ea68@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/nicstat
Branch : f44
Commit : e69b6ec7ea68e8df5e0c2aca074cda034563d3ef
Author : Tomasz Torcz <tomek@pipebreaker.pl>
Date : 2026-06-03T10:06:38+02:00
Stats : +74/-4 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/nicstat/c/e69b6ec7ea68e8df5e0c2aca074cda034563d3ef?branch=f44
Log:
add patch fixing high-speed interfaces reporting
---
diff --git a/nicstat-fix-speed-highspeed.patch b/nicstat-fix-speed-highspeed.patch
new file mode 100644
index 0000000..3d5f417
--- /dev/null
+++ b/nicstat-fix-speed-highspeed.patch
@@ -0,0 +1,65 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tomasz Torcz <ttorcz@fedoraproject.org>
+Date: Tue, 27 May 2026 14:00:00 +0200
+Subject: [PATCH] Fix incorrect utilization on high-speed (10G+) interfaces
+
+get_speed_duplex() reads interface speed via ETHTOOL_GSET ioctl into
+struct ethtool_cmd. The assignment:
+
+ nicp->speed = edata.speed * 1000000;
+
+has two bugs affecting interfaces faster than 1 GbE:
+
+1. Integer overflow: edata.speed is __u16 (Mbps). The multiplication is
+ evaluated as 32-bit signed arithmetic before assignment to the uint64_t
+ nicp->speed. For 10 GbE (edata.speed = 10000):
+
+ 10000 * 1000000 = 10,000,000,000 > INT32_MAX (2,147,483,647)
+
+ The result wraps to 1,410,065,408, making utilization calculations
+ wildly wrong. 1 GbE (1000 * 1000000 = 1,000,000,000) fits within
+ 32 bits and was never affected.
+
+2. Truncated speed on 100G+: The ethtool_cmd.speed field is only 16 bits
+ wide (max 65,535 Mbps). Since Linux 2.6.27 (2009), the kernel stores
+ speeds above 65,535 Mbps split across speed (low 16 bits) and speed_hi
+ (high 16 bits). Reading only edata.speed for a 100 GbE interface
+ (100,000 Mbps) yields 100000 & 0xFFFF = 34,464 Mbps — roughly a third
+ of the true speed — causing utilization to appear ~2.9x higher than
+ actual even without the overflow.
+
+The fix replaces the bare field access with ethtool_cmd_speed(&edata),
+a static inline introduced in Linux 2.6.27 that combines speed and
+speed_hi into a correct __u32, covering interfaces up to ~4 Tbps.
+The explicit (uint64_t) cast ensures the subsequent * 1000000
+multiplication is done in 64-bit arithmetic, eliminating the overflow.
+
+A partial fix casting to (long long) without using ethtool_cmd_speed()
+was applied in the scotte/nicstat community fork:
+https://github.com/scotte/nicstat/commit/3bd58668
+That fix resolves the overflow for 10G/25G/50G but still reads the wrong
+speed for 100G+ because it does not consume speed_hi.
+
+Upstream bug report: https://sourceforge.net/p/nicstat/bugs/1/
+Fedora bug: https://bugzilla.redhat.com/show_bug.cgi?id=2145035
+
+Reported-by: Honggang LI <honggangli@163.com>
+---
+ nicstat.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/nicstat.c b/nicstat.c
+index 0000000..0000001 100644
+--- a/nicstat.c
++++ b/nicstat.c
+@@ -1609,7 +1609,7 @@ get_speed_duplex(nicdata_t *nicp)
+ get_speed_duplex(nicp);
+ return;
+ }
+- nicp->speed = edata.speed * 1000000;
++ nicp->speed = (uint64_t) ethtool_cmd_speed(&edata) * 1000000;
+ nicp->duplex = edata.duplex;
+ }
+ #endif /* OS_LINUX */
+--
+2.49.0
diff --git a/nicstat.spec b/nicstat.spec
index b0927ee..72692d0 100644
--- a/nicstat.spec
+++ b/nicstat.spec
@@ -1,21 +1,23 @@
-Name: nicstat
+Name: nicstat
Version: 1.95
-Release: 27%{?dist}
-Summary: CLI utility that prints out network statistics for all network interface
+Release: 28%{?dist}
+Summary: CLI utility that prints out network statistics for all network interface
License: Artistic-2.0
URL: http://sourceforge.net/projects/%{name}
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
+Patch0: nicstat-fix-speed-highspeed.patch
BuildRequires: gcc
%description
-nicstat is a Solaris and Linux command-line that prints out network statistics
+nicstat is a Solaris and Linux command-line that prints out network statistics
for all network interface cards (NICs), including packets, kilobytes per second,
average packet sizes and more.
%prep
+%autosetup
%setup -qn %{name}-%{version}
@@ -36,6 +38,9 @@ install -p -D -m 0644 %{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1
%changelog
+* Wed May 27 2026 Tomasz Torcz <ttorcz@fedoraproject.org>
+- fix reporting of high-speed interfaces (fixes rhbz#2145035)
+
* Fri Jan 16 2026 Fedora Release Engineering <releng@fedoraproject.org> - 1.95-27
- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild
reply other threads:[~2026-06-03 8:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178047404276.1.11495631908867444085.rpms-nicstat-e69b6ec7ea68@fedoraproject.org \
--to=tomek@pipebreaker.pl \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox