From 0cf196355aaefa7f29bc6456fca461e1c83c3926 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Tue, 13 May 2008 14:13:39 -0500 Subject: [PATCH] Add fd_readv handler to tap This allows fragmented packets to be sent with no additional copies over the tap interface. Signed-off-by: Anthony Liguori Signed-off-by: Avi Kivity --- vl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vl.c b/vl.c index 1f0a6ac6a3..7900b76748 100644 --- a/vl.c +++ b/vl.c @@ -4086,6 +4086,19 @@ static void tap_receive(void *opaque, const uint8_t *buf, int size) } } +static ssize_t tap_readv(void *opaque, const struct iovec *iov, + int iovcnt) +{ + TAPState *s = opaque; + ssize_t len; + + do { + len = writev(s->fd, iov, iovcnt); + } while (len == -1 && (errno == EINTR || errno == EAGAIN)); + + return len; +} + static void tap_send(void *opaque) { TAPState *s = opaque; @@ -4135,6 +4148,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, int fd) s->no_poll = 0; enable_sigio_timer(fd); s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s); + s->vc->fd_readv = tap_readv; qemu_set_fd_handler2(s->fd, tap_read_poll, tap_send, NULL, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: fd=%d", fd); return s; -- 2.11.4.GIT