smb/client: print "Unknown" instead of bogus link speed value
authorEnzo Matsumiya <ematsumiya@suse.de>
Fri, 9 Jun 2023 21:29:59 +0000 (18:29 -0300)
committerSteve French <stfrench@microsoft.com>
Mon, 12 Jun 2023 01:52:49 +0000 (20:52 -0500)
commit50e63d6db6fd30a6dd9a33c49aa5b0bba36e1a92
treeb31d540518bf8a0fbbd05d7335fc24fe028239c4
parent2a44b389664c193dc06cb37d9663d3c5a2a2b743
smb/client: print "Unknown" instead of bogus link speed value

The virtio driver for Linux guests will not set a link speed to its
paravirtualized NICs.  This will be seen as -1 in the ethernet layer, and
when some servers (e.g. samba) fetches it, it's converted to an unsigned
value (and multiplied by 1000 * 1000), so in client side we end up with:

1)      Speed: 4294967295000000 bps

in DebugData.

This patch introduces a helper that returns a speed string (in Mbps or
Gbps) if interface speed is valid (>= SPEED_10 and <= SPEED_800000), or
"Unknown" otherwise.

The reason to not change the value in iface->speed is because we don't
know the real speed of the HW backing the server NIC, so let's keep
considering these as the fastest NICs available.

Also print "Capabilities: None" when the interface doesn't support any.

Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifs_debug.c