Netdev List
 help / color / mirror / Atom feed
From: Petri Gynther <pgynther@google.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, f.fainelli@gmail.com, jaedon.shin@gmail.com,
	edumazet@google.com, Petri Gynther <pgynther@google.com>
Subject: [PATCH net 2/2] net: bcmgenet: fix skb_len in bcmgenet_xmit_single()
Date: Wed, 23 Mar 2016 13:01:29 -0700	[thread overview]
Message-ID: <1458763289-95167-2-git-send-email-pgynther@google.com> (raw)
In-Reply-To: <1458763289-95167-1-git-send-email-pgynther@google.com>

skb_len needs to be skb_headlen(skb) in bcmgenet_xmit_single().

Fragmented skbs can have only Ethernet + IP + TCP headers (14+20+20=54 bytes)
in the linear buffer, followed by the rest in fragments. Bumping skb_len to
ETH_ZLEN would be incorrect for this case, as it would introduce garbage
between TCP header and the fragment data.

This also works with regular/non-fragmented small packets < ETH_ZLEN bytes.
Successfully tested this on GENETv3 with 42-byte ARP frames.

For testing, I used:
ethtool -K eth0 tx-checksum-ipv4 off
ethtool -K eth0 tx-checksum-ipv6 off
echo 0 > /proc/sys/net/ipv4/tcp_timestamps

Signed-off-by: Petri Gynther <pgynther@google.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 9990582..00da239 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1298,7 +1298,7 @@ static int bcmgenet_xmit_single(struct net_device *dev,
 
 	tx_cb_ptr->skb = skb;
 
-	skb_len = skb_headlen(skb) < ETH_ZLEN ? ETH_ZLEN : skb_headlen(skb);
+	skb_len = skb_headlen(skb);
 
 	mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE);
 	ret = dma_mapping_error(kdev, mapping);
-- 
2.8.0.rc3.226.g39d4020

  reply	other threads:[~2016-03-23 20:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-23 20:01 [PATCH net 1/2] net: bcmgenet: fix dev->stats.tx_bytes accounting Petri Gynther
2016-03-23 20:01 ` Petri Gynther [this message]
2016-03-23 21:24   ` [PATCH net 2/2] net: bcmgenet: fix skb_len in bcmgenet_xmit_single() Eric Dumazet
2016-03-23 21:23 ` [PATCH net 1/2] net: bcmgenet: fix dev->stats.tx_bytes accounting Eric Dumazet
2016-03-23 21:47   ` Florian Fainelli
2016-03-23 22:02 ` Florian Fainelli
2016-03-23 22:09 ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458763289-95167-2-git-send-email-pgynther@google.com \
    --to=pgynther@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=jaedon.shin@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox