diff options
| author | Chandrakanth Patil <chandrakanth.patil@broadcom.com> | 2026-01-30 07:15:55 +0000 |
|---|---|---|
| committer | Sumit Saxena <ssaxena@FreeBSD.org> | 2026-02-10 09:30:06 +0000 |
| commit | c2f799d4193f135f4d36e9f622b10b825b9144eb (patch) | |
| tree | 7d1993bcc3a9a8913893bed4c415c5e26bd6b459 | |
| parent | feb0a7e19f3c2e4c7eb90668b1e3dc34b5bb6dd6 (diff) | |
iflib: Add support for SIOCGIFDOWNREASON ioctl
This change adds native support for the SIOCGIFDOWNREASON ioctl in iflib.
When ifconfig issues SIOCGIFDOWNREASON, the request is now routed through a
new driver callback (IFDI_GET_DOWNREASON). iflib allocates the ifdownreason
structure, calls the driver to fill the down-reason message, and then
returns the data back to ifconfig for display.
Without this change, iflib-based drivers cannot implement link-down reason
reporting even if the hardware provides the information.
No functional change for existing drivers unless they implement the new
IFDI_GET_DOWNREASON method. Existing drivers continue to behave as before.
Reviewed by: gallatin, erj, kgalazka, ssaxena, #iflib
Differential Revision: https://reviews.freebsd.org/D54045
MFC After: 1 week
| -rw-r--r-- | sys/net/ifdi_if.m | 11 | ||||
| -rw-r--r-- | sys/net/iflib.c | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/sys/net/ifdi_if.m b/sys/net/ifdi_if.m index f4a3db5092ab..cb24ba36ee60 100644 --- a/sys/net/ifdi_if.m +++ b/sys/net/ifdi_if.m @@ -117,6 +117,12 @@ CODE { { return (false); } + + static int + null_get_downreason(if_ctx_t _ctx __unused, struct ifdownreason *_ifdr __unused) + { + return (ENOTSUP); + } }; # @@ -364,3 +370,8 @@ METHOD bool needs_restart { if_ctx_t _ctx; enum iflib_restart_event _event; } DEFAULT null_needs_restart; + +METHOD int get_downreason { + if_ctx_t _ctx; + struct ifdownreason *_ifdr; +} DEFAULT null_get_downreason; diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 8e2fd257ca74..08282d1799b8 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -4540,6 +4540,11 @@ iflib_if_ioctl(if_t ifp, u_long command, caddr_t data) err = IFDI_PRIV_IOCTL(ctx, command, data); CTX_UNLOCK(ctx); break; + case SIOCGIFDOWNREASON: + CTX_LOCK(ctx); + err = IFDI_GET_DOWNREASON(ctx, (struct ifdownreason *)data); + CTX_UNLOCK(ctx); + break; default: err = ether_ioctl(ifp, command, data); break; |
