-/* $OpenBSD: if_vlan.c,v 1.204 2020/07/22 01:30:54 dlg Exp $ */
+/* $OpenBSD: if_vlan.c,v 1.205 2021/01/21 13:17:13 mvs Exp $ */
/*
* Copyright 1998 Massachusetts Institute of Technology
struct ifnet *ifp0;
int error = 0;
- ifp0 = ifunit(parent); /* doesn't need an if_put */
+ ifp0 = if_unit(parent);
if (ifp0 == NULL)
return (EINVAL);
- if (ifp0->if_type != IFT_ETHER)
- return (EPROTONOSUPPORT);
+ if (ifp0->if_type != IFT_ETHER) {
+ error = EPROTONOSUPPORT;
+ goto put;
+ }
if (sc->sc_ifidx0 == ifp0->if_index) {
/* nop */
- return (0);
+ goto put;
}
- if (ISSET(ifp->if_flags, IFF_RUNNING))
- return (EBUSY);
+ if (ISSET(ifp->if_flags, IFF_RUNNING)) {
+ error = EBUSY;
+ goto put;
+ }
error = vlan_inuse(sc->sc_type, ifp0->if_index, sc->sc_tag);
if (error != 0)
- return (error);
+ goto put;
/* commit */
sc->sc_ifidx0 = ifp0->if_index;
if (!ISSET(sc->sc_flags, IFVF_LLADDR))
if_setlladdr(ifp, LLADDR(ifp0->if_sadl));
- return (0);
+put:
+ if_put(ifp0);
+ return (error);
}
int