the code pretty obviously assumes that it only handles Ethernet packets, so we should restrict it to IF_ETHER type interfaces.
ok? Index: if_switch.c =================================================================== RCS file: /cvs/src/sys/net/if_switch.c,v retrieving revision 1.30 diff -u -p -r1.30 if_switch.c --- if_switch.c 6 Nov 2019 03:51:26 -0000 1.30 +++ if_switch.c 9 Jul 2020 05:59:51 -0000 @@ -506,6 +506,9 @@ switch_port_add(struct switch_softc *sc, if ((ifs = ifunit(req->ifbr_ifsname)) == NULL) return (ENOENT); + if (ifs->if_type != IFT_ETHER) + return (EPROTONOSUPPORT); + if (ifs->if_bridgeidx != 0) return (EBUSY); @@ -517,15 +520,12 @@ switch_port_add(struct switch_softc *sc, return (EBUSY); } - if (ifs->if_type == IFT_ETHER) { - if ((error = ifpromisc(ifs, 1)) != 0) - return (error); - } + if ((error = ifpromisc(ifs, 1)) != 0) + return (error); swpo = malloc(sizeof(*swpo), M_DEVBUF, M_NOWAIT|M_ZERO); if (swpo == NULL) { - if (ifs->if_type == IFT_ETHER) - ifpromisc(ifs, 0); + ifpromisc(ifs, 0); return (ENOMEM); } swpo->swpo_switch = sc;