Bug 2226574

Summary: The ethtool tool displays the truncated intree driver version when use the default kernel version as driver version
Product: Red Hat Enterprise Linux 9 Reporter: xijunli <xijun.li>
Component: ethtoolAssignee: Ivan Vecera <ivecera>
Status: CLOSED WONTFIX QA Contact: Tianhao <tizhao>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 9.2CC: hwkernel-mgr, linville, mschmidt
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-08-17 14:42:44 UTC 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:

Description xijunli 2023-07-26 02:08:04 UTC
Description of problem:
=======================
[root@localhost ~]# modinfo ice | grep -i version
rhelversion:    9.2
srcversion:     D90546B7F98B65CA9BF8044
vermagic:       5.14.0-284.11.1.rt14.296.el9_2.x86_64 SMP preempt_rt mod_unload modversions
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ifconfig | less

[root@localhost ~]# ethtool -i ens1f0
driver: ice
version: 5.14.0-284.11.1.rt14.296.el9_2.
firmware-version: 4.10 0x8001518e 1.3310.0
expansion-rom-version:
bus-info: 0000:9d:00.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: yes
[root@localhost ~]#


Version-Release number of selected component (if applicable):
=============================================================
RHEL 9.2 (5.14.0-284.11.1.rt14.296.el9_2.x86_64)


Steps to Reproduce:
===================
# ethtool -i netname
# check the driver version is not match with kernel version (truncated)


Actual results:
===============
version: 5.14.0-284.11.1.rt14.296.el9_2.

Expected results:
=================
version: 5.14.0-284.11.1.rt14.296.el9_2.x86_64

Comment 1 xijunli 2023-07-26 02:19:44 UTC
This issue may be caused by:
* kernel version definition is 64 bytes 
* driver version definition is 32 bytes
* in ioctl.c:
    * strlcpy(info.version, UTS_RELEASE, sizeof(info.version))  # this line will cutoff when the kernel version length is larger than 31 bytes/chars


As the default version string, it should be correct, not confused to users (in case some driver implementation will use the default kernel version not their own version format for intree driver)

Comment 2 John W. Linville 2023-07-26 13:25:54 UTC
Speaking in a "friend of the kernel" capacity...the width of the version string here is constrained by the pre-existing ethtool API, and the utility of duplicating information that can be obtained with uname is not sufficient to justify a RHEL-specific API extension. It would be better to consider some way to deprecate that feature of ethtool.

Comment 3 xijunli 2023-07-31 01:59:22 UTC
Hi @Ivan Vecera, 

Any comments for this issue from you?

Comment 4 Ivan Vecera 2023-08-01 15:12:43 UTC
As John mentioned... the problem is with ethtool's UAPI:

struct ethtool_drvinfo {
        __u32   cmd;
        char    driver[32];
        char    version[32];
...

Version cannot be longer than 32 chars... and we cannot extend this field as we would break UAPI.

Comment 5 xijunli 2023-08-02 01:49:28 UTC
As this ethtool_drvinfo struct definition is located in kernel source folder, who should be the correct contact for this fix, please help to involve here, thanks

Comment 6 Ivan Vecera 2023-08-04 15:03:53 UTC
(In reply to xijunli from comment #5)
> As this ethtool_drvinfo struct definition is located in kernel source
> folder, who should be the correct contact for this fix, please help to
> involve here, thanks

This cannot be fixed so easily... The existing UAPI has to be preserved. To provide wider string for version a new field has to be added in upstream and update ethtool userspace to handle it...

E.g.
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index f7fba0dc87e545..f1f8a3130a20aa 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -195,6 +195,7 @@ struct ethtool_drvinfo {
        __u32   testinfo_len;
        __u32   eedump_len;
        __u32   regdump_len;
+       char    version_long[64];
 };
 
However I'm not sure if upstream would like to extend this deprecated ioctl API this way.

John, what do you think?

Comment 7 Ivan Vecera 2023-08-04 15:08:08 UTC
Second possibility to read version for the driver:
1. Get driver (module) name
2. Fetch version of the loaded module

E.g.:
[root@cnb-06 ~]# DRV=$(ethtool -i enp2s0f0 | awk '/driver:/{ print $2 }')
[root@cnb-06 ~]# cat /sys/module/${DRV}/version
4.18.0-506.el8.x86_64

Comment 8 John W. Linville 2023-08-04 17:13:13 UTC
Right, it isn't about the technical challenge of changing things. I don't see upstream accepting such a change. The usefulness of driver-specific version information is at best unclear. A better solution would be some mechanism for a driver to publish something like feature or capability flags, and then some sort of standardization around an API to query and use such information. Perhaps something netlink based?

Comment 9 xijunli 2023-08-07 02:47:56 UTC
Yes, totally understand, 
And the original intention of raising this ticket is just to keep RHEL a unified response for all driver versions for customer usage, no confusion for some special cases

As it's not a functionality bug, So either "a longer fix period" or "even set with a known limitation/won't fix" works for me, just need a clear information for this ticket

If won't fix this, let me know, i will close this ticket, thanks

Comment 10 Michal Schmidt 2023-08-17 08:19:33 UTC
$ echo 'whatever the kernel version is' | wc -c
31
$ echo 'same as the kernel version' | wc -c
27
$ echo "same as what 'uname -r' says" | wc -c
29

Why not return one of these fixed strings? ;)


Seriously, unless the truncation can be shown to break some userspace software, I don't think it's worth fixing.

Comment 11 xijunli 2023-08-17 14:35:49 UTC
that's ok, i will close this ticket, and mark it with won't fix, thanks for support :)