Revert the previous commit and use M_PROMISC flag instead.
It is safer because it will never be used for outgoing packets.
This commit is contained in:
parent
22cc9ba0f0
commit
8cd892f752
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178223
@ -841,6 +841,9 @@ bpfwrite(struct cdev *dev, struct uio *uio, int ioflag)
|
||||
mc = m_dup(m, M_DONTWAIT);
|
||||
if (mc != NULL)
|
||||
mc->m_pkthdr.rcvif = ifp;
|
||||
/* Set M_PROMISC for outgoing packets to be discarded. */
|
||||
if (d->bd_direction == BPF_D_INOUT)
|
||||
m->m_flags |= M_PROMISC;
|
||||
} else
|
||||
mc = NULL;
|
||||
|
||||
@ -1571,9 +1574,6 @@ bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen)
|
||||
#define BPF_CHECK_DIRECTION(d, i) \
|
||||
(((d)->bd_direction == BPF_D_IN && (i) == NULL) || \
|
||||
((d)->bd_direction == BPF_D_OUT && (i) != NULL))
|
||||
#define BPF_CHECK_DUPLICATE(d, i) \
|
||||
((d)->bd_feedback && \
|
||||
(d)->bd_direction == BPF_D_INOUT && (i) == NULL)
|
||||
|
||||
/*
|
||||
* Incoming linkage from device drivers, when packet is in an mbuf chain.
|
||||
@ -1586,14 +1586,19 @@ bpf_mtap(struct bpf_if *bp, struct mbuf *m)
|
||||
int gottime;
|
||||
struct timeval tv;
|
||||
|
||||
/* Skip outgoing duplicate packets. */
|
||||
if ((m->m_flags & M_PROMISC) != 0 && m->m_pkthdr.rcvif == NULL) {
|
||||
m->m_flags &= ~M_PROMISC;
|
||||
return;
|
||||
}
|
||||
|
||||
gottime = 0;
|
||||
|
||||
pktlen = m_length(m, NULL);
|
||||
|
||||
BPFIF_LOCK(bp);
|
||||
LIST_FOREACH(d, &bp->bif_dlist, bd_next) {
|
||||
if (BPF_CHECK_DIRECTION(d, m->m_pkthdr.rcvif) ||
|
||||
BPF_CHECK_DUPLICATE(d, m->m_pkthdr.rcvif))
|
||||
if (BPF_CHECK_DIRECTION(d, m->m_pkthdr.rcvif))
|
||||
continue;
|
||||
BPFD_LOCK(d);
|
||||
++d->bd_rcount;
|
||||
@ -1636,6 +1641,12 @@ bpf_mtap2(struct bpf_if *bp, void *data, u_int dlen, struct mbuf *m)
|
||||
int gottime;
|
||||
struct timeval tv;
|
||||
|
||||
/* Skip outgoing duplicate packets. */
|
||||
if ((m->m_flags & M_PROMISC) != 0 && m->m_pkthdr.rcvif == NULL) {
|
||||
m->m_flags &= ~M_PROMISC;
|
||||
return;
|
||||
}
|
||||
|
||||
gottime = 0;
|
||||
|
||||
pktlen = m_length(m, NULL);
|
||||
@ -1651,8 +1662,7 @@ bpf_mtap2(struct bpf_if *bp, void *data, u_int dlen, struct mbuf *m)
|
||||
|
||||
BPFIF_LOCK(bp);
|
||||
LIST_FOREACH(d, &bp->bif_dlist, bd_next) {
|
||||
if (BPF_CHECK_DIRECTION(d, m->m_pkthdr.rcvif) ||
|
||||
BPF_CHECK_DUPLICATE(d, m->m_pkthdr.rcvif))
|
||||
if (BPF_CHECK_DIRECTION(d, m->m_pkthdr.rcvif))
|
||||
continue;
|
||||
BPFD_LOCK(d);
|
||||
++d->bd_rcount;
|
||||
@ -1675,7 +1685,6 @@ bpf_mtap2(struct bpf_if *bp, void *data, u_int dlen, struct mbuf *m)
|
||||
}
|
||||
|
||||
#undef BPF_CHECK_DIRECTION
|
||||
#undef BPF_CHECK_DUPLICATE
|
||||
|
||||
/*
|
||||
* Move the packet data from interface memory (pkt) into the
|
||||
|
Loading…
Reference in New Issue
Block a user