qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Brian Kress <kressb@moose.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] vmxnet3, vnet_hdr, and minimum length padding
Date: Mon, 29 Jun 2015 16:06:04 +0100	[thread overview]
Message-ID: <20150629150604.GL32151@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <55898005.2040600@moose.net>

[-- Attachment #1: Type: text/plain, Size: 2410 bytes --]

On Tue, Jun 23, 2015 at 11:49:25AM -0400, Brian Kress wrote:
>     When running ESXi under qemu there is an issue with the ESXi guest
> discarding packets that are too short.  The guest discards any packets under
> the normal minimum length for an ethernet packet (60).  This results in odd
> behaviour where other hosts or VMs on other hosts can communicate with the
> ESXi guest just fine (since there's a physical NIC somewhere doing padding),
> but VMs on the host and the host itself cannot because the ARP request
> packets are too small for the ESXi host to accept.
>     Someone in the past thought this was worth fixing, and added code to the
> vmxnet3 qemu emulation such that if it is receiving packets smaller than 60
> bytes to pad the packet out to 60. Unfortunately this code is wrong (or at
> least in the wrong place). It does so BEFORE before taking into account the
> vnet_hdr at the front of the packet added by the tap device.   As a result,
> it might add padding, but it never adds enough.  Specifically it adds 10
> less (the length of the vnet_hdr) than it needs to.
>     The following (hopefully "obviously correct") patch simply swaps the
> order of processing the vnet header and the padding.  With this patch an
> ESXi guest is able to communicate with the host or other local VMs.
> 
> 
> --- a/qemu-2.3.0/hw/net/vmxnet3.c       2015-04-27 10:08:24.000000000 -0400
> +++ b/qemu-2.3.0/hw/net/vmxnet3.c       2015-06-23 11:38:48.865728713 -0400
> @@ -1879,6 +1879,12 @@
>          return -1;
>      }
> 
> +    if (s->peer_has_vhdr) {
> +        vmxnet_rx_pkt_set_vhdr(s->rx_pkt, (struct virtio_net_hdr *)buf);
> +        buf += sizeof(struct virtio_net_hdr);
> +        size -= sizeof(struct virtio_net_hdr);
> +    }
> +
>      /* Pad to minimum Ethernet frame length */
>      if (size < sizeof(min_buf)) {
>          memcpy(min_buf, buf, size);
> @@ -1887,12 +1893,6 @@
>          size = sizeof(min_buf);
>      }
> 
> -    if (s->peer_has_vhdr) {
> -        vmxnet_rx_pkt_set_vhdr(s->rx_pkt, (struct virtio_net_hdr *)buf);
> -        buf += sizeof(struct virtio_net_hdr);
> -        size -= sizeof(struct virtio_net_hdr);
> -    }
> -
>      vmxnet_rx_pkt_set_packet_type(s->rx_pkt,
>          get_eth_packet_type(PKT_GET_ETH_HDR(buf)));

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

      parent reply	other threads:[~2015-06-29 15:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-23 15:49 [Qemu-devel] vmxnet3, vnet_hdr, and minimum length padding Brian Kress
2015-06-25 13:27 ` Stefan Hajnoczi
2015-06-25 13:34   ` Brian Kress
2015-06-25 14:43     ` Paolo Bonzini
2015-06-28 14:56 ` Dmitry Fleytman
2015-06-29 15:06 ` Stefan Hajnoczi [this message]

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=20150629150604.GL32151@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=kressb@moose.net \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).