summaryrefslogtreecommitdiffstats
path: root/sys/net/bpf.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2000-03-18 06:30:42 +0000
committerrwatson <rwatson@FreeBSD.org>2000-03-18 06:30:42 +0000
commit7432002de6b5ecd51d01bb7e91819ee6347ea6f3 (patch)
treeef6052ed707bd0c402ea6479889593ef5f2ce159 /sys/net/bpf.c
parent5f00c83601ca3aad8d17dffa0fdc389fb61599d1 (diff)
downloadFreeBSD-src-7432002de6b5ecd51d01bb7e91819ee6347ea6f3.zip
FreeBSD-src-7432002de6b5ecd51d01bb7e91819ee6347ea6f3.tar.gz
Introduce a new bd_seesent flag to the BPF descriptor, indicating whether or
not the current BPF device should report locally generated packets or not. This allows sniffing applications to see only packets that are not generated locally, which can be useful for debugging bridging problems, or other situations where MAC addresses are not sufficient to identify locally sourced packets. Default to true for this flag, so as to provide existing behavior by default. Introduce two new ioctls, BIOCGSEESENT and BIOCSSEESENT, which may be used to manipulate this flag from userland, given appropriate privilege. Modify bpf.4 to document these two new ioctl arguments. Reviewed by: asmodai
Diffstat (limited to 'sys/net/bpf.c')
-rw-r--r--sys/net/bpf.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index d75013e..466227c 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -359,6 +359,7 @@ bpfopen(dev, flags, fmt, p)
dev->si_drv1 = d;
d->bd_bufsize = bpf_bufsize;
d->bd_sig = SIGIO;
+ d->bd_seesent = 1;
return (0);
}
@@ -633,6 +634,8 @@ reset_d(d)
* BIOCVERSION Get filter language version.
* BIOCGHDRCMPLT Get "header already complete" flag
* BIOCSHDRCMPLT Set "header already complete" flag
+ * BIOCGSEESENT Get "see packets sent" flag
+ * BIOCSSEESENT Set "see packets sent" flag
*/
/* ARGSUSED */
static int
@@ -848,6 +851,20 @@ bpfioctl(dev, cmd, addr, flags, p)
d->bd_hdrcmplt = *(u_int *)addr ? 1 : 0;
break;
+ /*
+ * Get "see sent packets" flag
+ */
+ case BIOCGSEESENT:
+ *(u_int *)addr = d->bd_seesent;
+ break;
+
+ /*
+ * Set "see sent packets" flag
+ */
+ case BIOCSSEESENT:
+ d->bd_seesent = *(u_int *)addr;
+ break;
+
case FIONBIO: /* Non-blocking I/O */
break;
@@ -1103,6 +1120,8 @@ bpf_mtap(ifp, m)
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)
OpenPOWER on IntegriCloud