diff options
author | 2015-09-10 17:32:32 +0000 | |
---|---|---|
committer | 2015-09-10 17:32:32 +0000 | |
commit | bb45e08d23f2b14c1e402724ab7c234b35fef6f8 (patch) | |
tree | c1487e6588c0d6eded48a33028d75da28c3b04c9 | |
parent | Fix error value in ktrace syscall records. ok deraadt@ dlg@ guenther@ (diff) | |
download | wireguard-openbsd-bb45e08d23f2b14c1e402724ab7c234b35fef6f8.tar.xz wireguard-openbsd-bb45e08d23f2b14c1e402724ab7c234b35fef6f8.zip |
if_put after if_get
ok claudio@
-rw-r--r-- | sys/net/if_vlan.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index b83c14f85c1..364b3be8fd3 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.137 2015/09/10 16:41:30 mikeb Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.138 2015/09/10 17:32:32 dlg Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -172,6 +172,24 @@ vlan_ifdetach(void *ptr) vlan_clone_destroy(&ifv->ifv_if); } +static inline int +vlan_mplstunnel(int ifidx) +{ +#if NMPW > 0 + struct ifnet *ifp; + int rv = 0; + + ifp = if_get(ifidx); + if (ifp != NULL) { + rv = ifp->if_type == IFT_MPLSTUNNEL; + if_put(ifp); + } + return (rv); +#else + return (0); +#endif +} + void vlan_start(struct ifnet *ifp) { @@ -206,21 +224,18 @@ vlan_start(struct ifnet *ifp) if (prio <= 1) prio = !prio; -#if NMPW > 0 - struct ifnet *ifpn = if_get(m->m_pkthdr.ph_ifidx); /* * If this packet came from a pseudowire it means it already * has all tags it needs, so just output it. */ - if (ifpn && ifpn->if_type == IFT_MPLSTUNNEL) { + if (vlan_mplstunnel(m->m_pkthdr.ph_ifidx)) { /* NOTHING */ - } else -#endif /* NMPW */ + /* * If the underlying interface cannot do VLAN tag insertion * itself, create an encapsulation header. */ - if ((p->if_capabilities & IFCAP_VLAN_HWTAGGING) && + } else if ((p->if_capabilities & IFCAP_VLAN_HWTAGGING) && (ifv->ifv_type == ETHERTYPE_VLAN)) { m->m_pkthdr.ether_vtag = ifv->ifv_tag + (prio << EVL_PRIO_BITS); |