On Fri, 4 Dec 2015, Todd C. Miller wrote: > On Fri, 04 Dec 2015 09:47:46 -0800, Philip Guenther wrote: > > We should fix open(2); please try the diff below. Are you sure pppx > > is affected? pppxioctl()'s FIONBIO case appears to be a no-op. I > > certainly agree that bpf and tun are affected. > > Shouldn't the device open function check for FNONBLOCK and handle > it as needed?
Finally got back to this; this diff should fix open(O_NONBLOCK) of bpf, tun, and tap devices. The bikeshed question is whether this should use O_NONBLOCK or FNONBLOCK... ok? Index: net/bpf.c =================================================================== RCS file: /data/src/openbsd/src/sys/net/bpf.c,v retrieving revision 1.131 diff -u -p -r1.131 bpf.c --- net/bpf.c 5 Dec 2015 10:07:55 -0000 1.131 +++ net/bpf.c 1 Jan 2016 18:47:42 -0000 @@ -341,6 +341,9 @@ bpfopen(dev_t dev, int flag, int mode, s d->bd_bufsize = bpf_bufsize; d->bd_sig = SIGIO; + if (flag & O_NONBLOCK) + d->bd_rtout = -1; + D_GET(d); return (0); Index: net/if_tun.c =================================================================== RCS file: /data/src/openbsd/src/sys/net/if_tun.c,v retrieving revision 1.164 diff -u -p -r1.164 if_tun.c --- net/if_tun.c 5 Dec 2015 16:09:09 -0000 1.164 +++ net/if_tun.c 1 Jan 2016 18:47:30 -0000 @@ -361,6 +361,8 @@ tun_dev_open(struct tun_softc *tp, int f ifp = &tp->tun_if; tp->tun_flags |= TUN_OPEN; + if (flag & O_NONBLOCK) + tp->tun_flags |= TUN_NBIO; /* automatically mark the interface running on open */ s = splnet();