diff options
author | Christopher Pascoe <pascoe@cvs.openbsd.org> | 2005-07-31 03:52:20 +0000 |
---|---|---|
committer | Christopher Pascoe <pascoe@cvs.openbsd.org> | 2005-07-31 03:52:20 +0000 |
commit | 781ac69d614f18f3a062f09f4114df646729d1f4 (patch) | |
tree | d35b9790c3a701453c5f26373609f72d03e19ec9 /sys/netinet/ip_esp.c | |
parent | 572772cf7ccf3f3860c0121c89ee22e0001d0692 (diff) |
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_esp.c')
-rw-r--r-- | sys/netinet/ip_esp.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c index 35e41b62708..f374aba0d40 100644 --- a/sys/netinet/ip_esp.c +++ b/sys/netinet/ip_esp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_esp.c,v 1.92 2005/05/28 15:10:07 ho Exp $ */ +/* $OpenBSD: ip_esp.c,v 1.93 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 @@ -731,12 +731,11 @@ esp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip, struct cryptodesc *crde = NULL, *crda = NULL; struct cryptop *crp; - #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)); @@ -747,15 +746,7 @@ esp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip, if (esph) hdr.flags |= M_AUTH; - m1.m_flags = 0; - 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 |