Bug 2145035 - speed calculation is wrong for high speed network interface
Summary: speed calculation is wrong for high speed network interface
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: nicstat
Version: rawhide
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Tomasz Torcz
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-11-23 01:14 UTC by Honggang Li
Modified: 2026-06-12 00:58 UTC (History)
1 user (show)

Fixed In Version: nicstat-1.95-28.fc45 nicstat-1.95-28.fc44
Clone Of:
Environment:
Last Closed: 2026-05-27 13:11:31 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Fix speed calculation for high speed network interface (1.10 KB, application/mbox)
2022-11-23 01:14 UTC, Honggang Li
no flags Details

Description Honggang Li 2022-11-23 01:14:45 UTC
Created attachment 1926539 [details]
Fix speed calculation for high speed network interface

Description of problem:

For 10Gb/s network interface, `get_speed_duplex` returns wrong speed
because of overflow.
    
Things get worse for 200Gb/s interface, as `ethtool_cmd.speed_hi`
field was ignored.

Version-Release number of selected component (if applicable):


How reproducible:
100%

Steps to Reproduce:
1.run nicstat to monitor network read and write usage of 10Gb or 200Gb interface
2.
3.

Actual results:
Wrong rUtil and wUtil are reported because of wrong speed returned by function `get_speed_duplex`.

Expected results:


Additional info:
Patch for this issue.
```
diff --git a/nicstat.c b/nicstat.c
index 83ad557..2b52c39 100644
--- a/nicstat.c
+++ b/nicstat.c
@@ -1587,6 +1587,7 @@ get_speed_duplex(nicdata_t *nicp)
 	struct ifreq ifr;
 	struct ethtool_cmd edata;
 	int status;
+	unsigned long long speed;
 
 	if (nicp->flags & NIC_NO_GSET) {
 		if (nicp->speed > 0)
@@ -1609,7 +1610,8 @@ get_speed_duplex(nicdata_t *nicp)
 		get_speed_duplex(nicp);
 		return;
 	}
-	nicp->speed = edata.speed * 1000000;
+	speed = (((unsigned)edata.speed_hi) << 16) + edata.speed;
+	nicp->speed = speed * 1000000;
 	nicp->duplex = edata.duplex;
 }
```

Comment 1 Ben Cotton 2023-04-25 18:25:39 UTC
This message is a reminder that Fedora Linux 36 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 36 on 2023-05-16.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '36'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 36 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 2 Fedora Release Engineering 2023-08-16 07:06:14 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.

Comment 3 Aoife Moloney 2024-11-08 10:45:12 UTC
This message is a reminder that Fedora Linux 39 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 39 on 2024-11-26.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '39'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 39 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 4 Aoife Moloney 2025-02-26 12:52:53 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 42 development cycle.
Changing version to 42.

Comment 5 Fedora Release Engineering 2026-05-06 11:27:38 UTC
This message is a reminder that Fedora Linux 42 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 42 on 2026-05-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '42'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version. Note that the version field may be hidden.
Click the "Show advanced fields" button if you do not see it.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 42 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 6 Fedora Update System 2026-05-27 13:08:55 UTC
FEDORA-2026-0ca6e85ae6 (nicstat-1.95-28.fc45) has been submitted as an update to Fedora 45.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-0ca6e85ae6

Comment 7 Fedora Update System 2026-05-27 13:11:31 UTC
FEDORA-2026-0ca6e85ae6 (nicstat-1.95-28.fc45) has been pushed to the Fedora 45 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 8 Fedora Update System 2026-06-03 08:14:33 UTC
FEDORA-2026-663cf5fbc6 (nicstat-1.95-28.fc44) has been submitted as an update to Fedora 44.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-663cf5fbc6

Comment 9 Fedora Update System 2026-06-04 01:52:59 UTC
FEDORA-2026-663cf5fbc6 has been pushed to the Fedora 44 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2026-663cf5fbc6`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2026-663cf5fbc6

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2026-06-12 00:58:58 UTC
FEDORA-2026-663cf5fbc6 (nicstat-1.95-28.fc44) has been pushed to the Fedora 44 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.