From owner-freebsd-bugs@FreeBSD.ORG Sat Apr 10 16:48:42 2004 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D8A1C16A4CE for ; Sat, 10 Apr 2004 16:48:42 -0700 (PDT) Received: from mail.iinet.net.au (mail-04.iinet.net.au [203.59.3.36]) by mx1.FreeBSD.org (Postfix) with SMTP id E50B743D39 for ; Sat, 10 Apr 2004 16:48:40 -0700 (PDT) (envelope-from darrenr@reed.wattle.id.au) Received: (qmail 11555 invoked from network); 10 Apr 2004 23:45:45 -0000 Received: from unknown (HELO firewall.reed.wattle.id.au) (203.217.34.157) by mail.iinet.net.au with SMTP; 10 Apr 2004 23:45:45 -0000 Received: (from root@localhost) by firewall.reed.wattle.id.au (8.11.0/8.11.0) id i3ANjoe05555; Sun, 11 Apr 2004 09:45:50 +1000 (EST) From: Darren Reed Message-Id: <200404102345.JAA02555@avalon.reed.wattle.id.au> To: andre@freebsd.org, vys@renet.ru Date: Sun, 11 Apr 2004 09:45:23 +1000 (EST) X-Mailer: ELM [version 2.4ME+ PL99d (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII cc: freebsd-bugs@freebsd.org Subject: kern/56441 - bpf_tap() used incorrectly in bpf X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Apr 2004 23:48:43 -0000 Andre, The patch below should resolve this PR. It modifies the behaviour of bpf_mtap() in a manner that resembles bpf_tap(), providing the speed "boost", whilst preserving the application of "seesent". Darren Index: bpf.c =================================================================== RCS file: /home/ncvs/src/sys/net/bpf.c,v retrieving revision 1.125 diff -c -r1.125 bpf.c *** bpf.c 7 Apr 2004 20:46:11 -0000 1.125 --- bpf.c 10 Apr 2004 23:38:02 -0000 *************** *** 1197,1209 **** struct bpf_if *bp; struct mbuf *m; { struct bpf_d *d; ! u_int pktlen, slen; pktlen = m_length(m, NULL); if (pktlen == m->m_len) { ! bpf_tap(bp, mtod(m, u_char *), pktlen); ! return; } BPFIF_LOCK(bp); --- 1197,1216 ---- struct bpf_if *bp; struct mbuf *m; { + void *(*cpfn) __P((void *, const void *, size_t)); + u_int pktlen, slen, buflen; struct bpf_d *d; ! void *marg; pktlen = m_length(m, NULL); if (pktlen == m->m_len) { ! cpfn = bcopy; ! marg = mtod(m, void *); ! buflen = pktlen; ! } else { ! cpfn = bpf_mcopy; ! marg = m; ! buflen = 0; } BPFIF_LOCK(bp); *************** *** 1212,1224 **** continue; BPFD_LOCK(d); ++d->bd_rcount; ! slen = bpf_filter(d->bd_filter, (u_char *)m, pktlen, 0); if (slen != 0) #ifdef MAC if (mac_check_bpfdesc_receive(d, bp->bif_ifp) == 0) #endif ! catchpacket(d, (u_char *)m, pktlen, slen, ! bpf_mcopy); BPFD_UNLOCK(d); } BPFIF_UNLOCK(bp); --- 1219,1230 ---- continue; BPFD_LOCK(d); ++d->bd_rcount; ! slen = bpf_filter(d->bd_filter, marg, pktlen, buflen); if (slen != 0) #ifdef MAC if (mac_check_bpfdesc_receive(d, bp->bif_ifp) == 0) #endif ! catchpacket(d, (u_char *)m, pktlen, slen, cpfn); BPFD_UNLOCK(d); } BPFIF_UNLOCK(bp);