[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/19] net: make tap_receive() re-use tap_receive_io
From: |
Mark McLoughlin |
Subject: |
[Qemu-devel] [PATCH 03/19] net: make tap_receive() re-use tap_receive_iov() code |
Date: |
Wed, 21 Oct 2009 12:27:42 +0100 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH 00/19], Mark McLoughlin, 2009/10/21
- [Qemu-devel] [PATCH 03/19] net: make tap_receive() re-use tap_receive_iov() code,
Mark McLoughlin <=
- [Qemu-devel] [PATCH 01/19] net: remove unused includes of if_tun.h and if_tap.h, Mark McLoughlin, 2009/10/21
- [Qemu-devel] [PATCH 08/19] net: add tap_has_vnet_hdr() and tap_using_vnet_hdr() APIs, Mark McLoughlin, 2009/10/21
- [Qemu-devel] [PATCH 04/19] net: enable IFF_VNET_HDR on tap fds if available, Mark McLoughlin, 2009/10/21
- [Qemu-devel] [PATCH 02/19] net: import linux tap ioctl definitions, Mark McLoughlin, 2009/10/21
- [Qemu-devel] [PATCH 06/19] net: add a vnet_hdr=on|off parameter, Mark McLoughlin, 2009/10/21
- [Qemu-devel] [PATCH 07/19] net: add a client type code, Mark McLoughlin, 2009/10/21
- [Qemu-devel] [PATCH 13/19] net: implement tap support for receive_raw(), Mark McLoughlin, 2009/10/21
- [Qemu-devel] [PATCH 05/19] net: refactor tap initialization, Mark McLoughlin, 2009/10/21
- [Qemu-devel] [PATCH 15/19] net: add tap_set_offload(), Mark McLoughlin, 2009/10/21
- [Qemu-devel] [PATCH 14/19] virtio-net: add vnet_hdr support, Mark McLoughlin, 2009/10/21