Index: ng_bpf.c =================================================================== RCS file: /home/ncvs/src/sys/netgraph/ng_bpf.c,v retrieving revision 1.21 diff -u -p -r1.21 ng_bpf.c --- ng_bpf.c 7 Dec 2005 21:41:45 -0000 1.21 +++ ng_bpf.c 12 Dec 2006 22:27:57 -0000 @@ -381,8 +381,7 @@ ng_bpf_rcvdata(hook_p hook, item_p item) { const hinfo_p hip = NG_HOOK_PRIVATE(hook); int totlen; - int needfree = 0, error = 0; - u_char *data, buf[256]; + int error = 0; hinfo_p dhip; hook_p dest; u_int len; @@ -396,34 +395,20 @@ ng_bpf_rcvdata(hook_p hook, item_p item) hip->stats.recvFrames++; hip->stats.recvOctets += totlen; - /* Need to put packet in contiguous memory for bpf */ - if (m->m_next != NULL) { - if (totlen > sizeof(buf)) { - MALLOC(data, u_char *, totlen, M_NETGRAPH_BPF, M_NOWAIT); - if (data == NULL) { - NG_FREE_ITEM(item); - return (ENOMEM); - } - needfree = 1; - } else - data = buf; - m_copydata(m, 0, totlen, (caddr_t)data); - } else - data = mtod(m, u_char *); - /* Run packet through filter */ if (totlen == 0) len = 0; /* don't call bpf_filter() with totlen == 0! */ else { #ifdef BPF_JITTER - if (bpf_jitter_enable != 0 && hip->jit_prog != NULL) - len = (*(hip->jit_prog->func))(data, totlen, totlen); + /* XXX We cannot handle multiple mbufs. */ + if (bpf_jitter_enable != 0 && hip->jit_prog != NULL && + m->m_next == NULL) + len = (*(hip->jit_prog->func))(mtod(m, u_char *), + totlen, totlen); else #endif - len = bpf_filter(hip->prog->bpf_prog, data, totlen, totlen); + len = bpf_filter(hip->prog->bpf_prog, (u_char *)m, totlen, 0); } - if (needfree) - FREE(data, M_NETGRAPH_BPF); /* See if we got a match and find destination hook */ if (len > 0) {