From 281b584e8e67aeaa7a50762a346678c7364fa725 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Fri, 9 Jul 2010 11:27:33 +0000 Subject: [PATCH] Improve last commit: use bpf_mtap2() to avoiding stack usage. Prodded by: julian --- sys/netinet/ipfw/ip_fw_log.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/sys/netinet/ipfw/ip_fw_log.c b/sys/netinet/ipfw/ip_fw_log.c index d1ed43260d15..2995f2cc1553 100644 --- a/sys/netinet/ipfw/ip_fw_log.c +++ b/sys/netinet/ipfw/ip_fw_log.c @@ -152,24 +152,17 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ip_fw_args *args, if (V_fw_verbose == 0) { #ifndef WITHOUT_BPF - struct mbuf m0; if (log_if == NULL || log_if->if_bpf == NULL) return; - /* BPF treats the "mbuf" as read-only */ - bzero(&m0, sizeof(struct mbuf)); - m0.m_hdr.mh_next = m; - m0.m_hdr.mh_len = ETHER_HDR_LEN; - if (args->eh) { /* layer2, use orig hdr */ - m0.m_hdr.mh_data = (char *)args->eh; - } else { - /* add fake header. Later we will store - * more info in the header + if (args->eh) /* layer2, use orig hdr */ + BPF_MTAP2(log_if, args->eh, ETHER_HDR_LEN, m); + else + /* Add fake header. Later we will store + * more info in the header. */ - m0.m_hdr.mh_data = "DDDDDDSSSSSS\x08\x00"; - } - BPF_MTAP(log_if, &m0); + BPF_MTAP2(log_if, "DDDDDDSSSSSS\x08\x00", ETHER_HDR_LEN, m); #endif /* !WITHOUT_BPF */ return; }