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/net/if_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/net/if_gre.c')
-rw-r--r-- | sys/net/if_gre.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 8310ff5404e..8b411fc95fe 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gre.c,v 1.34 2005/06/08 06:35:04 henning Exp $ */ +/* $OpenBSD: if_gre.c,v 1.35 2005/07/31 03:52:18 pascoe Exp $ */ /* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -235,24 +235,8 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, m_tag_prepend(m, mtag); #if NBPFILTER >0 - if (ifp->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_int32_t af = dst->sa_family; - - m0.m_flags = 0; - m0.m_next = m; - m0.m_len = 4; - m0.m_data = (char *) ⁡ - - bpf_mtap(ifp->if_bpf, &m0); - } + if (ifp->if_bpf) + bpf_mtap_af(ifp->if_bpf, dst->sa_family, m); #endif if (sc->g_proto == IPPROTO_MOBILE) { |