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
This commit is contained in:
Chandrakanth Patil
2026-01-30 07:15:55 +00:00
committed by Sumit Saxena
parent feb0a7e19f
commit c2f799d419
2 changed files with 16 additions and 0 deletions
+11
View File
@@ -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;
+5
View File
@@ -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;