summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2013-11-11 03:06:43 +0000
committerdlg <dlg@openbsd.org>2013-11-11 03:06:43 +0000
commita155e548dd14596e44fc6d1bce65f5f4f2039c98 (patch)
tree1fb45e6907bbcfe11ec00ab1957314363218fbcb /sys
parentreplace disksort with bufqs. (diff)
downloadwireguard-openbsd-a155e548dd14596e44fc6d1bce65f5f4f2039c98.tar.xz
wireguard-openbsd-a155e548dd14596e44fc6d1bce65f5f4f2039c98.zip
replace the user of ticks in a condition like "interval + start < ticks"
with "ticks - start > interval" because the latter copes with the ticks value wrapping. pointed out by guenther@ ok krw@
Diffstat (limited to 'sys')
-rw-r--r--sys/net/bpf.c15
-rw-r--r--sys/net/bpfdesc.h6
2 files changed, 9 insertions, 12 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index e01f3faf08d..f11ebb014a8 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.83 2012/12/28 17:52:06 gsoares Exp $ */
+/* $OpenBSD: bpf.c,v 1.84 2013/11/11 03:06:43 dlg Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -1420,19 +1420,16 @@ bpf_catchpacket(struct bpf_d *d, u_char *pkt, size_t pktlen, size_t snaplen,
* reads should be woken up.
*/
bpf_wakeup(d);
- }
-
- if (d->bd_rdStart && (d->bd_rtout + d->bd_rdStart < ticks)) {
+ } else if (d->bd_fbuf && d->bd_rdStart &&
+ (ticks - d->bd_rdStart > d->bd_rtout)) {
/*
* we could be selecting on the bpf, and we
* may have timeouts set. We got here by getting
* a packet, so wake up the reader.
*/
- if (d->bd_fbuf) {
- d->bd_rdStart = 0;
- ROTATE_BUFFERS(d);
- bpf_wakeup(d);
- }
+ d->bd_rdStart = 0;
+ ROTATE_BUFFERS(d);
+ bpf_wakeup(d);
}
}
diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h
index ff5cc0ea77a..6ab7f053963 100644
--- a/sys/net/bpfdesc.h
+++ b/sys/net/bpfdesc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpfdesc.h,v 1.18 2013/10/24 11:14:33 deraadt Exp $ */
+/* $OpenBSD: bpfdesc.h,v 1.19 2013/11/11 03:06:43 dlg Exp $ */
/* $NetBSD: bpfdesc.h,v 1.11 1995/09/27 18:30:42 thorpej Exp $ */
/*
@@ -67,8 +67,8 @@ struct bpf_d {
int bd_bufsize; /* absolute length of buffers */
struct bpf_if * bd_bif; /* interface descriptor */
- u_long bd_rtout; /* Read timeout in 'ticks' */
- u_long bd_rdStart; /* when the read started */
+ int bd_rtout; /* Read timeout in 'ticks' */
+ int bd_rdStart; /* when the read started */
struct bpf_insn *bd_rfilter; /* read filter code */
struct bpf_insn *bd_wfilter; /* write filter code */
u_long bd_rcount; /* number of packets received */