From: "Michael S. Tsirkin" <mst@redhat.com>
To: Greg Kurz <gkurz@linux.vnet.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 3/3] vhost_net: fix virtio_net header endianness
Date: Sun, 22 Feb 2015 10:46:15 +0100 [thread overview]
Message-ID: <20150222094615.GA17529@redhat.com> (raw)
In-Reply-To: <20150220101454.18608.64016.stgit@bahia.local>
On Fri, Feb 20, 2015 at 11:15:05AM +0100, Greg Kurz wrote:
> Without this patch, packets are being silently dropped by the tap backend.
>
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
I think it's the wrong place to fix this. You want a tun/macvtap ioctl
to enable legacy big endian stuff. Treat it same way as vhost, with a
config option to enable.
> ---
> drivers/vhost/net.c | 32 ++++++++++++++++++++++++++------
> 1 file changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index afa06d2..2923eee 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -288,6 +288,16 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success)
> rcu_read_unlock_bh();
> }
>
> +static void fix_virtio_net_hdr(struct vhost_virtqueue *vq)
> +{
> + struct virtio_net_hdr *hdr = vq->iov[0].iov_base;
> +
> + hdr->hdr_len = vhost16_to_cpu(vq, hdr->hdr_len);
> + hdr->gso_size = vhost16_to_cpu(vq, hdr->gso_size);
> + hdr->csum_start = vhost16_to_cpu(vq, hdr->csum_start);
> + hdr->csum_offset = vhost16_to_cpu(vq, hdr->csum_offset);
> +}
> +
> /* Expects to be always run from workqueue - which acts as
> * read-size critical section for our kind of RCU. */
> static void handle_tx(struct vhost_net *net)
> @@ -352,6 +362,10 @@ static void handle_tx(struct vhost_net *net)
> "out %d, int %d\n", out, in);
> break;
> }
> +
> + if (!hdr_size)
> + fix_virtio_net_hdr(vq);
> +
> /* Skip header. TODO: support TSO. */
> len = iov_length(vq->iov, out);
> iov_iter_init(&msg.msg_iter, WRITE, vq->iov, out, len);
> @@ -609,12 +623,18 @@ static void handle_rx(struct vhost_net *net)
> continue;
> }
> /* Supply virtio_net_hdr if VHOST_NET_F_VIRTIO_NET_HDR */
> - if (unlikely(vhost_hlen) &&
> - copy_to_iter(&hdr, sizeof(hdr), &fixup) != sizeof(hdr)) {
> - vq_err(vq, "Unable to write vnet_hdr at addr %p\n",
> - vq->iov->iov_base);
> - break;
> - }
> + if (unlikely(vhost_hlen)) {
> + size_t len = copy_to_iter(&hdr, sizeof(hdr), &fixup);
> +
> + if (len != sizeof(hdr)) {
> + vq_err(vq,
> + "Unable to write vnet_hdr at addr %p\n",
> + vq->iov->iov_base);
> + break;
> + }
> + } else
> + fix_virtio_net_hdr(vq);
> +
> /* TODO: Should check and handle checksum. */
>
> num_buffers = cpu_to_vhost16(vq, headcount);
next prev parent reply other threads:[~2015-02-22 9:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 10:07 [PATCH 0/3] vhost_net: support for cross endian guests Greg Kurz
2015-02-20 10:07 ` [PATCH 1/3] vhost: add VHOST_VRING_F_LEGACY_BIG_ENDIAN flag Greg Kurz
2015-02-22 9:51 ` Michael S. Tsirkin
2015-02-22 9:51 ` Michael S. Tsirkin
2015-02-20 10:14 ` [PATCH 2/3] vhost: add support for legacy virtio Greg Kurz
2015-02-20 10:14 ` Greg Kurz
2015-02-22 9:48 ` Michael S. Tsirkin
2015-02-22 9:48 ` Michael S. Tsirkin
2015-02-20 10:15 ` [PATCH 3/3] vhost_net: fix virtio_net header endianness Greg Kurz
2015-02-22 9:46 ` Michael S. Tsirkin [this message]
2015-02-20 10:15 ` Greg Kurz
2015-02-22 9:53 ` [PATCH 0/3] vhost_net: support for cross endian guests Michael S. Tsirkin
2015-02-23 13:24 ` Greg Kurz
2015-02-23 13:24 ` Greg Kurz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150222094615.GA17529@redhat.com \
--to=mst@redhat.com \
--cc=clg@fr.ibm.com \
--cc=gkurz@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.