Menu

#1387 Change SIOCETHTOOL ioctl to use ETHTOOL_GLINKSETTINGS instead of obsolete ETHTOOL_GSET

backport-needed
closed
nobody
None
5
2019-06-06
2019-02-12
No

Change SIOCETHTOOL ioctl to use ETHTOOL_GLINKSETTINGS instead of obsolete ETHTOOL_GSET.
Changes needed to avoid kernel warnings: "warning: 'snmpd' uses legacy ethtool link settings API, link modes are only partially reported"
Version: 5.8
Tested on Linux, kernel 4.12.29 x86_64

1 Attachments

Discussion

  • Bart Van Assche

    Bart Van Assche - 2019-04-15

    A modified version of this patch has been applied on the v5.8 and master branches. Please retest.

     
  • Bart Van Assche

    Bart Van Assche - 2019-04-15
    • status: open --> closed
     
  • Sam Tannous

    Sam Tannous - 2019-06-05

    These patches in V5-8-patches break the ifSpeed and ifHighSpeed functionality:

    09da7e2 Fix CentOS6 compile witch does not define ETHTOOL_GLINKSETTINGS
    ec9f614 CHANGES: snmpd: Use ETHTOOL_GLINKSETTINGS when available

    I compiled latest patches from this branch and tested on a recently upgraded Debian Buster
    VM server:

    Latest code:

    root@buster1:/home/stannous# ./sbin/snmpd -v
    
    NET-SNMP version:  5.8
    Web:               http://www.net-snmp.org/
    Email:             net-snmp-coders@lists.sourceforge.net
    
    root@buster1:/home/stannous# /sbin/ethtool enp0s3
    Settings for enp0s3:
        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
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: off (auto)
        Supports Wake-on: umbg
        Wake-on: d
        Current message level: 0x00000007 (7)
                       drv probe link
        Link detected: yes
    root@buster1:/home/stannous# 
    root@buster1:/home/stannous# 
    root@buster1:/home/stannous# which snmpwalk
    root@buster1:/home/stannous# snmpwalk -v2c -cpublic localhost 1 | grep Speed
    IF-MIB::ifSpeed.1 = Gauge32: 10000000
    IF-MIB::ifSpeed.2 = Gauge32: 0
    HOST-RESOURCES-MIB::hrSWRunParameters.20433 = STRING: "Speed"
    IF-MIB::ifHighSpeed.1 = Gauge32: 10
    IF-MIB::ifHighSpeed.2 = Gauge32: 0
    

    Where previously, using the default (5.7.3) snmpd, I had these results:

    root@buster1:/home/stannous# which snmpd 
    root@buster1:/home/stannous# /usr/sbin/snmpd -v
    
    NET-SNMP version:  5.7.3
    Web:               http://www.net-snmp.org/
    Email:             net-snmp-coders@lists.sourceforge.net
    
    root@buster1:/home/stannous# 
    root@buster1:/home/stannous# snmpwalk -v2c -cpublic localhost 1 | grep Speed
    IF-MIB::ifSpeed.1 = Gauge32: 10000000
    IF-MIB::ifSpeed.2 = Gauge32: 1000000000
    HOST-RESOURCES-MIB::hrSWRunParameters.20448 = STRING: "Speed"
    IF-MIB::ifHighSpeed.1 = Gauge32: 10
    IF-MIB::ifHighSpeed.2 = Gauge32: 1000
    root@buster1:/home/stannous# 
    

    Can you please either fix the ETHTOOL_GLINKSETTINGS patch or just revert it?
    I looked at the code briefly but couldn't see why it was failing. It seems that the
    ioctl call with ETHTOOL_GLINKSETTINGS returns 0 (in my small sample code) but
    doesn't retrieve the actual speed (it's 0) so that the ETHTOOL_GSET call is never made.

    Thanks,
    Sam

     
  • Sam Tannous

    Sam Tannous - 2019-06-05

    When looking over the ethtool code, it appears that multiple ioctl calls may be required.
    Why, I do not know.....This small patch works:

    --Regards,
    Sam

     
    • Bart Van Assche

      Bart Van Assche - 2019-06-06

      I think that patch could cause a stack overflow so I have checked in a slightly different patch. Please retest.

       
      • Sam Tannous

        Sam Tannous - 2019-06-06

        That works fine. And no stack smashing. Thanks, Bart.

        --Sam

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.