netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 02/14] tg3: Drop non-VLAN rx pkts larger than the MTU
@ 2009-02-26  0:21 Matt Carlson
  0 siblings, 0 replies; only message in thread
From: Matt Carlson @ 2009-02-26  0:21 UTC (permalink / raw)
  To: davem; +Cc: netdev, Michael Chan, Benjamin Li, andy

The hardware's MTU is configured so that it will accept packets whose
VLAN tag is left inline.  This means that the hardware will also accept
other packets larger than the desired MTU size.  This patch checks for
and discards packets that are larger than the requested MTU but are not
VLAN tagged frames.

Signed-off-by: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: Benjamin Li <benli@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/tg3.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index c7bbbb1..774a01a 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -4339,6 +4339,13 @@ static int tg3_rx(struct tg3 *tp, int budget)
 			skb->ip_summed = CHECKSUM_NONE;
 
 		skb->protocol = eth_type_trans(skb, tp->dev);
+
+		if (len > (tp->dev->mtu + ETH_HLEN) &&
+		    skb->protocol != htons(ETH_P_8021Q)) {
+			dev_kfree_skb(skb);
+			goto next_pkt;
+		}
+
 #if TG3_VLAN_TAG_USED
 		if (tp->vlgrp != NULL &&
 		    desc->type_flags & RXD_FLAG_VLAN) {
@@ -6824,7 +6831,8 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
 	__tg3_set_mac_addr(tp, 0);
 
 	/* MTU + ethernet header + FCS + optional VLAN tag */
-	tw32(MAC_RX_MTU_SIZE, tp->dev->mtu + ETH_HLEN + 8);
+	tw32(MAC_RX_MTU_SIZE,
+	     tp->dev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN);
 
 	/* The slot time is changed by tg3_setup_phy if we
 	 * run at gigabit with half duplex.
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-26  2:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-26  0:21 [PATCH 02/14] tg3: Drop non-VLAN rx pkts larger than the MTU Matt Carlson

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).