diff options
author | mav <mav@FreeBSD.org> | 2015-05-04 19:33:51 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2015-05-04 19:33:51 +0000 |
commit | 0da2a8acdea0c8ad4249795ea7e35a89a6bb3e68 (patch) | |
tree | 5b7671cb6cb413e213a46dbda0e919b71155561d /sys/net/bpf.c | |
parent | e55c1de2760b573c3ebc54b2c3cadf2e6fe51dd3 (diff) | |
download | FreeBSD-src-0da2a8acdea0c8ad4249795ea7e35a89a6bb3e68.zip FreeBSD-src-0da2a8acdea0c8ad4249795ea7e35a89a6bb3e68.tar.gz |
MFC r281765:
Activate write-only optimization if bpf device opened with O_WRONLY.
dhclient opens bpf as write-only to send packets. It never reads received
packets from that descriptor, but processing them in kernel takes time.
Especially much time takes packet timestamping on systems with expensive
timecounter, such as bhyve guest, where network speed dropped in half.
Sponsored by: iXsystems, Inc.
Diffstat (limited to 'sys/net/bpf.c')
-rw-r--r-- | sys/net/bpf.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 93929da..c73fbd3 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -600,7 +600,7 @@ bpf_attachd(struct bpf_d *d, struct bpf_if *bp) * Save sysctl value to protect from sysctl change * between reads */ - op_w = V_bpf_optimize_writers; + op_w = V_bpf_optimize_writers || d->bd_writer; if (d->bd_bif != NULL) bpf_detachd_locked(d); @@ -802,6 +802,8 @@ bpfopen(struct cdev *dev, int flags, int fmt, struct thread *td) * particular buffer method. */ bpf_buffer_init(d); + if ((flags & FREAD) == 0) + d->bd_writer = 2; d->bd_hbuf_in_use = 0; d->bd_bufmode = BPF_BUFMODE_BUFFER; d->bd_sig = SIGIO; |