diff options
author | 2016-01-07 05:31:17 +0000 | |
---|---|---|
committer | 2016-01-07 05:31:17 +0000 | |
commit | 60cecb24293b1d864085ffaa182899ccf4551c02 (patch) | |
tree | 015e132374b4015ed2468dba4994d3cc0cb2b99d | |
parent | Handle receive queue full condition instead of hanging.This can be (diff) | |
download | wireguard-openbsd-60cecb24293b1d864085ffaa182899ccf4551c02.tar.xz wireguard-openbsd-60cecb24293b1d864085ffaa182899ccf4551c02.zip |
Make open(O_NONBLOCK) of tun, tap, and bpf behave like open+ioctl(FIONBIO)
problem noted by yasuoka@
ok yasuoka@ millert@
-rw-r--r-- | sys/net/bpf.c | 5 | ||||
-rw-r--r-- | sys/net/if_tun.c | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 86f5f6db879..167c5fe86c8 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.131 2015/12/05 10:07:55 tedu Exp $ */ +/* $OpenBSD: bpf.c,v 1.132 2016/01/07 05:31:17 guenther Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -341,6 +341,9 @@ bpfopen(dev_t dev, int flag, int mode, struct proc *p) d->bd_bufsize = bpf_bufsize; d->bd_sig = SIGIO; + if (flag & FNONBLOCK) + d->bd_rtout = -1; + D_GET(d); return (0); diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index efda8b2cae9..afa6b3d1bcd 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.164 2015/12/05 16:09:09 yasuoka Exp $ */ +/* $OpenBSD: if_tun.c,v 1.165 2016/01/07 05:31:17 guenther Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -361,6 +361,8 @@ tun_dev_open(struct tun_softc *tp, int flag, int mode, struct proc *p) ifp = &tp->tun_if; tp->tun_flags |= TUN_OPEN; + if (flag & FNONBLOCK) + tp->tun_flags |= TUN_NBIO; /* automatically mark the interface running on open */ s = splnet(); |