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_gre.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_gre.c')
-rw-r--r-- | sys/netinet/ip_gre.c | 41 |
1 files changed, 5 insertions, 36 deletions
diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c index 8c65f1a3798..886964f2070 100644 --- a/sys/netinet/ip_gre.c +++ b/sys/netinet/ip_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_gre.c,v 1.26 2005/06/08 06:16:42 henning Exp $ */ +/* $OpenBSD: ip_gre.c,v 1.27 2005/07/31 03:52:19 pascoe Exp $ */ /* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -192,23 +192,8 @@ gre_input2(m , hlen, proto) m_adj(m, hlen); #if NBPFILTER > 0 - if (sc->sc_if.if_bpf) { - /* - * We need to prepend the address family as - * a four byte field. Cons up a fake 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 m0; - - m0.m_flags = 0; - m0.m_next = m; - m0.m_len = 4; - m0.m_data = (char *) ⁡ - - bpf_mtap(sc->sc_if.if_bpf, &m0); - } + if (sc->sc_if.if_bpf) + bpf_mtap_af(sc->sc_if.if_bpf, af, m); #endif s = splimp(); /* possible */ @@ -333,24 +318,8 @@ gre_mobile_input(struct mbuf *m, ...) ifq = &ipintrq; #if NBPFILTER > 0 - if (sc->sc_if.if_bpf) { - /* - * We need to prepend the address family as - * a four byte field. Cons up a fake 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 m0; - u_int af = AF_INET; - - m0.m_flags = 0; - m0.m_next = m; - m0.m_len = 4; - m0.m_data = (char *) ⁡ - - bpf_mtap(sc->sc_if.if_bpf, &m0); - } + if (sc->sc_if.if_bpf) + bpf_mtap_af(sc->sc_if.if_bpf, AF_INET, m); #endif s = splimp(); /* possible */ |