summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_carp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet/ip_carp.c')
-rw-r--r--sys/netinet/ip_carp.c37
1 files 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);
}