From: dlg Date: Fri, 5 Mar 2021 06:44:09 +0000 (+0000) Subject: pass the uint64_t dst ethernet address from ether_input to bridges. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4e0e716093605df15aec0a8b3e8fe5fb40a5c36a;p=openbsd pass the uint64_t dst ethernet address from ether_input to bridges. tested on amd64 and sparc64. --- diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 3ec31ff993a..7dbcf4a2ab0 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.353 2021/03/01 11:05:42 bluhm Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.354 2021/03/05 06:44:09 dlg Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -110,7 +110,7 @@ void bridge_spandetach(void *); int bridge_ifremove(struct bridge_iflist *); void bridge_spanremove(struct bridge_iflist *); struct mbuf * - bridge_input(struct ifnet *, struct mbuf *, void *); + bridge_input(struct ifnet *, struct mbuf *, uint64_t, void *); void bridge_process(struct ifnet *, struct mbuf *); void bridgeintr_frame(struct ifnet *, struct ifnet *, struct mbuf *); void bridge_bifgetstp(struct bridge_softc *, struct bridge_iflist *, @@ -1119,7 +1119,7 @@ bridge_ourether(struct ifnet *ifp, uint8_t *ena) * not for us, and schedule an interrupt. */ struct mbuf * -bridge_input(struct ifnet *ifp, struct mbuf *m, void *null) +bridge_input(struct ifnet *ifp, struct mbuf *m, uint64_t dst, void *null) { KASSERT(m->m_flags & M_PKTHDR); diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 4c183cc4465..79d8ec94122 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.272 2021/03/05 03:51:41 dlg Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.273 2021/03/05 06:44:09 dlg Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -398,6 +398,7 @@ ether_input(struct ifnet *ifp, struct mbuf *m) */ eh = mtod(m, struct ether_header *); + dst = ether_addr_to_e64((struct ether_addr *)eh->ether_dhost); etype = ntohs(eh->ether_type); if (ISSET(m->m_flags, M_VLANTAG) || @@ -426,7 +427,7 @@ ether_input(struct ifnet *ifp, struct mbuf *m) smr_read_enter(); eb = SMR_PTR_GET(&ac->ac_brport); if (eb != NULL) { - m = (*eb->eb_input)(ifp, m, eb->eb_port); + m = (*eb->eb_input)(ifp, m, dst, eb->eb_port); if (m == NULL) { smr_read_leave(); return; @@ -451,7 +452,6 @@ ether_input(struct ifnet *ifp, struct mbuf *m) */ eh = mtod(m, struct ether_header *); - dst = ether_addr_to_e64((struct ether_addr *)eh->ether_dhost); self = ether_addr_to_e64((struct ether_addr *)ac->ac_enaddr); if (dst != self) { #if NCARP > 0 diff --git a/sys/net/if_switch.c b/sys/net/if_switch.c index c70761f8fd5..22aecdc6b75 100644 --- a/sys/net/if_switch.c +++ b/sys/net/if_switch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_switch.c,v 1.42 2021/02/25 02:48:21 dlg Exp $ */ +/* $OpenBSD: if_switch.c,v 1.43 2021/03/05 06:44:09 dlg Exp $ */ /* * Copyright (c) 2016 Kazuya GODA @@ -69,7 +69,7 @@ void switch_port_detach(void *); int switch_port_del(struct switch_softc *, struct ifbreq *); int switch_port_list(struct switch_softc *, struct ifbifconf *); struct mbuf * - switch_input(struct ifnet *, struct mbuf *, void *); + switch_input(struct ifnet *, struct mbuf *, uint64_t, void *); struct mbuf *switch_port_ingress(struct switch_softc *, struct ifnet *, struct mbuf *); @@ -668,7 +668,7 @@ switch_port_del(struct switch_softc *sc, struct ifbreq *req) } struct mbuf * -switch_input(struct ifnet *ifp, struct mbuf *m, void *null) +switch_input(struct ifnet *ifp, struct mbuf *m, uint64_t dst, void *null) { KASSERT(m->m_flags & M_PKTHDR); diff --git a/sys/net/if_tpmr.c b/sys/net/if_tpmr.c index 5b9e09b5705..981a7d5a09b 100644 --- a/sys/net/if_tpmr.c +++ b/sys/net/if_tpmr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tpmr.c,v 1.23 2021/02/26 02:09:45 dlg Exp $ */ +/* $OpenBSD: if_tpmr.c,v 1.24 2021/03/05 06:44:09 dlg Exp $ */ /* * Copyright (c) 2019 The University of Queensland @@ -224,16 +224,8 @@ tpmr_vlan_filter(const struct mbuf *m) } static int -tpmr_8021q_filter(const struct mbuf *m) +tpmr_8021q_filter(const struct mbuf *m, uint64_t dst) { - const struct ether_header *eh; - uint64_t dst; - - if (m->m_len < sizeof(*eh)) - return (1); - - eh = mtod(m, struct ether_header *); - dst = ether_addr_to_e64((struct ether_addr *)eh->ether_dhost); if (ETH64_IS_8021_RSVD(dst)) { switch (dst & 0xf) { case 0x01: /* IEEE MAC-specific Control Protocols */ @@ -292,7 +284,7 @@ tpmr_pf(struct ifnet *ifp0, int dir, struct mbuf *m) #endif /* NPF > 0 */ static struct mbuf * -tpmr_input(struct ifnet *ifp0, struct mbuf *m, void *brport) +tpmr_input(struct ifnet *ifp0, struct mbuf *m, uint64_t dst, void *brport) { struct tpmr_port *p = brport; struct tpmr_softc *sc = p->p_tpmr; @@ -325,7 +317,7 @@ tpmr_input(struct ifnet *ifp0, struct mbuf *m, void *brport) goto drop; if (!ISSET(ifp->if_flags, IFF_LINK0) && - tpmr_8021q_filter(m)) + tpmr_8021q_filter(m, dst)) goto drop; #if NPF > 0 diff --git a/sys/net/if_veb.c b/sys/net/if_veb.c index fd4cb4c3b73..311503e0627 100644 --- a/sys/net/if_veb.c +++ b/sys/net/if_veb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_veb.c,v 1.14 2021/03/03 00:00:03 dlg Exp $ */ +/* $OpenBSD: if_veb.c,v 1.15 2021/03/05 06:44:09 dlg Exp $ */ /* * Copyright (c) 2021 David Gwynne @@ -334,7 +334,7 @@ veb_clone_destroy(struct ifnet *ifp) } static struct mbuf * -veb_span_input(struct ifnet *ifp0, struct mbuf *m, void *brport) +veb_span_input(struct ifnet *ifp0, struct mbuf *m, uint64_t dst, void *brport) { m_freem(m); return (NULL); @@ -914,13 +914,13 @@ drop: } static struct mbuf * -veb_port_input(struct ifnet *ifp0, struct mbuf *m, void *brport) +veb_port_input(struct ifnet *ifp0, struct mbuf *m, uint64_t dst, void *brport) { struct veb_port *p = brport; struct veb_softc *sc = p->p_veb; struct ifnet *ifp = &sc->sc_if; struct ether_header *eh; - uint64_t src, dst; + uint64_t src; #if NBPFILTER > 0 caddr_t if_bpf; #endif @@ -935,7 +935,6 @@ veb_port_input(struct ifnet *ifp0, struct mbuf *m, void *brport) eh = mtod(m, struct ether_header *); src = ether_addr_to_e64((struct ether_addr *)eh->ether_shost); - dst = ether_addr_to_e64((struct ether_addr *)eh->ether_dhost); /* Is this a MAC Bridge component Reserved address? */ if (ETH64_IS_8021_RSVD(dst)) { @@ -2148,6 +2147,9 @@ vport_enqueue(struct ifnet *ifp, struct mbuf *m) smr_read_enter(); eb = SMR_PTR_GET(&ac->ac_brport); if (eb != NULL) { + struct ether_header *eh; + uint64_t dst; + counters_pkt(ifp->if_counters, ifc_opackets, ifc_obytes, m->m_pkthdr.len); @@ -2157,7 +2159,9 @@ vport_enqueue(struct ifnet *ifp, struct mbuf *m) bpf_mtap_ether(if_bpf, m, BPF_DIRECTION_OUT); #endif - m = (*eb->eb_input)(ifp, m, eb->eb_port); + eh = mtod(m, struct ether_header *); + dst = ether_addr_to_e64((struct ether_addr *)eh->ether_dhost); + m = (*eb->eb_input)(ifp, m, dst, eb->eb_port); error = 0; } diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h index 04d92124df6..83fefe51a97 100644 --- a/sys/netinet/if_ether.h +++ b/sys/netinet/if_ether.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.h,v 1.79 2021/02/26 01:12:37 dlg Exp $ */ +/* $OpenBSD: if_ether.h,v 1.80 2021/03/05 06:44:09 dlg Exp $ */ /* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */ /* @@ -218,7 +218,8 @@ do { \ #include /* for "struct ifnet" */ struct ether_brport { - struct mbuf *(*eb_input)(struct ifnet *, struct mbuf *, void *); + struct mbuf *(*eb_input)(struct ifnet *, struct mbuf *, + uint64_t, void *); void *eb_port; };