From 2512f120b4360b72c5c5fd8b0cc5e1cf6e18bb8e Mon Sep 17 00:00:00 2001 From: mvs Date: Thu, 21 Jan 2021 13:17:13 +0000 Subject: [PATCH] vlan(4): convert ifunit() to if_unit(9) ok dlg@ kn@ --- sys/net/if_vlan.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index c5a08e63950..b0bf72d2cb6 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $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 @@ -887,31 +887,37 @@ vlan_set_parent(struct vlan_softc *sc, const char *parent) 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 -- 2.20.1