Page MenuHomeFreeBSD

Add SIOCGIFDOWNREASON
ClosedPublic

Authored by kib on Sep 4 2019, 8:45 PM.

Details

Summary

The ioctl(2) intended to provide more details about the cause of the down for the link.

Eventually we might define a comprehensive list of codes for the situations. But interface also allows the driver to provide free-form null-terminated ASCII string to provide arbitrary non-formalized information. Sample implementation exists for mlx5(4), where the string is fetched from firmware controlling the port.

Currently, the interface is only utilized by ifconfig(8) to provide the hint to user, if available.

Sample output:

# ifconfig mce0
mce0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=3ed07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWFILTER,VLAN_HWTSO,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6,TXRTLMT,HWRXTSTMP>
        ether e4:1d:2d:e7:10:0a
        media: Ethernet autoselect <full-duplex,rxpause,txpause>
        status: no carrier (Negotiation failure)
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 26280

Event Timeline

kib created this revision.Sep 4 2019, 8:45 PM

What about translation of text messages? Should we use an enum for this? Or provide both?

kib added a comment.Sep 9 2019, 10:54 AM

What about translation of text messages? Should we use an enum for this? Or provide both?

Translations are not planned, the string that comes from kernel typically is provided by hardware (firmware). I added some way to extend the interface in more automation-friendly way in the next revision.

kib updated this revision to Diff 61829.Sep 9 2019, 10:56 AM

Make the IFDOWNREASON interface capable of returning standard numeric reasons, but not define any yet.
Add vendor-specific escape.

hselasky added inline comments.Sep 11 2019, 7:42 AM
sbin/ifconfig/ifmedia.c
193

Should there be some filter or forced zero at on ifdr_msg ?

ifdr_msg[sizeof(ifdr_msg) - 1] = 0 ??

kib added inline comments.Sep 11 2019, 8:07 AM
sbin/ifconfig/ifmedia.c
193

Kernel must zero-terminate the string. Why would utility not trust the kernel ?

hselasky added inline comments.Sep 11 2019, 8:34 AM
sbin/ifconfig/ifmedia.c
193

OK, but what about non-printable characters? Is the kernel responsible to filter this? I don't trust hardware/firmware to provide correct strings :-)

kib added inline comments.Sep 11 2019, 10:07 AM
sbin/ifconfig/ifmedia.c
193

I am not sure, and I think it is premature to do anything about it until there is a driver that does emit something non-printable.

Even then, I think this is a problem of the driver, and not kernel/ifconfig.

kib edited the summary of this revision. (Show Details)Sep 16 2019, 8:07 AM
kib edited the summary of this revision. (Show Details)Sep 16 2019, 8:12 AM
kib edited the summary of this revision. (Show Details)

Sometimes I suffer from being unable to bring the interface to "administratively shutdown" state as opposed to "operative shutdown". It would be nice if ifconfig(8) "down" was able to update status of the interface with "admindown" string or similar, and "up" was able to auto-remove such note.

Such information can be useful for code responsible for recovering procedures trying to reset a driver or synthetic tunnel-like interface to differentiate faulty or disabled interfaces.

I mean, there may be different sources of such information and not only firmware/driver.

rrs accepted this revision.Tue, Sep 17, 12:59 PM
This revision is now accepted and ready to land.Tue, Sep 17, 12:59 PM
hselasky accepted this revision.Tue, Sep 17, 1:12 PM
This revision was automatically updated to reflect the committed changes.