From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z88NK-00028F-6l for qemu-devel@nongnu.org; Thu, 25 Jun 2015 10:43:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z88NG-0007Y8-Qi for qemu-devel@nongnu.org; Thu, 25 Jun 2015 10:43:34 -0400 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:37315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z88NG-0007Xk-Jw for qemu-devel@nongnu.org; Thu, 25 Jun 2015 10:43:30 -0400 Received: by wicgi11 with SMTP id gi11so78103665wic.0 for ; Thu, 25 Jun 2015 07:43:30 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <558C138F.7030706@redhat.com> Date: Thu, 25 Jun 2015 16:43:27 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <55898005.2040600@moose.net> <20150625132741.GK4419@stefanha-thinkpad.redhat.com> <558C0380.6050709@moose.net> In-Reply-To: <558C0380.6050709@moose.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] vmxnet3, vnet_hdr, and minimum length padding List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Brian Kress , qemu-devel@nongnu.org Cc: Dmitry Fleytman , Stefan Hajnoczi , jasowang@redhat.com On 25/06/2015 15:34, Brian Kress wrote: > Resending by request with Signed-off-by: > > > 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. This is not the correct format for a patch: - the subject should start with [PATCH] - the subject should describe what the patch does - the lines of the body of the commit message should be ~72 characters long at most - the patch should apply with "patch -p1" (your patch requires "-p2"). For more information, see http://wiki.qemu.org/Contribute/SubmitAPatch. It's up to the maintainer whether to fix the above; the code however is fine so: Reviewed-by: Paolo Bonzini Thanks, Paolo > > Signed-off-by: Brian Kress > > --- 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))); > > >