From owner-freebsd-bugs@FreeBSD.ORG Mon Mar 29 13:00:31 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D79E116A4CE for ; Mon, 29 Mar 2004 13:00:31 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D030943D41 for ; Mon, 29 Mar 2004 13:00:30 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i2TL0Tbv001299 for ; Mon, 29 Mar 2004 13:00:29 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i2TL0Tx4001298; Mon, 29 Mar 2004 13:00:29 -0800 (PST) (envelope-from gnats) Date: Mon, 29 Mar 2004 13:00:29 -0800 (PST) Message-Id: <200403292100.i2TL0Tx4001298@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Ed Maste Subject: Re: kern/64718: [patch] Bridged packets still seen by BPF listener after BIOCSEESENT ioctl. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Ed Maste List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Mar 2004 21:00:32 -0000 The following reply was made to PR kern/64718; it has been noted by GNATS. From: Ed Maste 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)