From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N10nW-0007Fs-1S for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:45:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N10nL-0006zi-Jh for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:45:52 -0400 Received: from [199.232.76.173] (port=47952 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N10nL-0006yu-1t for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:45:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32593) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N10nJ-0003FS-3a for qemu-devel@nongnu.org; Thu, 22 Oct 2009 12:45:45 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9MGjhNP008430 for ; Thu, 22 Oct 2009 12:45:43 -0400 From: Mark McLoughlin Date: Thu, 22 Oct 2009 17:43:34 +0100 Message-Id: <1256229830-28066-4-git-send-email-markmc@redhat.com> In-Reply-To: <1256229830-28066-1-git-send-email-markmc@redhat.com> References: <1256229830-28066-1-git-send-email-markmc@redhat.com> Subject: [Qemu-devel] [PATCH 03/19] net: make tap_receive() re-use tap_receive_iov() code List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Mark McLoughlin In future we will want to prepend a virtio_net header if the NIC didn't supply one but IFF_VNET_HDR is enabled on the interface. This is most easily achived by using writev() in all cases. Signed-off-by: Mark McLoughlin --- net.c | 23 +++++++++++++++-------- 1 files changed, 15 insertions(+), 8 deletions(-) diff --git a/net.c b/net.c index 0e3388b..728941a 100644 --- a/net.c +++ b/net.c @@ -1291,10 +1291,8 @@ static void tap_writable(void *opaque) qemu_flush_queued_packets(s->vc); } -static ssize_t tap_receive_iov(VLANClientState *vc, const struct iovec *iov, - int iovcnt) +static ssize_t tap_write_packet(TAPState *s, const struct iovec *iov, int iovcnt) { - TAPState *s = vc->opaque; ssize_t len; do { @@ -1309,16 +1307,25 @@ static ssize_t tap_receive_iov(VLANClientState *vc, const struct iovec *iov, return len; } +static ssize_t tap_receive_iov(VLANClientState *vc, const struct iovec *iov, + int iovcnt) +{ + TAPState *s = vc->opaque; + + return tap_write_packet(s, iov, iovcnt); +} + static ssize_t tap_receive(VLANClientState *vc, const uint8_t *buf, size_t size) { TAPState *s = vc->opaque; - ssize_t len; + struct iovec iov[1]; + int iovcnt = 0; - do { - len = write(s->fd, buf, size); - } while (len == -1 && (errno == EINTR || errno == EAGAIN)); + iov[iovcnt].iov_base = (char *)buf; + iov[iovcnt].iov_len = size; + iovcnt++; - return len; + return tap_write_packet(s, iov, iovcnt); } static int tap_can_send(void *opaque) -- 1.6.2.5