Index: net/if_ethersubr.c =================================================================== RCS file: /cvs/src/sys/net/if_ethersubr.c,v retrieving revision 1.271 diff -u -p -r1.271 if_ethersubr.c --- net/if_ethersubr.c 26 Feb 2021 01:12:37 -0000 1.271 +++ net/if_ethersubr.c 27 Feb 2021 01:32:34 -0000 @@ -382,6 +382,7 @@ ether_input(struct ifnet *ifp, struct mb struct arpcom *ac; const struct ether_brport *eb; unsigned int sdelim = 0; + uint64_t dst, self; /* Drop short frames */ if (m->m_len < ETHER_HDR_LEN) @@ -450,14 +451,16 @@ ether_input(struct ifnet *ifp, struct mb */ eh = mtod(m, struct ether_header *); - if (memcmp(ac->ac_enaddr, eh->ether_dhost, ETHER_ADDR_LEN) != 0) { + 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 /* * If it's not for this port, it could be for carp(4). */ if (ifp->if_type != IFT_CARP && !SRPL_EMPTY_LOCKED(&ifp->if_carp)) { - m = carp_input(ifp, m); + m = carp_input(ifp, m, dst); if (m == NULL) return; @@ -468,7 +471,7 @@ ether_input(struct ifnet *ifp, struct mb /* * If not, it must be multicast or broadcast to go further. */ - if (!ETHER_IS_MULTICAST(eh->ether_dhost)) + if (!ETH64_IS_MULTICAST(dst)) goto dropanyway; /* @@ -476,15 +479,13 @@ ether_input(struct ifnet *ifp, struct mb * if it came from us. */ if ((ifp->if_flags & IFF_SIMPLEX) == 0) { - if (memcmp(ac->ac_enaddr, eh->ether_shost, - ETHER_ADDR_LEN) == 0) + uint64_t src = ether_addr_to_e64( + (struct ether_addr *)eh->ether_shost); + if (self == src) goto dropanyway; } - if (ETHER_IS_BROADCAST(eh->ether_dhost)) - m->m_flags |= M_BCAST; - else - m->m_flags |= M_MCAST; + SET(m->m_flags, ETH64_IS_BROADCAST(dst) ? M_BCAST : M_MCAST); ifp->if_imcasts++; } Index: netinet/ip_carp.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_carp.c,v retrieving revision 1.352 diff -u -p -r1.352 ip_carp.c --- netinet/ip_carp.c 8 Feb 2021 12:30:10 -0000 1.352 +++ netinet/ip_carp.c 27 Feb 2021 01:32:34 -0000 @@ -260,7 +260,7 @@ void carp_update_lsmask(struct carp_soft int carp_new_vhost(struct carp_softc *, int, int); void carp_destroy_vhosts(struct carp_softc *); void carp_del_all_timeouts(struct carp_softc *); -int carp_vhe_match(struct carp_softc *, uint8_t *); +int carp_vhe_match(struct carp_softc *, uint64_t); struct if_clone carp_cloner = IF_CLONE_INITIALIZER("carp", carp_clone_create, carp_clone_destroy); @@ -1345,6 +1345,7 @@ carp_ourether(struct ifnet *ifp, uint8_t struct carp_softc *sc; struct srp_ref sr; int match = 0; + uint64_t dst = ether_bytes_to_e64(ena); KASSERT(ifp->if_type == IFT_ETHER); @@ -1352,7 +1353,7 @@ carp_ourether(struct ifnet *ifp, uint8_t if ((sc->sc_if.if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) continue; - if (carp_vhe_match(sc, ena)) { + if (carp_vhe_match(sc, dst)) { match = 1; break; } @@ -1363,29 +1364,26 @@ carp_ourether(struct ifnet *ifp, uint8_t } int -carp_vhe_match(struct carp_softc *sc, uint8_t *ena) +carp_vhe_match(struct carp_softc *sc, uint64_t dst) { struct carp_vhost_entry *vhe; struct srp_ref sr; - int match = 0; + int active = 0; vhe = SRPL_FIRST(&sr, &sc->carp_vhosts); - match = (vhe->state == MASTER || sc->sc_balancing >= CARP_BAL_IP) && - !memcmp(ena, sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN); + active = (vhe->state == MASTER || sc->sc_balancing >= CARP_BAL_IP); SRPL_LEAVE(&sr); - return (match); + return (active && (ether_bytes_to_e64(sc->sc_ac.ac_enaddr) == dst)); } struct mbuf * -carp_input(struct ifnet *ifp0, struct mbuf *m) +carp_input(struct ifnet *ifp0, struct mbuf *m, uint64_t dst) { - struct ether_header *eh; struct srpl *cif; struct carp_softc *sc; struct srp_ref sr; - eh = mtod(m, struct ether_header *); cif = &ifp0->if_carp; SRPL_FOREACH(sc, &sr, cif, sc_list) { @@ -1393,7 +1391,7 @@ carp_input(struct ifnet *ifp0, struct mb (IFF_UP|IFF_RUNNING)) continue; - if (carp_vhe_match(sc, eh->ether_dhost)) { + if (carp_vhe_match(sc, dst)) { /* * These packets look like layer 2 multicast but they * are unicast at layer 3. With help of the tag the @@ -1417,7 +1415,7 @@ carp_input(struct ifnet *ifp0, struct mb if (sc == NULL) { SRPL_LEAVE(&sr); - if (!ETHER_IS_MULTICAST(eh->ether_dhost)) + if (!ETH64_IS_MULTICAST(dst)) return (m); /* Index: netinet/ip_carp.h =================================================================== RCS file: /cvs/src/sys/netinet/ip_carp.h,v retrieving revision 1.50 diff -u -p -r1.50 ip_carp.h --- netinet/ip_carp.h 24 Jul 2020 18:17:15 -0000 1.50 +++ netinet/ip_carp.h 27 Feb 2021 01:32:34 -0000 @@ -209,7 +209,7 @@ carp_strict_addr_chk(struct ifnet *ifp_a ifp_a->if_carpdevidx == ifp_b->if_carpdevidx)); } -struct mbuf *carp_input(struct ifnet *, struct mbuf *); +struct mbuf *carp_input(struct ifnet *, struct mbuf *, uint64_t); int carp_proto_input(struct mbuf **, int *, int, int); void carp_carpdev_state(void *);