summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ipsec_input.c
diff options
context:
space:
mode:
authorpascoe <pascoe@openbsd.org>2005-07-31 03:52:18 +0000
committerpascoe <pascoe@openbsd.org>2005-07-31 03:52:18 +0000
commit63df607f4ba29b104b88074b0e34fff7f2442652 (patch)
tree7f01592680bffe6f7f165b3c1d56128c8c789d94 /sys/netinet/ipsec_input.c
parentChange the API for icmp_do_error so that it takes the mtu directly, rather (diff)
downloadwireguard-openbsd-63df607f4ba29b104b88074b0e34fff7f2442652.tar.xz
wireguard-openbsd-63df607f4ba29b104b88074b0e34fff7f2442652.zip
Introduce bpf_mtap_af and bpf_mtap_hdr to be used when passing a mbuf chain
to bpf with either an address family or other header added. These helpers only allocate a much smaller struct m_hdr on the stack when needed, rather than leaving 256 byte struct mbufs on the stack in deep call paths. Also removes a fair bit of duplicated code. commit now, tune after deraadt@
Diffstat (limited to 'sys/netinet/ipsec_input.c')
-rw-r--r--sys/netinet/ipsec_input.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c
index cb7aa669434..17e23e856e0 100644
--- a/sys/netinet/ipsec_input.c
+++ b/sys/netinet/ipsec_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_input.c,v 1.75 2004/11/25 21:54:54 markus Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.76 2005/07/31 03:52:19 pascoe Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -560,26 +560,13 @@ ipsec_common_input_cb(struct mbuf *m, struct tdb *tdbp, int skip, int protoff,
#if NBPFILTER > 0
bpfif = &encif[0].sc_if;
if (bpfif->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 a to it).
- */
- struct mbuf m1;
struct enchdr hdr;
hdr.af = af;
hdr.spi = tdbp->tdb_spi;
hdr.flags = m->m_flags & (M_AUTH|M_CONF|M_AUTH_AH);
- m1.m_flags = 0;
- m1.m_next = m;
- m1.m_len = ENC_HDRLEN;
- m1.m_data = (char *) &hdr;
-
- bpf_mtap(bpfif->if_bpf, &m1);
+ bpf_mtap_hdr(bpfif->if_bpf, (char *)&hdr, ENC_HDRLEN, m);
}
#endif