Commit b203262de63c56393d09e254242b57c002d8619d

Authored by Neil Horman
Committed by David S. Miller
1 parent 11aad99af6

vmxnet3: cap copy length at size of skb to prevent dropped frames on tx

I was recently shown that vmxnet3 devices on transmit, will drop very small udp
frames consistently.  This is due to a regression introduced by commit
39d4a96fd7d2926e46151adbd18b810aeeea8ec0.  This commit attempts to introduce an
optimization to the tx path, indicating that the underlying hardware behaves
optimally when at least 54 bytes of header data are available for direct access.
This causes problems however, if the entire frame is less than 54 bytes long.
The subsequent pskb_may_pull in vmxnet3_parse_and_copy_hdr fails, causing an
error return code, which leads to vmxnet3_tq_xmit dropping the frame.

Fix it by placing a cap on the copy length.  For frames longer than 54 bytes, we
do the pull as we normally would.  If the frame is shorter than that, copy the
whole frame, but no more.  This ensures that we still get the optimization for
qualifying frames, but don't do any damange for frames that are too short.

Also, since I'm unable to do this, it wuold be great if vmware could follow up
this patch with some additional code commentary as to why 54 bytes is an optimal
pull length for a virtual NIC driver.  The comment that introduced this was
vague on that.  Thanks!

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Reported-by: Max Matveev <mmatveev@redhat.com>
CC: Max Matveev <mmatveev@redhat.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Shreyas Bhatewara <sbhatewara@vmware.com>
CC: "VMware, Inc." <pv-drivers@vmware.com>
Signed-off-by: Shreyas N Bhatewara <sbhatewara@vmware.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff

drivers/net/vmxnet3/vmxnet3_drv.c
... ... @@ -843,8 +843,8 @@
843 843 /* for simplicity, don't copy L4 headers */
844 844 ctx->l4_hdr_size = 0;
845 845 }
846   - ctx->copy_size = ctx->eth_ip_hdr_size +
847   - ctx->l4_hdr_size;
  846 + ctx->copy_size = min(ctx->eth_ip_hdr_size +
  847 + ctx->l4_hdr_size, skb->len);
848 848 } else {
849 849 ctx->eth_ip_hdr_size = 0;
850 850 ctx->l4_hdr_size = 0;