From b050d63245ccba76344dc888830fbe2e975a5d2a Mon Sep 17 00:00:00 2001 From: bluhm Date: Fri, 2 Feb 2018 22:00:39 +0000 Subject: [PATCH] In ether_input() use goto dropanyway instead of repeating m_freem() and return. Change sizeof(etherbroadcastaddr) to ETHER_ADDR_LEN for consistency. from Michele Curti --- sys/net/if_ethersubr.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 8f7d8e7cb88..548cf22a305 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.250 2018/01/10 00:14:38 dlg Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.251 2018/02/02 22:00:39 bluhm Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -333,14 +333,12 @@ ether_input(struct ifnet *ifp, struct mbuf *m, void *cookie) */ if ((ifp->if_flags & IFF_SIMPLEX) == 0) { if (memcmp(ac->ac_enaddr, eh->ether_shost, - ETHER_ADDR_LEN) == 0) { - m_freem(m); - return (1); - } + ETHER_ADDR_LEN) == 0) + goto dropanyway; } if (memcmp(etherbroadcastaddr, eh->ether_dhost, - sizeof(etherbroadcastaddr)) == 0) + ETHER_ADDR_LEN) == 0) m->m_flags |= M_BCAST; else m->m_flags |= M_MCAST; @@ -351,10 +349,8 @@ ether_input(struct ifnet *ifp, struct mbuf *m, void *cookie) * HW vlan tagged packets that were not collected by vlan(4) must * be dropped now. */ - if (m->m_flags & M_VLANTAG) { - m_freem(m); - return (1); - } + if (m->m_flags & M_VLANTAG) + goto dropanyway; /* * If packet is unicast, make sure it is for us. Drop otherwise. @@ -362,10 +358,8 @@ ether_input(struct ifnet *ifp, struct mbuf *m, void *cookie) * where the MAC filter is 'best effort' only. */ if ((m->m_flags & (M_BCAST|M_MCAST)) == 0) { - if (memcmp(ac->ac_enaddr, eh->ether_dhost, ETHER_ADDR_LEN)) { - m_freem(m); - return (1); - } + if (memcmp(ac->ac_enaddr, eh->ether_dhost, ETHER_ADDR_LEN)) + goto dropanyway; } etype = ntohs(eh->ether_type); -- 2.20.1