diff --git a/sys/rump/net/lib/libvirtif/if_virt.c b/sys/rump/net/lib/libvirtif/if_virt.c index 86aee7c0d699..9a5cf7bdfabd 100644 --- a/sys/rump/net/lib/libvirtif/if_virt.c +++ b/sys/rump/net/lib/libvirtif/if_virt.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_virt.c,v 1.18 2010/04/05 16:35:30 joerg Exp $ */ +/* $NetBSD: if_virt.c,v 1.19 2010/08/10 18:06:10 pooka Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.18 2010/04/05 16:35:30 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.19 2010/08/10 18:06:10 pooka Exp $"); #include #include @@ -110,7 +110,8 @@ rump_virtif_create(int num) snprintf(tapdev, sizeof(tapdev), "/dev/tap%d", num); fd = rumpuser_open(tapdev, O_RDWR, &error); if (fd == -1) { - printf("virtif_create: can't open /dev/tap %d\n", error); + printf("virtif_create: can't open /dev/tap%d: %d\n", + num, error); return error; } KASSERT(num < 0x100); @@ -212,7 +213,7 @@ virtif_worker(void *arg) again: n = rumpuser_read(sc->sc_tapfd, mtod(m, void *), plen, &error); KASSERT(n < ETHER_MAX_LEN_JUMBO); - if (n <= 0) { + if (__predict_false(n < 0)) { /* * work around tap bug: /dev/tap is opened in * non-blocking mode if it previously was @@ -227,9 +228,15 @@ virtif_worker(void *arg) rumpuser_poll(&pfd, 1, INFTIM, &error); goto again; } + m_freem(m); break; } + + /* tap sometimes returns EOF. don't sweat it and plow on */ + if (__predict_false(n == 0)) + goto again; + m->m_len = m->m_pkthdr.len = n; m->m_pkthdr.rcvif = ifp; bpf_mtap(ifp, m);