Page MenuHomeFreeBSD

Add SIOCGIFDOWNREASON
ClosedPublic

Authored by kib on Sep 4 2019, 8:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Mar 12, 3:29 AM
Unknown Object (File)
Dec 20 2023, 3:29 AM
Unknown Object (File)
Sep 28 2023, 9:02 AM
Unknown Object (File)
Sep 28 2023, 9:02 AM
Unknown Object (File)
Sep 28 2023, 9:01 AM
Unknown Object (File)
Sep 28 2023, 8:57 AM
Unknown Object (File)
Sep 25 2023, 12:45 AM
Unknown Object (File)
Sep 16 2023, 12:40 AM

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 - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

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

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.

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

sbin/ifconfig/ifmedia.c
193 ↗(On Diff #61829)

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

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

sbin/ifconfig/ifmedia.c
193 ↗(On Diff #61829)

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

sbin/ifconfig/ifmedia.c
193 ↗(On Diff #61829)

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

sbin/ifconfig/ifmedia.c
193 ↗(On Diff #61829)

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)

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.

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