aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pasemi_mac.c
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2007-11-06 23:21:38 -0500
committerJeff Garzik <jeff@garzik.org>2007-11-10 04:25:14 -0500
commit32bee776533eea839f9499d985c1490b5ac98512 (patch)
tree395a2183a97bef80966c5fd5d731e7b3d8b761b7 /drivers/net/pasemi_mac.c
parentdbd62af7de9ee63f83c0262e4acc3b3319c09c8b (diff)
pasemi_mac: Fix CRC checks
Make sure we don't feed packets with bad CRC up the network stack, and discount the packet length as reported from the MAC for the CRC field. Signed-off-by: Olof Johansson <olof@lixom.net> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/pasemi_mac.c')
-rw-r--r--drivers/net/pasemi_mac.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index b14f171b1b67..09b4fde8d924 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -580,6 +580,16 @@ static int pasemi_mac_clean_rx(struct pasemi_mac *mac, int limit)
580 580
581 len = (macrx & XCT_MACRX_LLEN_M) >> XCT_MACRX_LLEN_S; 581 len = (macrx & XCT_MACRX_LLEN_M) >> XCT_MACRX_LLEN_S;
582 582
583 pci_unmap_single(mac->dma_pdev, dma, len, PCI_DMA_FROMDEVICE);
584
585 if (macrx & XCT_MACRX_CRC) {
586 /* CRC error flagged */
587 mac->netdev->stats.rx_errors++;
588 mac->netdev->stats.rx_crc_errors++;
589 dev_kfree_skb_irq(skb);
590 goto next;
591 }
592
583 if (len < 256) { 593 if (len < 256) {
584 struct sk_buff *new_skb; 594 struct sk_buff *new_skb;
585 595
@@ -595,11 +605,10 @@ static int pasemi_mac_clean_rx(struct pasemi_mac *mac, int limit)
595 } else 605 } else
596 info->skb = NULL; 606 info->skb = NULL;
597 607
598 pci_unmap_single(mac->dma_pdev, dma, len, PCI_DMA_FROMDEVICE);
599
600 info->dma = 0; 608 info->dma = 0;
601 609
602 skb_put(skb, len); 610 /* Don't include CRC */
611 skb_put(skb, len-4);
603 612
604 if (likely((macrx & XCT_MACRX_HTY_M) == XCT_MACRX_HTY_IPV4_OK)) { 613 if (likely((macrx & XCT_MACRX_HTY_M) == XCT_MACRX_HTY_IPV4_OK)) {
605 skb->ip_summed = CHECKSUM_UNNECESSARY; 614 skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -614,6 +623,7 @@ static int pasemi_mac_clean_rx(struct pasemi_mac *mac, int limit)
614 skb->protocol = eth_type_trans(skb, mac->netdev); 623 skb->protocol = eth_type_trans(skb, mac->netdev);
615 netif_receive_skb(skb); 624 netif_receive_skb(skb);
616 625
626next:
617 RX_RING(mac, n) = 0; 627 RX_RING(mac, n) = 0;
618 RX_RING(mac, n+1) = 0; 628 RX_RING(mac, n+1) = 0;
619 629