netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sathya Perla <sathya.perla@emulex.com>
To: <netdev@vger.kernel.org>
Subject: [PATCH 2/2] be2net: drop non-tso frames longer than mtu
Date: Tue, 15 Oct 2013 17:26:28 +0530	[thread overview]
Message-ID: <1381838188-9625-2-git-send-email-sathya.perla@emulex.com> (raw)
In-Reply-To: <1381838188-9625-1-git-send-email-sathya.perla@emulex.com>

From: Vasundhara Volam <vasundhara.volam@emulex.com>

Pktgen can generate non-TSO frames of arbitrary length disregarding
the MTU value of the physical interface. Drop such frames in the driver
instead of sending them to HW as it cannot handle such frames.

Signed-off-by: Vasundhara Volam <vasundhara.volam@emulex.com>
Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
---
 drivers/net/ethernet/emulex/benet/be_main.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 2c38cc4..76057b8 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -855,6 +855,13 @@ static struct sk_buff *be_xmit_workarounds(struct be_adapter *adapter,
 	unsigned int eth_hdr_len;
 	struct iphdr *ip;
 
+	/* Don't allow non-TSO packets longer than MTU */
+	eth_hdr_len = (ntohs(skb->protocol) == ETH_P_8021Q) ?
+			VLAN_ETH_HLEN : ETH_HLEN;
+	if (!skb_is_gso(skb) &&
+	    (skb->len - eth_hdr_len) > adapter->netdev->mtu)
+			goto tx_drop;
+
 	/* Lancer, SH-R ASICs have a bug wherein Packets that are 32 bytes or less
 	 * may cause a transmit stall on that port. So the work-around is to
 	 * pad short packets (<= 32 bytes) to a 36-byte length.
@@ -869,8 +876,6 @@ static struct sk_buff *be_xmit_workarounds(struct be_adapter *adapter,
 	 * incorrecly when VLAN tag is inserted by HW.
 	 * For padded packets, Lancer computes incorrect checksum.
 	 */
-	eth_hdr_len = ntohs(skb->protocol) == ETH_P_8021Q ?
-						VLAN_ETH_HLEN : ETH_HLEN;
 	if (skb->len <= 60 &&
 	    (lancer_chip(adapter) || vlan_tx_tag_present(skb)) &&
 	    is_ipv4_pkt(skb)) {
-- 
1.7.1

  reply	other threads:[~2013-10-15 11:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 11:56 [PATCH 1/2] be2net: pass if_id for v1 and V2 versions of TX_CREATE cmd Sathya Perla
2013-10-15 11:56 ` Sathya Perla [this message]
2013-10-15 13:45   ` [PATCH 2/2] be2net: drop non-tso frames longer than mtu Sergei Shtylyov
2013-10-15 13:47   ` Eric Dumazet
2013-10-15 14:30     ` Ivan Vecera
2013-10-16 12:08     ` Sathya Perla
2013-10-16 13:54       ` Eric Dumazet

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=1381838188-9625-2-git-send-email-sathya.perla@emulex.com \
    --to=sathya.perla@emulex.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;
as well as URLs for NNTP newsgroup(s).