Bug 2145035

Summary: speed calculation is wrong for high speed network interface
Product: [Fedora] Fedora Reporter: Honggang Li <honggangli>
Component: nicstatAssignee: Tomasz Torcz <tomek>
Status: ASSIGNED --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 39CC: tomek
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Fix speed calculation for high speed network interface none

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.