kern/56441 - bpf_tap() used incorrectly in bpf
Darren Reed
darrenr at reed.wattle.id.au
Sat Apr 10 16:48:43 PDT 2004
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);
More information about the freebsd-bugs
mailing list