BIOCSSEESENT ioctl not honoured for single-mbuf packets

Ed Maste emaste at phaedrus.sandvine.ca
Wed Aug 31 19:59:47 GMT 2005


A coworker of mine discovered a bug in bpf with BIOCSEESENT.
In sys/net/bpf.c, bpf_mtap() does

        if (pktlen == m->m_len) {
                bpf_tap(bp, mtod(m, u_char *), pktlen);
                return;
        }

        BPFIF_LOCK(bp);
        LIST_FOREACH(d, &bp->bif_dlist, bd_next) {
                if (!d->bd_seesent && (m->m_pkthdr.rcvif == NULL))
                        continue;
        [...]

The pktlen == m->m_len is an optimization for the case where
the entire packet is in a single mbuf, added in version 1.95.
However, bd_seesent then isn't checked so all packets will be
seen.

In order to make bpf_tap work correctly with BIOCSEESENT for
both this case and the few drivers that use it, I think it needs
another argument to indicate if the packet is being sent or not.
Is it possible to change the API for bpf_tap?  Or add a bpf_tap2
that includes the flag, and make bpf_tap call it (for any third
party drivers using bpf_tap)?

--
Ed Maste
Sandvine Incorporated


More information about the freebsd-net mailing list