diff options
author | Linas Vepstas <linas@austin.ibm.com> | 2006-10-10 17:01:00 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-10-11 04:04:25 -0400 |
commit | 808999c9a4749dc67c39bf52f712d0c27aa00e67 (patch) | |
tree | 7a6f8879857ca81fa36194e6d14e9f66a42ed2eb /drivers/net/spider_net.c | |
parent | c3fee4c55915c42b3278b65c91f9be8cee13426e (diff) |
[PATCH] powerpc/cell spidernet zlen min packet length
Polite device drivers pad short packets to 60 bytes,
so that mean-spirited users don't accidentally DOS
some other OS that can't handle short packets.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Cc: James K Lewis <jklewis@us.ibm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/spider_net.c')
-rw-r--r-- | drivers/net/spider_net.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index 52bf1b2968b..f5f73571a7a 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c | |||
@@ -648,18 +648,26 @@ spider_net_prepare_tx_descr(struct spider_net_card *card, | |||
648 | { | 648 | { |
649 | struct spider_net_descr *descr = card->tx_chain.head; | 649 | struct spider_net_descr *descr = card->tx_chain.head; |
650 | dma_addr_t buf; | 650 | dma_addr_t buf; |
651 | int length; | ||
651 | 652 | ||
652 | buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); | 653 | length = skb->len; |
654 | if (length < ETH_ZLEN) { | ||
655 | if (skb_pad(skb, ETH_ZLEN-length)) | ||
656 | return 0; | ||
657 | length = ETH_ZLEN; | ||
658 | } | ||
659 | |||
660 | buf = pci_map_single(card->pdev, skb->data, length, PCI_DMA_TODEVICE); | ||
653 | if (pci_dma_mapping_error(buf)) { | 661 | if (pci_dma_mapping_error(buf)) { |
654 | if (netif_msg_tx_err(card) && net_ratelimit()) | 662 | if (netif_msg_tx_err(card) && net_ratelimit()) |
655 | pr_err("could not iommu-map packet (%p, %i). " | 663 | pr_err("could not iommu-map packet (%p, %i). " |
656 | "Dropping packet\n", skb->data, skb->len); | 664 | "Dropping packet\n", skb->data, length); |
657 | card->spider_stats.tx_iommu_map_error++; | 665 | card->spider_stats.tx_iommu_map_error++; |
658 | return -ENOMEM; | 666 | return -ENOMEM; |
659 | } | 667 | } |
660 | 668 | ||
661 | descr->buf_addr = buf; | 669 | descr->buf_addr = buf; |
662 | descr->buf_size = skb->len; | 670 | descr->buf_size = length; |
663 | descr->next_descr_addr = 0; | 671 | descr->next_descr_addr = 0; |
664 | descr->skb = skb; | 672 | descr->skb = skb; |
665 | descr->data_status = 0; | 673 | descr->data_status = 0; |
@@ -693,6 +701,7 @@ spider_net_release_tx_descr(struct spider_net_card *card) | |||
693 | { | 701 | { |
694 | struct spider_net_descr *descr = card->tx_chain.tail; | 702 | struct spider_net_descr *descr = card->tx_chain.tail; |
695 | struct sk_buff *skb; | 703 | struct sk_buff *skb; |
704 | unsigned int len; | ||
696 | 705 | ||
697 | card->tx_chain.tail = card->tx_chain.tail->next; | 706 | card->tx_chain.tail = card->tx_chain.tail->next; |
698 | descr->dmac_cmd_status |= SPIDER_NET_DESCR_NOT_IN_USE; | 707 | descr->dmac_cmd_status |= SPIDER_NET_DESCR_NOT_IN_USE; |
@@ -701,7 +710,8 @@ spider_net_release_tx_descr(struct spider_net_card *card) | |||
701 | skb = descr->skb; | 710 | skb = descr->skb; |
702 | if (!skb) | 711 | if (!skb) |
703 | return; | 712 | return; |
704 | pci_unmap_single(card->pdev, descr->buf_addr, skb->len, | 713 | len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; |
714 | pci_unmap_single(card->pdev, descr->buf_addr, len, | ||
705 | PCI_DMA_TODEVICE); | 715 | PCI_DMA_TODEVICE); |
706 | dev_kfree_skb_any(skb); | 716 | dev_kfree_skb_any(skb); |
707 | } | 717 | } |