sky2: check drop truncated packets
authorStephen Hemminger <shemminger@linux-foundation.org>
Thu, 16 Aug 2007 13:12:48 +0000 (09:12 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 22 Aug 2007 23:23:25 +0000 (16:23 -0700)
Backport of commit 71749531f2d1954137a1a77422ef4ff29eb102dd

If packet larger than MTU is received, the driver uses hardware to
truncate the packet. Use the status registers to catch/drop them.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/net/sky2.c

index d5fe418bdf42602c12cd8cc37373eca31d40effa..d2646a8087a8bc2e8bed8bdba7c07bbaa4814cf3 100644 (file)
@@ -2065,6 +2065,9 @@ static struct sk_buff *sky2_receive(struct net_device *dev,
        if (!(status & GMR_FS_RX_OK))
                goto resubmit;
 
+       if (status >> 16 != length)
+               goto len_mismatch;
+
        if (length < copybreak)
                skb = receive_copy(sky2, re, length);
        else
@@ -2074,6 +2077,11 @@ resubmit:
 
        return skb;
 
+len_mismatch:
+       /* Truncation of overlength packets
+          causes PHY length to not match MAC length */
+       ++sky2->net_stats.rx_length_errors;
+
 error:
        ++sky2->net_stats.rx_errors;
        if (status & GMR_FS_RX_FF_OV) {