From 7cb182b490e4a60801bea9ee88f1e6ed0c9d2b2f Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 21 Apr 2015 09:35:32 +0000 Subject: [PATCH] Revert previous. Packets going through carp_input() but not destinated to the carp interface would end up enqueued without being decapsulated. Found the hard way by shten@ --- sys/netinet/ip_carp.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 0684ee07198..1c2f926999c 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.251 2015/04/15 15:16:17 mpi Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.252 2015/04/21 09:35:32 mpi Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -1416,15 +1416,11 @@ 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; - M_PREPEND(m, sizeof(*eh), M_DONTWAIT); - if (m == NULL) - return (-1); - eh = mtod(m, struct ether_header *); - memmove(eh, eh0, sizeof(*eh)); + memcpy(&eh, eh0, sizeof(eh)); if ((ifp = carp_ourether(cif, eh0->ether_dhost))) ; @@ -1445,11 +1441,11 @@ carp_input(struct ifnet *ifp0, struct ether_header *eh0, struct mbuf *m) m0->m_pkthdr.rcvif = &vh->sc_if; #if NBPFILTER > 0 if (vh->sc_if.if_bpf) - bpf_mtap_ether(vh->sc_if.if_bpf, m, - BPF_DIRECTION_IN); + bpf_mtap_hdr(vh->sc_if.if_bpf, (char *)&eh, + ETHER_HDR_LEN, m0, BPF_DIRECTION_IN, NULL); #endif vh->sc_if.if_ipackets++; - ether_input_mbuf(&vh->sc_if, m0); + ether_input(m0, &eh); } return (1); } @@ -1461,10 +1457,11 @@ carp_input(struct ifnet *ifp0, struct ether_header *eh0, struct mbuf *m) #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_hdr(ifp->if_bpf, (char *)&eh, ETHER_HDR_LEN, m, + BPF_DIRECTION_IN, NULL); #endif ifp->if_ipackets++; - ether_input_mbuf(ifp, m); + ether_input(m, &eh); return (0); } -- 2.20.1