diff options
author | Linas Vepstas <linas@austin.ibm.com> | 2006-10-10 16:01:00 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-10-11 04:04:25 -0400 |
commit | 808999c9a4749dc67c39bf52f712d0c27aa00e67 (patch) | |
tree | 7a6f8879857ca81fa36194e6d14e9f66a42ed2eb /drivers/net | |
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')
-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, { struct spider_net_descr *descr = card->tx_chain.head; dma_addr_t buf; + int length; - buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); + length = skb->len; + if (length < ETH_ZLEN) { + if (skb_pad(skb, ETH_ZLEN-length)) + return 0; + length = ETH_ZLEN; + } + + buf = pci_map_single(card->pdev, skb->data, length, PCI_DMA_TODEVICE); if (pci_dma_mapping_error(buf)) { if (netif_msg_tx_err(card) && net_ratelimit()) pr_err("could not iommu-map packet (%p, %i). " - "Dropping packet\n", skb->data, skb->len); + "Dropping packet\n", skb->data, length); card->spider_stats.tx_iommu_map_error++; return -ENOMEM; } descr->buf_addr = buf; - descr->buf_size = skb->len; + descr->buf_size = length; descr->next_descr_addr = 0; descr->skb = skb; descr->data_status = 0; @@ -693,6 +701,7 @@ spider_net_release_tx_descr(struct spider_net_card *card) { struct spider_net_descr *descr = card->tx_chain.tail; struct sk_buff *skb; + unsigned int len; card->tx_chain.tail = card->tx_chain.tail->next; descr->dmac_cmd_status |= SPIDER_NET_DESCR_NOT_IN_USE; @@ -701,7 +710,8 @@ spider_net_release_tx_descr(struct spider_net_card *card) skb = descr->skb; if (!skb) return; - pci_unmap_single(card->pdev, descr->buf_addr, skb->len, + len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; + pci_unmap_single(card->pdev, descr->buf_addr, len, PCI_DMA_TODEVICE); dev_kfree_skb_any(skb); } |