* [Qemu-devel] [PATCH] Fix incorrect small packet padding in vmxnet3
@ 2015-06-28 15:34 Brian Kress
2015-06-28 15:40 ` Dmitry Fleytman
0 siblings, 1 reply; 2+ messages in thread
From: Brian Kress @ 2015-06-28 15:34 UTC (permalink / raw)
To: Dmitry Fleytman; +Cc: qemu-devel
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>
--- a/hw/net/vmxnet3.c 2015-04-27 10:08:24.000000000 -0400
+++ b/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)));
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [Qemu-devel] [PATCH] Fix incorrect small packet padding in vmxnet3
2015-06-28 15:34 [Qemu-devel] [PATCH] Fix incorrect small packet padding in vmxnet3 Brian Kress
@ 2015-06-28 15:40 ` Dmitry Fleytman
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Fleytman @ 2015-06-28 15:40 UTC (permalink / raw)
To: Brian Kress; +Cc: qemu-devel
> On Jun 28, 2015, at 18:34 PM, Brian Kress <bkress@egenera.com> 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.
>
> Signed-off-by: Brian Kress <kressb@moose.net>
>
> --- a/hw/net/vmxnet3.c 2015-04-27 10:08:24.000000000 -0400
> +++ b/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);
> - }
> -
Looks good.
~Dmitry.
> vmxnet_rx_pkt_set_packet_type(s->rx_pkt,
> get_eth_packet_type(PKT_GET_ETH_HDR(buf)));
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-28 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-28 15:34 [Qemu-devel] [PATCH] Fix incorrect small packet padding in vmxnet3 Brian Kress
2015-06-28 15:40 ` Dmitry Fleytman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.