From owner-svn-src-projects@FreeBSD.ORG Sat Dec 8 00:47:04 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9B7B2324; Sat, 8 Dec 2012 00:47:04 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 679D48FC19; Sat, 8 Dec 2012 00:47:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qB80l4Es025035; Sat, 8 Dec 2012 00:47:04 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qB80l4jO025032; Sat, 8 Dec 2012 00:47:04 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201212080047.qB80l4jO025032@svn.freebsd.org> From: Jung-uk Kim Date: Sat, 8 Dec 2012 00:47:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r244009 - projects/bpfjit/sys/netgraph X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Dec 2012 00:47:04 -0000 Author: jkim Date: Sat Dec 8 00:47:03 2012 New Revision: 244009 URL: http://svnweb.freebsd.org/changeset/base/244009 Log: Remove an unnecessary hack. bpfjit can handle mbuf chains. Modified: projects/bpfjit/sys/netgraph/ng_bpf.c Modified: projects/bpfjit/sys/netgraph/ng_bpf.c ============================================================================== --- projects/bpfjit/sys/netgraph/ng_bpf.c Sat Dec 8 00:29:16 2012 (r244008) +++ projects/bpfjit/sys/netgraph/ng_bpf.c Sat Dec 8 00:47:03 2012 (r244009) @@ -416,7 +416,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, usejit = 0; + int error = 0; u_char *data = NULL; hinfo_p dhip; hook_p dest; @@ -437,23 +437,8 @@ ng_bpf_rcvdata(hook_p hook, item_p item) goto ready; } -#ifdef BPFJIT - if (bpfjit_disable == 0 && hip->jit_prog != NULL) - usejit = 1; -#endif - /* Need to put packet in contiguous memory for bpf */ - if (m->m_next != NULL && totlen > MHLEN) { - if (usejit) { - data = malloc(totlen, M_NETGRAPH_BPF, M_NOWAIT); - if (data == NULL) { - NG_FREE_ITEM(item); - return (ENOMEM); - } - needfree = 1; - m_copydata(m, 0, totlen, (caddr_t)data); - } - } else { + if (m->m_next == NULL || totlen <= MHLEN) { if (m->m_next != NULL) { NGI_M(item) = m = m_pullup(m, totlen); if (m == NULL) { @@ -466,16 +451,18 @@ ng_bpf_rcvdata(hook_p hook, item_p item) /* Run packet through filter */ #ifdef BPFJIT - if (usejit) - len = (hip->jit_prog)(data, totlen, totlen); - else + if (bpfjit_disable == 0 && hip->jit_prog != NULL) { + if (data) + len = (hip->jit_prog)(data, totlen, totlen); + else + len = (hip->jit_prog)((u_char *)m, totlen, 0); + } else #endif if (data) len = bpf_filter(hip->prog->bpf_prog, data, totlen, totlen); else len = bpf_filter(hip->prog->bpf_prog, (u_char *)m, totlen, 0); - if (needfree) - free(data, M_NETGRAPH_BPF); + ready: /* See if we got a match and find destination hook */ if (len > 0) {