Module Name: src
Committed By: pooka
Date: Wed Sep 16 13:29:42 UTC 2009
Modified Files:
src/sys/rump/net/lib/libvirtif: if_virt.c
Log Message:
work around tap bug: if /dev/tap<n> was previously non-blocking, newly
opened fd's will also be non-blocking.
(yeayea, i'll fix the kernel some day, but I don't want to reboot
my host OS now)
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/rump/net/lib/libvirtif/if_virt.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.10 src/sys/rump/net/lib/libvirtif/if_virt.c:1.11
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.10 Wed May 27 23:41:20 2009
+++ src/sys/rump/net/lib/libvirtif/if_virt.c Wed Sep 16 13:29:42 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: if_virt.c,v 1.10 2009/05/27 23:41:20 pooka Exp $ */
+/* $NetBSD: if_virt.c,v 1.11 2009/09/16 13:29:42 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.10 2009/05/27 23:41:20 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.11 2009/09/16 13:29:42 pooka Exp $");
#include <sys/param.h>
#include <sys/condvar.h>
@@ -34,6 +34,7 @@
#include <sys/kmem.h>
#include <sys/kthread.h>
#include <sys/mutex.h>
+#include <sys/poll.h>
#include <sys/sockio.h>
#include <sys/socketvar.h>
@@ -207,9 +208,24 @@
m = m_gethdr(M_WAIT, MT_DATA);
MEXTMALLOC(m, plen, M_WAIT);
+ again:
n = rumpuser_read(sc->sc_tapfd, mtod(m, void *), plen, &error);
KASSERT(n < ETHER_MAX_LEN_JUMBO);
if (n <= 0) {
+ /*
+ * work around tap bug: /dev/tap is opened in
+ * non-blocking mode if it previously was
+ * non-blocking.
+ */
+ if (n == -1 && error == EAGAIN) {
+ struct pollfd pfd;
+
+ pfd.fd = sc->sc_tapfd;
+ pfd.events = POLLIN;
+
+ rumpuser_poll(&pfd, 1, INFTIM, &error);
+ goto again;
+ }
m_freem(m);
break;
}