Add a new ioctl for changing the read filter (BIOCSETFNR). This is

just like BIOCSETF but it doesn't drop all the packets buffered on
the discriptor and reset the statistics.

Also, when setting the write filter, don't drop packets waiting to
be read or reset the statistics.

PR:		118486
Submitted by:	Matthew Luckie <mluckie@cs.waikato.ac.nz>
MFC after:	1 month
This commit is contained in:
David Malone 2008-07-07 09:25:49 +00:00
parent e1a32fd42b
commit f11c35082b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=180337
2 changed files with 9 additions and 4 deletions

View File

@ -927,8 +927,9 @@ reset_d(struct bpf_d *d)
* FIONREAD Check for read packet available.
* SIOCGIFADDR Get interface address - convenient hook to driver.
* BIOCGBLEN Get buffer len [for read()].
* BIOCSETF Set ethernet read filter.
* BIOCSETWF Set ethernet write filter.
* BIOCSETF Set read filter.
* BIOCSETFNR Set read filter without resetting descriptor.
* BIOCSETWF Set write filter.
* BIOCFLUSH Flush read packet buffer.
* BIOCPROMISC Put interface into promiscuous mode.
* BIOCGDLT Get link layer type.
@ -1047,6 +1048,7 @@ bpfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
* Set link layer read filter.
*/
case BIOCSETF:
case BIOCSETFNR:
case BIOCSETWF:
error = bpf_setf(d, (struct bpf_program *)addr, cmd);
break;
@ -1361,8 +1363,9 @@ bpf_setf(struct bpf_d *d, struct bpf_program *fp, u_long cmd)
#ifdef BPF_JITTER
d->bd_bfilter = NULL;
#endif
if (cmd == BIOCSETF)
reset_d(d);
}
reset_d(d);
BPFD_UNLOCK(d);
if (old != NULL)
free((caddr_t)old, M_BPF);
@ -1388,8 +1391,9 @@ bpf_setf(struct bpf_d *d, struct bpf_program *fp, u_long cmd)
#ifdef BPF_JITTER
d->bd_bfilter = bpf_jitter(fcode, flen);
#endif
if (cmd == BIOCSETF)
reset_d(d);
}
reset_d(d);
BPFD_UNLOCK(d);
if (old != NULL)
free((caddr_t)old, M_BPF);

View File

@ -142,6 +142,7 @@ struct bpf_zbuf {
#define BIOCGETZMAX _IOR('B',127, size_t)
#define BIOCROTZBUF _IOR('B',128, struct bpf_zbuf)
#define BIOCSETZBUF _IOW('B',129, struct bpf_zbuf)
#define BIOCSETFNR _IOW('B',130, struct bpf_program)
/* Obsolete */
#define BIOCGSEESENT BIOCGDIRECTION