* improve diagnostic print

* deal with a tap quirk when it returns 0 bytes
This commit is contained in:
pooka 2010-08-10 18:06:10 +00:00
parent 2dcdd0a999
commit 8a20e6b473
1 changed files with 11 additions and 4 deletions

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/condvar.h>
@ -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);