Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ethtool: Set cmd field in ETHTOOL_GLINKSETTINGS response to wrong nwords

When the ETHTOOL_GLINKSETTINGS implementation finds that userland is
using the wrong number of words of link mode bitmaps (or is trying to
find out the right numbers) it sets the cmd field to 0 in the response
structure.

This is inconsistent with the implementation of every other ethtool
command, so let's remove that inconsistency before it gets into a
stable release.

Fixes: 3f1ac7a700d03 ("net: ethtool: add new ETHTOOL_xLINKSETTINGS API")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ben Hutchings and committed by
David S. Miller
793cf87d ad846aa5

+1 -1
+1 -1
net/core/ethtool.c
··· 655 655 != link_ksettings.base.link_mode_masks_nwords) { 656 656 /* wrong link mode nbits requested */ 657 657 memset(&link_ksettings, 0, sizeof(link_ksettings)); 658 - /* keep cmd field reset to 0 */ 658 + link_ksettings.base.cmd = ETHTOOL_GLINKSETTINGS; 659 659 /* send back number of words required as negative val */ 660 660 compiletime_assert(__ETHTOOL_LINK_MODE_MASK_NU32 <= S8_MAX, 661 661 "need too many bits for link modes!");