diff options
author | pascoe <pascoe@openbsd.org> | 2005-07-31 03:52:18 +0000 |
---|---|---|
committer | pascoe <pascoe@openbsd.org> | 2005-07-31 03:52:18 +0000 |
commit | 63df607f4ba29b104b88074b0e34fff7f2442652 (patch) | |
tree | 7f01592680bffe6f7f165b3c1d56128c8c789d94 /sys/netinet/ip_ipcomp.c | |
parent | Change the API for icmp_do_error so that it takes the mtu directly, rather (diff) | |
download | wireguard-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/ip_ipcomp.c')
-rw-r--r-- | sys/netinet/ip_ipcomp.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/sys/netinet/ip_ipcomp.c b/sys/netinet/ip_ipcomp.c index 36ebfad06ac..a1a1f2d0f4d 100644 --- a/sys/netinet/ip_ipcomp.c +++ b/sys/netinet/ip_ipcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipcomp.c,v 1.17 2004/11/25 21:54:54 markus Exp $ */ +/* $OpenBSD: ip_ipcomp.c,v 1.18 2005/07/31 03:52:19 pascoe Exp $ */ /* * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org) @@ -387,26 +387,18 @@ ipcomp_output(m, tdb, mp, skip, protoff) struct cryptop *crp; struct tdb_crypto *tc; struct mbuf *mi, *mo; - #if NBPFILTER > 0 - { - struct ifnet *ifn; + struct ifnet *ifn = &(encif[0].sc_if); + + if (ifn->if_bpf) { struct enchdr hdr; - struct mbuf m1; bzero(&hdr, sizeof(hdr)); hdr.af = tdb->tdb_dst.sa.sa_family; hdr.spi = tdb->tdb_spi; - m1.m_next = m; - m1.m_len = ENC_HDRLEN; - m1.m_data = (char *) &hdr; - - ifn = &(encif[0].sc_if); - - if (ifn->if_bpf) - bpf_mtap(ifn->if_bpf, &m1); + bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, ENC_HDRLEN, m); } #endif hlen = IPCOMP_HLENGTH; |