diff options
author | glebius <glebius@FreeBSD.org> | 2005-02-28 11:54:36 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2005-02-28 11:54:36 +0000 |
commit | b190483209b03e799d798478f84c9ffa2e638d4e (patch) | |
tree | 3de8d73b5d613f69a583f7305ea06ac176123a84 /sys | |
parent | e8f47d5fa9ee610965bb779c7fb92c98638e00f2 (diff) | |
download | FreeBSD-src-b190483209b03e799d798478f84c9ffa2e638d4e.zip FreeBSD-src-b190483209b03e799d798478f84c9ffa2e638d4e.tar.gz |
Fix tcpdump(8) on carp(4) interface:
- Use our loop DLT type, not OpenBSD. [1]
- The fields that are converted to network byte order are not 32-bit
fields but 16-bit fields, so htons should be used in htonl. [1]
- Secondly, ip_input changes ip->ip_len into its value without
the ip-header length. So, restore the length to make bpf happy. [1]
- Use bpf_mtap2(), use temporary af1, since bpf_mtap2 doesn't
understand uint8_t af identifier.
Submitted by: Frank Volf [1]
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/ip_carp.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 8706725..7bef3f3 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -357,7 +357,7 @@ carp_clone_create(struct if_clone *ifc, int unit) ifp->if_hdrlen = 0; if_attach(ifp); LIST_INSERT_HEAD(&carpif_list, sc, sc_next); - bpfattach(&sc->sc_if, DLT_LOOP, sizeof(u_int32_t)); + bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int32_t)); return (0); } @@ -595,24 +595,13 @@ carp_input_c(struct mbuf *m, struct carp_header *ch, sa_family_t af) sc->sc_if.if_ibytes += m->m_pkthdr.len; if (sc->sc_if.if_bpf) { - /* - * We need to prepend the address family as - * a four byte field. Cons up a dummy header - * to pacify bpf. This is safe because bpf - * will only read from the mbuf (i.e., it won't - * try to free it or keep a pointer to it). - */ - struct mbuf m0; struct ip *ip = mtod(m, struct ip *); - u_int32_t maf = htonl(af); + uint32_t af1 = af; - m0.m_next = m; - m0.m_len = sizeof(maf); - m0.m_data = (char *)&maf; /* BPF wants net byte order */ - ip->ip_len = htonl(ip->ip_len); - ip->ip_off = htonl(ip->ip_off); - BPF_MTAP(&sc->sc_if, &m0); + ip->ip_len = htons(ip->ip_len + (ip->ip_hl << 2)); + ip->ip_off = htons(ip->ip_off); + bpf_mtap2(sc->sc_if.if_bpf, &af1, sizeof(af1), m); } /* verify the CARP version. */ |