Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Mar 2004 13:00:29 -0800 (PST)
From:      Ed Maste <emaste@sandvine.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/64718: [patch] Bridged packets still seen by BPF listener after BIOCSEESENT ioctl.
Message-ID:  <200403292100.i2TL0Tx4001298@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/64718; it has been noted by GNATS.

From: Ed Maste <emaste@sandvine.com>
To: freebsd-gnats-submit@FreeBSD.org, emaste@sandvine.com
Cc:  
Subject: Re: kern/64718: [patch] Bridged packets still seen by BPF listener
 after BIOCSEESENT ioctl.
Date: Mon, 29 Mar 2004 15:59:15 -0500

 Here's a better patch for this issue.  This was actually my first
 idea, but it didn't work due to a bug in ether_input and bpf_mtap.
 
 ether_input creates an m_hdr on the stack to put back the ether
 header for bpf_mtap.  It then casts this to a struct mbuf *. 
 However, it doesn't set mh_flags.  In the non-seesent case, bpf_mtap
 checks m->m_pkthdr.rcvif, but that's not valid on the passed in
 "mbuf."  Clearing mh_flags before calling bpf_mtap fixed this issue.
 
 Here's my new patches:
 
 --- if_ethersubr.c.orig     2004-02-05 12:33:44.000000000 -0500
 +++ if_ethersubr.c      2004-03-29 14:36:20.000000000 -0500
 @@ -599,6 +599,7 @@
                 struct m_hdr mh;
  
                 /* This kludge is OK; BPF treats the "mbuf" as read-only */
 +                mh.mh_flags = 0;
                 mh.mh_next = m;
                 mh.mh_data = (char *)eh;
                 mh.mh_len = ETHER_HDR_LEN;
 
 
 --- bpf.c.orig       2004-03-04 12:34:26.000000000 -0500
 +++ bpf.c       2004-03-29 15:09:45.000000000 -0500
 @@ -1249,8 +1249,14 @@
                 pktlen += m0->m_len;
  
         for (d = bp->bif_dlist; d != 0; d = d->bd_next) {
 -               if (!d->bd_seesent && (m->m_pkthdr.rcvif == NULL))
 -                       continue;
 +               if (!d->bd_seesent) {
 +                        for (m0 = m; m0 != 0; m0 = m0->m_next)
 +                                if (m0->m_flags & M_PKTHDR)
 +                                        break;
 +                        if (m0 && m0->m_pkthdr.rcvif != ifp)
 +                               continue;
 +                }
                 ++d->bd_rcount;
                 slen = bpf_filter(d->bd_filter, (u_char *)m, pktlen, 0);
                 if (slen != 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403292100.i2TL0Tx4001298>