Bug 2145035 - speed calculation is wrong for high speed network interface
Summary: speed calculation is wrong for high speed network interface
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora
Classification: Fedora
Component: nicstat
Version: 39
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: 2023-08-16 07:06 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
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.


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