From: Ido Schimmel <ido...@nvidia.com>

This patch set teaches ethtool to set the 'ETHTOOL_FLAG_LEGACY' flag in
the ethtool netlink request header of the various commands mapped to
'ethtool set' in order to improve compatibility with the legacy ioctl
interface.

The current use case is to ensure that the kernel will advertise all the
supported link modes when autoneg is enabled, but without specifying
other parameters.

To prevent the kernel from complaining about unknown flags, the flag is
only set in the request header in case the kernel supports it. This is
achieved by using the recently introduced per-operation policy dump
infrastructure.

Example #1 - ethtool and kernel are both aware of the flag
==========================================================

# ethtool -s eth0 advertise 0xC autoneg on
# ethtool -s eth0 autoneg on
# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: 1000Mb/s
        Duplex: Full
        Auto-negotiation: on
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        MDI-X: on (auto)
        Supports Wake-on: umbg
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes

Example #2 - only ethtool is aware of the flag
==============================================

# ethtool -s eth0 advertise 0xC autoneg on
# ethtool -s eth0 autoneg on
# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  100baseT/Half 100baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: 1000Mb/s
        Duplex: Full
        Auto-negotiation: on
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        MDI-X: off (auto)
        Supports Wake-on: umbg
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes

In example #2 the kernel does not advertise all the supported link
modes, but it does not complain about unknown flags either, thus
preventing breakage with old kernels.

Ido Schimmel (2):
  update UAPI header copies
  netlink: Set 'ETHTOOL_FLAG_LEGACY' for compatibility with legacy ioctl
    interface

 netlink/netlink.c            | 13 +++++++++++++
 netlink/netlink.h            |  2 ++
 netlink/parser.c             |  5 ++++-
 uapi/linux/ethtool_netlink.h |  5 ++++-
 4 files changed, 23 insertions(+), 2 deletions(-)

-- 
2.26.2

Reply via email to