From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKm00-0006Py-IT for qemu-devel@nongnu.org; Fri, 22 Aug 2014 06:23:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKlzs-0001Xe-6t for qemu-devel@nongnu.org; Fri, 22 Aug 2014 06:23:12 -0400 Received: from mail-ie0-f170.google.com ([209.85.223.170]:33341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKlzs-0001XQ-1b for qemu-devel@nongnu.org; Fri, 22 Aug 2014 06:23:04 -0400 Received: by mail-ie0-f170.google.com with SMTP id rl12so6281171iec.1 for ; Fri, 22 Aug 2014 03:23:03 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1408537634-3812-1-git-send-email-ben@xrsa.net> References: <1408537634-3812-1-git-send-email-ben@xrsa.net> Date: Fri, 22 Aug 2014 11:23:02 +0100 Message-ID: From: Ben Draper Content-Type: multipart/alternative; boundary=90e6ba5bb9e9e5930f050135380b Subject: Re: [Qemu-devel] [PATCH] vmxnet3: Pad short frames to minimum size (60 bytes) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Ben Draper , stefanha@redhat.com --90e6ba5bb9e9e5930f050135380b Content-Type: text/plain; charset=UTF-8 Interestingly this does not appear to affect Windows guests on the same host/bridge as the ESXi guest, as Windows pads the frames before sending them out. However it does affect Linux guests on the same host/bridge from communicating with the ESXi guest itself and the guests ESXi hosts. -- *View My LinkedIn Profile* http://uk.linkedin.com/in/bendraper00 On 20 August 2014 13:27, Ben Draper wrote: > When running VMware ESXi under qemu-kvm the guest discards frames > that are too short. Short ARP Requests will be dropped, this prevents > guests on the same bridge as VMware ESXi from communicating. This patch > simply adds the padding on the network device itself. > > Signed-off-by: Ben Draper > --- > hw/net/vmxnet3.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c > index 791321f..f246fa1 100644 > --- a/hw/net/vmxnet3.c > +++ b/hw/net/vmxnet3.c > @@ -34,6 +34,7 @@ > > #define PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION 0x1 > #define VMXNET3_MSIX_BAR_SIZE 0x2000 > +#define MIN_BUF_SIZE 60 > > #define VMXNET3_BAR0_IDX (0) > #define VMXNET3_BAR1_IDX (1) > @@ -1871,12 +1872,21 @@ vmxnet3_receive(NetClientState *nc, const uint8_t > *buf, size_t size) > { > VMXNET3State *s = qemu_get_nic_opaque(nc); > size_t bytes_indicated; > + uint8_t min_buf[MIN_BUF_SIZE]; > > if (!vmxnet3_can_receive(nc)) { > VMW_PKPRN("Cannot receive now"); > return -1; > } > > + /* Pad to minimum Ethernet frame length */ > + if (size < sizeof(min_buf)) { > + memcpy(min_buf, buf, size); > + memset(&min_buf[size], 0, sizeof(min_buf) - size); > + buf = min_buf; > + 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); > -- > 1.7.10.4 > > --90e6ba5bb9e9e5930f050135380b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Interestingly this does not appear to affect Windows guest= s on the same host/bridge as the ESXi guest, as
Windows pads the frames= before sending them out. However it does affect Linux guests on the same h= ost/bridge
from communicating with the ESXi guest itself and the guests ESXi host= s.


--

View My LinkedIn P= rofile



On 20 August 2014 13:27, Ben Draper <ben@xrs= a.net> wrote:
When running VMware ESXi under qemu-kvm the guest discards frames
that are too short. Short ARP Requests will be dropped, this prevents
guests on the same bridge as VMware ESXi from communicating. This patch
simply adds the padding on the network device itself.

Signed-off-by: Ben Draper <ben@xrsa.net<= /a>>
---
=C2=A0hw/net/vmxnet3.c |=C2=A0 =C2=A010 ++++++++++
=C2=A01 file changed, 10 insertions(+)

diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 791321f..f246fa1 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -34,6 +34,7 @@

=C2=A0#define PCI_DEVICE_ID_VMWARE_VMXNET3_REVISION 0x1
=C2=A0#define VMXNET3_MSIX_BAR_SIZE 0x2000
+#define MIN_BUF_SIZE 60

=C2=A0#define VMXNET3_BAR0_IDX=C2=A0 =C2=A0 =C2=A0 (0)
=C2=A0#define VMXNET3_BAR1_IDX=C2=A0 =C2=A0 =C2=A0 (1)
@@ -1871,12 +1872,21 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *= buf, size_t size)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0VMXNET3State *s =3D qemu_get_nic_opaque(nc);
=C2=A0 =C2=A0 =C2=A0size_t bytes_indicated;
+=C2=A0 =C2=A0 uint8_t min_buf[MIN_BUF_SIZE];

=C2=A0 =C2=A0 =C2=A0if (!vmxnet3_can_receive(nc)) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0VMW_PKPRN("Cannot receive now")= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -1;
=C2=A0 =C2=A0 =C2=A0}

+=C2=A0 =C2=A0 /* Pad to minimum Ethernet frame length */
+=C2=A0 =C2=A0 if (size < sizeof(min_buf)) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 memcpy(min_buf, buf, size);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 memset(&min_buf[size], 0, sizeof(min_buf) = - size);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 buf =3D min_buf;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 size =3D sizeof(min_buf);
+=C2=A0 =C2=A0 }
+
=C2=A0 =C2=A0 =C2=A0if (s->peer_has_vhdr) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vmxnet_rx_pkt_set_vhdr(s->rx_pkt, (str= uct virtio_net_hdr *)buf);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0buf +=3D sizeof(struct virtio_net_hdr); --
1.7.10.4


--90e6ba5bb9e9e5930f050135380b--