diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2015-02-25 09:19:28 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-27 15:53:44 -0500 |
commit | 4c5a84421c7d1c259c3883a404f9a67a2f55b003 (patch) | |
tree | 03a323eceb7203dcf739317e5bb2a3e34cf52e7c /drivers/vhost | |
parent | 5f2ebfbee68872762ad76f735277ed7afa074d76 (diff) |
vhost: cleanup iterator update logic
Recent iterator-related changes in vhost made it
harder to follow the logic fixing up the header.
In fact, the fixup always happens at the same
offset: sizeof(virtio_net_hdr): sometimes the
fixup iterator is updated by copy_to_iter,
sometimes-by iov_iter_advance.
Rearrange code to make this obvious.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/vhost')
-rw-r--r-- | drivers/vhost/net.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index afa06d28725d..ca7043459e2c 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c | |||
@@ -591,11 +591,6 @@ static void handle_rx(struct vhost_net *net) | |||
591 | * TODO: support TSO. | 591 | * TODO: support TSO. |
592 | */ | 592 | */ |
593 | iov_iter_advance(&msg.msg_iter, vhost_hlen); | 593 | iov_iter_advance(&msg.msg_iter, vhost_hlen); |
594 | } else { | ||
595 | /* It'll come from socket; we'll need to patch | ||
596 | * ->num_buffers over if VIRTIO_NET_F_MRG_RXBUF | ||
597 | */ | ||
598 | iov_iter_advance(&fixup, sizeof(hdr)); | ||
599 | } | 594 | } |
600 | err = sock->ops->recvmsg(NULL, sock, &msg, | 595 | err = sock->ops->recvmsg(NULL, sock, &msg, |
601 | sock_len, MSG_DONTWAIT | MSG_TRUNC); | 596 | sock_len, MSG_DONTWAIT | MSG_TRUNC); |
@@ -609,11 +604,18 @@ static void handle_rx(struct vhost_net *net) | |||
609 | continue; | 604 | continue; |
610 | } | 605 | } |
611 | /* Supply virtio_net_hdr if VHOST_NET_F_VIRTIO_NET_HDR */ | 606 | /* Supply virtio_net_hdr if VHOST_NET_F_VIRTIO_NET_HDR */ |
612 | if (unlikely(vhost_hlen) && | 607 | if (unlikely(vhost_hlen)) { |
613 | copy_to_iter(&hdr, sizeof(hdr), &fixup) != sizeof(hdr)) { | 608 | if (copy_to_iter(&hdr, sizeof(hdr), |
614 | vq_err(vq, "Unable to write vnet_hdr at addr %p\n", | 609 | &fixup) != sizeof(hdr)) { |
615 | vq->iov->iov_base); | 610 | vq_err(vq, "Unable to write vnet_hdr " |
616 | break; | 611 | "at addr %p\n", vq->iov->iov_base); |
612 | break; | ||
613 | } | ||
614 | } else { | ||
615 | /* Header came from socket; we'll need to patch | ||
616 | * ->num_buffers over if VIRTIO_NET_F_MRG_RXBUF | ||
617 | */ | ||
618 | iov_iter_advance(&fixup, sizeof(hdr)); | ||
617 | } | 619 | } |
618 | /* TODO: Should check and handle checksum. */ | 620 | /* TODO: Should check and handle checksum. */ |
619 | 621 | ||