Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Nov 2002 14:13:59 +0100
From:      Fabien THOMAS <fabien.thomas@netasq.com>
To:        freebsd-net@freebsd.org
Subject:   bpf_tap problem with PKTHDR
Message-ID:  <127338536921.20021126141359@netasq.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hi,

It seems there is a problem in the bpf_mtap code:

Actually the code assume in the seesent case that mbuf will have a pkthdr structure.

There is 2 problems here:
      + they did not check for that with (m_flag & M_PKTHDR)
      + at the upper level the caller forge fake mbuf that did not
      contain any pkthdr and did not initialize the m_flags field

what do you think about that ?
      
if_ethersubr.c case:

        /* Check for a BPF tap */
        if (ifp->if_bpf != NULL) {
                struct m_hdr mh;

                /* This kludge is OK; BPF treats the "mbuf" as read-only */
                mh.mh_next = m;
                mh.mh_data = (char *)eh;
                mh.mh_len = ETHER_HDR_LEN;
                bpf_mtap(ifp, (struct mbuf *)&mh);
        }


bpf_mtap function:
/*
 * Incoming linkage from device drivers, when packet is in an mbuf chain.
 */
void
bpf_mtap(ifp, m)
        struct ifnet *ifp;
        struct mbuf *m;
{
        struct bpf_if *bp = ifp->if_bpf;
        struct bpf_d *d;
        u_int pktlen, slen;
        struct mbuf *m0;

        pktlen = 0;
        for (m0 = m; m0 != 0; m0 = m0->m_next)
                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;
                ++d->bd_rcount;
                slen = bpf_filter(d->bd_filter, (u_char *)m, pktlen, 0);
                if (slen != 0)
                        catchpacket(d, (u_char *)m, pktlen, slen, bpf_mcopy);
        }
}

fabien

[-- Attachment #2 --]
0F	*H
70310	+0	*H
q0m0U0
	*H
010	UFR1
0UNord10UVilleneuve d'Ascq1.0,U
%NETASQ - Secure Internet Connectivity1'0%UNETASQ Certification Authority0
020219144844Z
030219144844Z010	UFR1
0UNord10UVilleneuve d'Ascq1.0,U
%NetAsq - Secure Internet Connectivity1'0%UNetAsq Certification Authority10U
Fabien THOMAS1'0%	*H
	fabien.thomas@netasq.com00
	*H
0f7#ŃfVO"tAw
(M9zȅU\A|?,QUOH<RN6YՉMTld4{dr{nkiӭ=qJslzi8d/s00	U00U0UD48\`C5G!E0U#0'*D:sj	  %010	UFR1
0UNord10UVilleneuve d'Ascq1.0,U
%NETASQ - Secure Internet Connectivity1'0%UNETASQ Certification Authority0	`HB0
	*H
DG	ddʛ[ʾ+|r$͐C+W	m8f@Z<DF)pͶt*_.{i¤+I3uNWa@Ju dmx1)1F(fs#Ы
6g)($\-isDuF94Dd7hj/iqfFS=J>R{V3X=D]NH~op.SJ.e^~ƒoMF100010	UFR1
0UNord10UVilleneuve d'Ascq1.0,U
%NETASQ - Secure Internet Connectivity1'0%UNETASQ Certification Authority0	+]0	*H
	1	*H
0#	*H
	1$%:olXV.0	*H
	1
021126131359Z0
	*H
mmo/
ϴby&&h~5
ݟ()
>eCؖF9U:EP_LU
63~>QՊ=R++.WA|<w*Un7n

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