Received: from eggs.gnu.org ([2001:4830:134:3::10]:52731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z87C1-0003ak-Bx for qemu-devel@nongnu.org; Thu, 25 Jun 2015 09:27:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z87Bw-0008Q3-RA for qemu-devel@nongnu.org; Thu, 25 Jun 2015 09:27:49 -0400 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]:37912) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z87Bw-0008Py-Hi for qemu-devel@nongnu.org; Thu, 25 Jun 2015 09:27:44 -0400 Received: by wibdq8 with SMTP id dq8so75981200wib.1 for ; Thu, 25 Jun 2015 06:27:43 -0700 (PDT) Date: Thu, 25 Jun 2015 14:27:41 +0100 From: Stefan Hajnoczi Message-ID: <20150625132741.GK4419@stefanha-thinkpad.redhat.com> References: <55898005.2040600@moose.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="M0YLxmUXciMpOLPE" Content-Disposition: inline In-Reply-To: <55898005.2040600@moose.net> 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 Cc: Dmitry Fleytman , jasowang@redhat.com, qemu-devel@nongnu.org --M0YLxmUXciMpOLPE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 23, 2015 at 11:49:25AM -0400, Brian Kress wrote: Thanks for sending a patch! I have CCed the vmxnet3 maintainer and Jason Wang, who looks at net subsystem patches: $ scripts/get_maintainer.pl -f hw/net/vmxnet3.c Dmitry Fleytman (maintainer:Vmware) > When running ESXi under qemu there is an issue with the ESXi guest > discarding packets that are too short. The guest discards any packets un= der > the normal minimum length for an ethernet packet (60). This results in o= dd > 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 paddin= g), > 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 t= he > vnet_hdr at the front of the packet added by the tap device. As a resul= t, > 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. >=20 >=20 Please add your Signed-off-by. Details about Signed-off-by are on the http://qemu-project.org/Contribute/SubmitAPatch page. > --- a/qemu-2.3.0/hw/net/vmxnet3.c 2015-04-27 10:08:24.000000000 -04= 00 > +++ b/qemu-2.3.0/hw/net/vmxnet3.c 2015-06-23 11:38:48.865728713 -04= 00 > @@ -1879,6 +1879,12 @@ > return -1; > } >=20 > + if (s->peer_has_vhdr) { > + vmxnet_rx_pkt_set_vhdr(s->rx_pkt, (struct virtio_net_hdr *)buf); > + buf +=3D sizeof(struct virtio_net_hdr); > + size -=3D 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 =3D sizeof(min_buf); > } >=20 > - if (s->peer_has_vhdr) { > - vmxnet_rx_pkt_set_vhdr(s->rx_pkt, (struct virtio_net_hdr *)buf); > - buf +=3D sizeof(struct virtio_net_hdr); > - size -=3D sizeof(struct virtio_net_hdr); > - } > - > vmxnet_rx_pkt_set_packet_type(s->rx_pkt, > get_eth_packet_type(PKT_GET_ETH_HDR(buf))); >=20 >=20 >=20 >=20 >=20 --M0YLxmUXciMpOLPE Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVjAHNAAoJEJykq7OBq3PI5RMIAL35M8r++IDNem54J9sGtBF8 A8PhkPgZyiOHxaQXbioEfTXMfTbnkvDu1yfO+yXY7DLrgLFqCP5n4L2/bgzNsic7 xsOvn+gSrpsrAnH4tGrWx0B4f5jnxVlLBqZ525T8V4QH3y8VFml7U1R7Ql8j5630 Z4CCkk9AW5jLJ7O0KFrTYYdEikTYWucLqssYrvk3BhOR+/eDDqsIibJmsS9AHZt7 sIbB1EVeZpFOYBl0TKerSCh8F8dyphQZpBpINcCl9KduWifoP3GSOqn8NJpO2kQ8 jbFLROg2+H4ZBlO5cbQXCZNoXg+R4PJh0RbFUb5wZJQOa0yiUDUNWsW9m6q4GlM= =ToeR -----END PGP SIGNATURE----- --M0YLxmUXciMpOLPE--