Download raw body.
stop reporting ifmedia on virtual interfaces
On Fri, Nov 13, 2026 at 01:01:27PM +1000, David Gwynne wrote:
> showing "media: Ethernet autoselect" on virtual interfaces is
> unecessary. the important thing is link state, which is reported via
> if_link_state on the interface itself.
>
> this is inspired by src/sys/net/if_gre.c r1.195, which removed ifmedia
> code from gre because it wasn't wired up.
>
> the exception is vlan, svlan, and bpe, which pass the SIOCGIFMEDIA
> requests through to their parent interfaces.
>
> ok?
>
ok mvs
> Index: conf/files
> ===================================================================
> RCS file: /cvs/src/sys/conf/files,v
> diff -u -p -r1.752 files
> --- conf/files 16 Mar 2026 14:57:34 -0000 1.752
> +++ conf/files 13 Nov 2026 02:54:28 -0000
> @@ -592,7 +592,7 @@ pseudo-device ppp: ifnet
> pseudo-device tun: ifnet
> pseudo-device bpfilter: ifnet
> pseudo-device enc: ifnet
> -pseudo-device etherip: ifnet, ether, ifmedia
> +pseudo-device etherip: ifnet, ether
> pseudo-device bridge: ifnet, ether
> pseudo-device veb: ifnet, ether, etherbridge
> pseudo-device vlan: ifnet, ether
> @@ -602,9 +602,9 @@ pseudo-device gif: ifnet
> pseudo-device sec: ifnet
> pseudo-device gre: ifnet, ether, etherbridge
> pseudo-device crypto: ifnet
> -pseudo-device trunk: ifnet, ether, ifmedia
> -pseudo-device aggr: ifnet, ether, ifmedia
> -pseudo-device tpmr: ifnet, ether, ifmedia
> +pseudo-device trunk: ifnet, ether
> +pseudo-device aggr: ifnet, ether
> +pseudo-device tpmr: ifnet, ether
> pseudo-device mpe: ifnet, mpls
> pseudo-device mpw: ifnet, mpls, ether
> pseudo-device mpip: ifnet, mpls
> Index: net/if_aggr.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_aggr.c,v
> diff -u -p -r1.54 if_aggr.c
> --- net/if_aggr.c 5 Nov 2026 05:49:59 -0000 1.54
> +++ net/if_aggr.c 13 Nov 2026 02:54:28 -0000
> @@ -73,8 +73,6 @@
> #include <net/if.h>
> #include <net/if_types.h>
>
> -#include <net/if_media.h>
> -
> #include <netinet/in.h>
> #include <netinet/if_ether.h>
>
> @@ -413,7 +411,6 @@ struct aggr_softc {
> #define sc_if sc_ac.ac_if
> unsigned int sc_dead;
> unsigned int sc_promisc;
> - struct ifmedia sc_media;
>
> struct aggr_multiaddrs sc_multiaddrs;
>
> @@ -462,9 +459,6 @@ static int aggr_ioctl(struct ifnet *, u_
> static void aggr_start(struct ifqueue *);
> static int aggr_enqueue(struct ifnet *, struct mbuf *);
>
> -static int aggr_media_change(struct ifnet *);
> -static void aggr_media_status(struct ifnet *, struct ifmediareq *);
> -
> static int aggr_up(struct aggr_softc *);
> static int aggr_down(struct aggr_softc *);
> static int aggr_iff(struct aggr_softc *);
> @@ -578,10 +572,6 @@ aggr_clone_create(struct if_clone *ifc,
> sc->sc_lacp_prio = 0x8000; /* medium */
> sc->sc_lacp_port_prio = 0x8000; /* medium */
>
> - ifmedia_init(&sc->sc_media, 0, aggr_media_change, aggr_media_status);
> - ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
> - ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO);
> -
> ifp->if_softc = sc;
> ifp->if_hardmtu = ETHER_MAX_HARDMTU_LEN;
> ifp->if_ioctl = aggr_ioctl;
> @@ -996,13 +986,6 @@ aggr_ioctl(struct ifnet *ifp, u_long cmd
> error = aggr_multi_del(sc, ifr);
> break;
>
> - case SIOCSIFMEDIA:
> - error = EOPNOTSUPP;
> - break;
> - case SIOCGIFMEDIA:
> - error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
> - break;
> -
> default:
> error = ether_ioctl(ifp, &sc->sc_ac, cmd, data);
> break;
> @@ -2794,26 +2777,6 @@ aggr_multi(struct aggr_softc *sc, struct
> ifr.if_addr = ma->m_addr;
>
> return ((*p->p_ioctl)(ifp0, cmd, (caddr_t)&ifr));
> -}
> -
> -static void
> -aggr_media_status(struct ifnet *ifp, struct ifmediareq *imr)
> -{
> - struct aggr_softc *sc = ifp->if_softc;
> -
> - imr->ifm_status = IFM_AVALID;
> - imr->ifm_active = IFM_ETHER | IFM_AUTO;
> -
> - smr_read_enter(); /* there's no reason to block... */
> - if (SMR_PTR_GET(&sc->sc_map) != NULL)
> - imr->ifm_status |= IFM_ACTIVE;
> - smr_read_leave();
> -}
> -
> -static int
> -aggr_media_change(struct ifnet *ifp)
> -{
> - return (EOPNOTSUPP);
> }
>
> static void
> Index: net/if_etherip.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_etherip.c,v
> diff -u -p -r1.60 if_etherip.c
> --- net/if_etherip.c 4 Nov 2026 08:51:51 -0000 1.60
> +++ net/if_etherip.c 13 Nov 2026 02:54:28 -0000
> @@ -27,7 +27,6 @@
>
> #include <net/if.h>
> #include <net/if_var.h>
> -#include <net/if_media.h>
> #include <net/rtable.h>
>
> #include <netinet/in.h>
> @@ -87,7 +86,6 @@ static inline int etherip_cmp(const stru
> struct etherip_softc {
> struct etherip_tunnel sc_tunnel; /* must be first */
> struct arpcom sc_ac;
> - struct ifmedia sc_media;
> int sc_txhprio;
> int sc_rxhprio;
> uint16_t sc_df;
> @@ -109,8 +107,6 @@ int etherip_ioctl(struct ifnet *, u_long
> int etherip_output(struct ifnet *, struct mbuf *, struct sockaddr *,
> struct rtentry *);
> void etherip_start(struct ifnet *);
> -int etherip_media_change(struct ifnet *);
> -void etherip_media_status(struct ifnet *, struct ifmediareq *);
> int etherip_set_tunnel(struct etherip_softc *, struct if_laddrreq *);
> int etherip_get_tunnel(struct etherip_softc *, struct if_laddrreq *);
> int etherip_del_tunnel(struct etherip_softc *);
> @@ -159,11 +155,6 @@ etherip_clone_create(struct if_clone *if
> ifp->if_capabilities = IFCAP_VLAN_MTU;
> ether_fakeaddr(ifp);
>
> - ifmedia_init(&sc->sc_media, 0, etherip_media_change,
> - etherip_media_status);
> - ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
> - ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO);
> -
> if_counters_alloc(ifp);
> if_attach(ifp);
> ether_ifattach(ifp);
> @@ -187,7 +178,6 @@ etherip_clone_destroy(struct ifnet *ifp)
> TAILQ_REMOVE(ðerip_list, &sc->sc_tunnel, t_entry);
> NET_UNLOCK();
>
> - ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
> ether_ifdetach(ifp);
> if_detach(ifp);
>
> @@ -197,19 +187,6 @@ etherip_clone_destroy(struct ifnet *ifp)
> }
>
> int
> -etherip_media_change(struct ifnet *ifp)
> -{
> - return 0;
> -}
> -
> -void
> -etherip_media_status(struct ifnet *ifp, struct ifmediareq *imr)
> -{
> - imr->ifm_active = IFM_ETHER | IFM_AUTO;
> - imr->ifm_status = IFM_AVALID | IFM_ACTIVE;
> -}
> -
> -int
> etherip_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
> struct rtentry *rt)
> {
> @@ -351,11 +328,6 @@ etherip_ioctl(struct ifnet *ifp, u_long
> break;
> case SIOCGLIFPHYDF:
> ifr->ifr_df = sc->sc_df ? 1 : 0;
> - break;
> -
> - case SIOCSIFMEDIA:
> - case SIOCGIFMEDIA:
> - error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
> break;
>
> case SIOCADDMULTI:
> Index: net/if_pair.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_pair.c,v
> diff -u -p -r1.18 if_pair.c
> --- net/if_pair.c 7 Jul 2025 02:28:50 -0000 1.18
> +++ net/if_pair.c 13 Nov 2026 02:54:28 -0000
> @@ -23,7 +23,6 @@
> #include <sys/sockio.h>
>
> #include <net/if.h>
> -#include <net/if_media.h>
>
> #include <netinet/in.h>
> #include <netinet/if_ether.h>
> @@ -38,42 +37,16 @@ int pairioctl(struct ifnet *, u_long, ca
> void pairstart(struct ifqueue *);
> int pair_clone_create(struct if_clone *, int);
> int pair_clone_destroy(struct ifnet *);
> -int pair_media_change(struct ifnet *);
> -void pair_media_status(struct ifnet *, struct ifmediareq *);
> void pair_link_state(struct ifnet *);
>
> struct pair_softc {
> struct arpcom sc_ac;
> - struct ifmedia sc_media;
> unsigned int sc_pairedif;
> };
>
> struct if_clone pair_cloner =
> IF_CLONE_INITIALIZER("pair", pair_clone_create, pair_clone_destroy);
>
> -int
> -pair_media_change(struct ifnet *ifp)
> -{
> - return (0);
> -}
> -
> -void
> -pair_media_status(struct ifnet *ifp, struct ifmediareq *imr)
> -{
> - struct pair_softc *sc = ifp->if_softc;
> - struct ifnet *pairedifp;
> -
> - imr->ifm_active = IFM_ETHER | IFM_AUTO;
> -
> - if ((pairedifp = if_get(sc->sc_pairedif)) == NULL) {
> - imr->ifm_status = 0;
> - return;
> - }
> - if_put(pairedifp);
> -
> - imr->ifm_status = IFM_AVALID | IFM_ACTIVE;
> -}
> -
> void
> pair_link_state(struct ifnet *ifp)
> {
> @@ -120,11 +93,6 @@ pair_clone_create(struct if_clone *ifc,
> ifp->if_hardmtu = ETHER_MAX_HARDMTU_LEN;
> ifp->if_capabilities = IFCAP_VLAN_MTU;
>
> - ifmedia_init(&sc->sc_media, 0, pair_media_change,
> - pair_media_status);
> - ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
> - ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO);
> -
> if_attach(ifp);
> ether_ifattach(ifp);
>
> @@ -147,7 +115,6 @@ pair_clone_destroy(struct ifnet *ifp)
> if_put(pairedifp);
> }
>
> - ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
> ether_ifdetach(ifp);
> if_detach(ifp);
> free(sc, M_DEVBUF, sizeof(*sc));
> @@ -210,11 +177,6 @@ pairioctl(struct ifnet *ifp, u_long cmd,
>
> case SIOCADDMULTI:
> case SIOCDELMULTI:
> - break;
> -
> - case SIOCGIFMEDIA:
> - case SIOCSIFMEDIA:
> - error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
> break;
>
> case SIOCSIFPAIR:
> Index: net/if_trunk.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_trunk.c,v
> diff -u -p -r1.162 if_trunk.c
> --- net/if_trunk.c 8 Nov 2026 08:42:55 -0000 1.162
> +++ net/if_trunk.c 13 Nov 2026 02:54:28 -0000
> @@ -30,7 +30,6 @@
>
> #include <net/if.h>
> #include <net/if_dl.h>
> -#include <net/if_media.h>
> #include <net/if_types.h>
>
> #include <netinet/in.h>
> @@ -81,8 +80,6 @@ struct mbuf *
> void trunk_start(struct ifnet *);
> void trunk_init(struct ifnet *);
> void trunk_stop(struct ifnet *);
> -int trunk_media_change(struct ifnet *);
> -void trunk_media_status(struct ifnet *, struct ifmediareq *);
> struct trunk_port *trunk_link_active(struct trunk_softc *,
> struct trunk_port *);
> const void *trunk_gethdr(struct mbuf *, u_int, u_int, void *);
> @@ -164,12 +161,6 @@ trunk_clone_create(struct if_clone *ifc,
> }
> SLIST_INIT(&tr->tr_ports);
>
> - /* Initialise pseudo media types */
> - ifmedia_init(&tr->tr_media, 0, trunk_media_change,
> - trunk_media_status);
> - ifmedia_add(&tr->tr_media, IFM_ETHER | IFM_AUTO, 0, NULL);
> - ifmedia_set(&tr->tr_media, IFM_ETHER | IFM_AUTO);
> -
> ifp = &tr->tr_ac.ac_if;
> ifp->if_softc = tr;
> ifp->if_start = trunk_start;
> @@ -215,7 +206,6 @@ trunk_clone_destroy(struct ifnet *ifp)
> }
> NET_UNLOCK();
>
> - ifmedia_delete_instance(&tr->tr_media, IFM_INST_ANY);
> ether_ifdetach(ifp);
> if_detach(ifp);
>
> @@ -780,10 +770,6 @@ trunk_ioctl(struct ifnet *ifp, u_long cm
> case SIOCDELMULTI:
> error = trunk_ether_delmulti(tr, ifr);
> break;
> - case SIOCSIFMEDIA:
> - case SIOCGIFMEDIA:
> - error = ifmedia_ioctl(ifp, ifr, &tr->tr_media, cmd);
> - break;
> case SIOCSIFLLADDR:
> /* Update the port lladdrs as well */
> SLIST_FOREACH(tp, &tr->tr_ports, tp_entries)
> @@ -1143,33 +1129,6 @@ trunk_input(struct ifnet *ifp, struct mb
> drop:
> m_freem(m);
> return (NULL);
> -}
> -
> -int
> -trunk_media_change(struct ifnet *ifp)
> -{
> - struct trunk_softc *tr = (struct trunk_softc *)ifp->if_softc;
> -
> - if (tr->tr_ifflags & IFF_DEBUG)
> - printf("%s\n", __func__);
> -
> - /* Ignore */
> - return (0);
> -}
> -
> -void
> -trunk_media_status(struct ifnet *ifp, struct ifmediareq *imr)
> -{
> - struct trunk_softc *tr = (struct trunk_softc *)ifp->if_softc;
> - struct trunk_port *tp;
> -
> - imr->ifm_status = IFM_AVALID;
> - imr->ifm_active = IFM_ETHER | IFM_AUTO;
> -
> - SLIST_FOREACH(tp, &tr->tr_ports, tp_entries) {
> - if (TRUNK_PORTACTIVE(tp))
> - imr->ifm_status |= IFM_ACTIVE;
> - }
> }
>
> void
> Index: net/if_trunk.h
> ===================================================================
> RCS file: /cvs/src/sys/net/if_trunk.h,v
> diff -u -p -r1.34 if_trunk.h
> --- net/if_trunk.h 8 May 2026 03:36:04 -0000 1.34
> +++ net/if_trunk.h 13 Nov 2026 02:54:28 -0000
> @@ -224,7 +224,6 @@ struct trunk_softc {
> enum trunk_proto tr_proto; /* trunk protocol */
> u_int tr_count; /* number of ports */
> struct trunk_port *tr_primary; /* primary port */
> - struct ifmedia tr_media; /* media config */
> caddr_t tr_psc; /* protocol data */
>
> SLIST_HEAD(__tplhd, trunk_port) tr_ports; /* list of interfaces */
> Index: net/if_vether.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_vether.c,v
> diff -u -p -r1.39 if_vether.c
> --- net/if_vether.c 16 Sep 2025 23:11:39 -0000 1.39
> +++ net/if_vether.c 13 Nov 2026 02:54:28 -0000
> @@ -22,7 +22,6 @@
> #include <sys/sockio.h>
>
> #include <net/if.h>
> -#include <net/if_media.h>
>
> #include <netinet/in.h>
> #include <netinet/if_ether.h>
> @@ -38,30 +37,14 @@ int vetherioctl(struct ifnet *, u_long,
> void vetherqstart(struct ifqueue *);
> int vether_clone_create(struct if_clone *, int);
> int vether_clone_destroy(struct ifnet *);
> -int vether_media_change(struct ifnet *);
> -void vether_media_status(struct ifnet *, struct ifmediareq *);
>
> struct vether_softc {
> struct arpcom sc_ac;
> - struct ifmedia sc_media;
> };
>
> struct if_clone vether_cloner =
> IF_CLONE_INITIALIZER("vether", vether_clone_create, vether_clone_destroy);
>
> -int
> -vether_media_change(struct ifnet *ifp)
> -{
> - return (0);
> -}
> -
> -void
> -vether_media_status(struct ifnet *ifp, struct ifmediareq *imr)
> -{
> - imr->ifm_active = IFM_ETHER | IFM_AUTO;
> - imr->ifm_status = IFM_AVALID | IFM_ACTIVE;
> -}
> -
> void
> vetherattach(int nvether)
> {
> @@ -94,11 +77,6 @@ vether_clone_create(struct if_clone *ifc
> ifp->if_capabilities |= IFCAP_CSUM_TCPv6 | IFCAP_CSUM_UDPv6;
> ifp->if_xflags = IFXF_CLONED | IFXF_MPSAFE;
>
> - ifmedia_init(&sc->sc_media, 0, vether_media_change,
> - vether_media_status);
> - ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
> - ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO);
> -
> if_attach(ifp);
> ether_ifattach(ifp);
> return (0);
> @@ -109,7 +87,6 @@ vether_clone_destroy(struct ifnet *ifp)
> {
> struct vether_softc *sc = ifp->if_softc;
>
> - ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
> ether_ifdetach(ifp);
> if_detach(ifp);
> free(sc, M_DEVBUF, sizeof(*sc));
> @@ -141,7 +118,6 @@ int
> vetherioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
> {
> struct vether_softc *sc = (struct vether_softc *)ifp->if_softc;
> - struct ifreq *ifr = (struct ifreq *)data;
> int error = 0, link_state;
>
> switch (cmd) {
> @@ -165,11 +141,6 @@ vetherioctl(struct ifnet *ifp, u_long cm
>
> case SIOCADDMULTI:
> case SIOCDELMULTI:
> - break;
> -
> - case SIOCGIFMEDIA:
> - case SIOCSIFMEDIA:
> - error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
> break;
>
> default:
>
stop reporting ifmedia on virtual interfaces