qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Brian Kress <kressb@moose.net>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL for-2.4 3/9] vmxnet3: Fix incorrect small packet padding
Date: Tue,  7 Jul 2015 13:38:19 +0100	[thread overview]
Message-ID: <1436272705-28499-4-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1436272705-28499-1-git-send-email-stefanha@redhat.com>

From: Brian Kress <kressb@moose.net>

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.

Signed-off-by: Brian Kress <kressb@moose.net>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/net/vmxnet3.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 104a0f5..706e060 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1879,6 +1879,12 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         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 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, size_t size)
         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)));
 
-- 
2.4.3

  parent reply	other threads:[~2015-07-07 12:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 12:38 [Qemu-devel] [PULL for-2.4 0/9] Net patches Stefan Hajnoczi
2015-07-07 12:38 ` [Qemu-devel] [PULL for-2.4 1/9] rocker: fix memory leak Stefan Hajnoczi
2015-07-07 12:38 ` [Qemu-devel] [PULL for-2.4 2/9] e1000: flush packets when link comes up Stefan Hajnoczi
2015-07-07 12:38 ` Stefan Hajnoczi [this message]
2015-07-07 12:38 ` [Qemu-devel] [PULL for-2.4 4/9] rocker: don't queue receive pkts when port is disabled Stefan Hajnoczi
2015-07-07 12:38 ` [Qemu-devel] [PULL for-2.4 5/9] rocker: fix misplaced break statement Stefan Hajnoczi
2015-07-07 12:38 ` [Qemu-devel] [PULL for-2.4 6/9] rocker: fix missing break statements Stefan Hajnoczi
2015-07-07 12:38 ` [Qemu-devel] [PULL for-2.4 7/9] rocker: return -1 when dropping packet on ingress Stefan Hajnoczi
2015-07-07 12:38 ` [Qemu-devel] [PULL for-2.4 8/9] rocker: mark copy-to-cpu pkts as forwarding offloaded Stefan Hajnoczi
2015-07-07 12:38 ` [Qemu-devel] [PULL for-2.4 9/9] rocker: tests: don't need to specify master/self when setting vlans Stefan Hajnoczi
2015-07-07 15:57 ` [Qemu-devel] [PULL for-2.4 0/9] Net patches Peter Maydell

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=1436272705-28499-4-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=kressb@moose.net \
    --cc=peter.maydell@linaro.org \
    --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).