HomeFreeBSD

if: guard against if_ioctl being NULL

Description

if: guard against if_ioctl being NULL

There are situations where an struct ifnet has a NULL if_ioctl pointer.

For example, e6000sw creates such struct ifnets for each of its ports so it can
call into the MII code.

If there is then a link state event this calls do_link_state_change()
-> rtnl_handle_ifevent() -> dump_iface() -> get_operstate() ->
get_operstate_ether(). That wants to know if the link is up or down, so it tries
to ioctl(SIOCGIFMEDIA), which doesn't go well if if_ioctl is NULL.

Guard against this, and return EOPNOTSUPP.

PR: 275920
MFC ater: 3 days
Approved by: re (cperciva)
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 43387b4e574043b78a58c8bcb7575161b055fce1)
(cherry picked from commit 9a8a26aefb366ef6f497d48547a1562a1de566c1)

Details

Provenance
kpAuthored on May 6 2024, 9:39 AM
Parents
rG2a964a7fc34e: 14.1: update to BETA3
Branches
Unknown
Tags
Unknown