From cb0bed981444bda99e62f97f00efcc1f92d52dfd Mon Sep 17 00:00:00 2001 From: mpi Date: Wed, 22 Apr 2015 06:44:17 +0000 Subject: [PATCH] Add the necessary glue to keep carp(4) working while other pseudo-drivers are converted to if_input(), this time without breaking parent-less setup. ok sthen@, dlg@ --- sys/netinet/ip_carp.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 1c2f926999c..7dd8dca5d15 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.252 2015/04/21 09:35:32 mpi Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.253 2015/04/22 06:44:17 mpi Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -1416,15 +1416,15 @@ carp_our_mcastaddr(struct ifnet *ifp, u_int8_t *d_enaddr) int carp_input(struct ifnet *ifp0, struct ether_header *eh0, struct mbuf *m) { - struct ether_header eh; + struct ether_header *eh; struct carp_if *cif = (struct carp_if *)ifp0->if_carp; struct ifnet *ifp; - memcpy(&eh, eh0, sizeof(eh)); + ifp = carp_ourether(cif, eh0->ether_dhost); + if (ifp == NULL && (m->m_flags & (M_BCAST|M_MCAST)) == 0) + return (1); - if ((ifp = carp_ourether(cif, eh0->ether_dhost))) - ; - else if (m->m_flags & (M_BCAST|M_MCAST)) { + if (ifp == NULL) { struct carp_softc *vh; struct mbuf *m0; @@ -1438,30 +1438,39 @@ carp_input(struct ifnet *ifp0, struct ether_header *eh0, struct mbuf *m) m0 = m_copym2(m, 0, M_COPYALL, M_DONTWAIT); if (m0 == NULL) continue; + M_PREPEND(m0, sizeof(*eh), M_DONTWAIT); + if (m0 == NULL) + continue; + eh = mtod(m0, struct ether_header *); + memmove(eh, eh0, sizeof(*eh)); + m0->m_pkthdr.rcvif = &vh->sc_if; #if NBPFILTER > 0 if (vh->sc_if.if_bpf) - bpf_mtap_hdr(vh->sc_if.if_bpf, (char *)&eh, - ETHER_HDR_LEN, m0, BPF_DIRECTION_IN, NULL); + bpf_mtap_ether(vh->sc_if.if_bpf, m0, + BPF_DIRECTION_IN); #endif vh->sc_if.if_ipackets++; - ether_input(m0, &eh); + ether_input_mbuf(&vh->sc_if, m0); } + return (1); } - if (ifp == NULL) - return (1); + M_PREPEND(m, sizeof(*eh), M_DONTWAIT); + if (m == NULL) + return (0); + eh = mtod(m, struct ether_header *); + memmove(eh, eh0, sizeof(*eh)); m->m_pkthdr.rcvif = ifp; #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap_hdr(ifp->if_bpf, (char *)&eh, ETHER_HDR_LEN, m, - BPF_DIRECTION_IN, NULL); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif ifp->if_ipackets++; - ether_input(m, &eh); + ether_input_mbuf(ifp, m); return (0); } -- 2.20.1