Skip to contentSkip to conversation

ibm_newemac: Fixes entry of short packets

PATCH Superseded Stefan Roese 3 participants 4 messages Jun 23, 2008 – Jun 27, 2008

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ibm_newemac: Fixes entry of short packets

From: Sathya Narayanan <[email protected]>

Short packets has to be discarded by the driver. So this patch addresses the issue of discarding the short packets of size lesser then ethernet header size.

---
 drivers/net/ibm_newemac/core.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/ibm_newemac/core.c +7 -0
index 6dfc2c9..aa407b2 100644
@@ -1652,6 +1652,13 @@ static int emac_poll_rx(void *param, int budget)
 
 		skb_put(skb, len);
 	push_packet:
+		if (skb->len < ETH_HLEN) {
+			dev_kfree_skb(skb);
+			printk(KERN_WARNING "%s: short packets dropped\n",
+			       dev->ndev->name);
+			++dev->estats.rx_dropped_stack;
+			goto next;
+		}
 		skb->dev = dev->ndev;
 		skb->protocol = eth_type_trans(skb, dev->ndev);
 		emac_rx_csum(dev, skb, ctrl);
Signature · 1 line
1.5.6
#1 lore raw
Quoted 5 lines · Stefan Roese

From: Sathya Narayanan <[email protected]>

Short packets has to be discarded by the driver. So this patch addresses the issue of discarding the short packets of size lesser then ethernet header size.

You are freeing the skb, why ? Shouldn't we just keep the skb in the ring for further rx ?

Quoted 24 lines
---
 drivers/net/ibm_newemac/core.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/net/ibm_newemac/core.c +7 -0
index 6dfc2c9..aa407b2 100644
@@ -1652,6 +1652,13 @@ static int emac_poll_rx(void *param, int budget)
 
 		skb_put(skb, len);
 	push_packet:
+		if (skb->len < ETH_HLEN) {
+			dev_kfree_skb(skb);
+			printk(KERN_WARNING "%s: short packets dropped\n",
+			       dev->ndev->name);
+			++dev->estats.rx_dropped_stack;
+			goto next;
+		}
 		skb->dev = dev->ndev;
 		skb->protocol = eth_type_trans(skb, dev->ndev);
 		emac_rx_csum(dev, skb, ctrl);
#2 lore raw

Hi benh,

Please find my comments inline.

Quoted 10 lines · Benjamin Herrenschmidt
Quoted 3 lines · Stefan Roese

From: Sathya Narayanan <[email protected]>

Short packets has to be discarded by the driver. So this patch addresses

the

Quoted 2 lines

issue of discarding the short packets of size lesser then ethernet header size.

You are freeing the skb, why ? Shouldn't we just keep the skb in the ring for further rx ?

Actually , short packets are not allowed to flow through the higher layers, If any of the layer tried to use the extra room available may hit wit crash .
Since it is a invalid packet it has to be dropped and freed in driver. Actually if you see in code, the other invalid packets are also handelled similar.

Quoted 14 lines

Review

Quoted 8 lines
---
 drivers/net/ibm_newemac/core.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ibm_newemac/core.c

Quoted 5 lines

index 6dfc2c9..aa407b2 100644

drivers/net/ibm_newemac/core.c +0 -0
@@ -1652,6 +1652,13 @@ static int emac_poll_rx(void *param, int budget)
 
Quoted 14 lines

drivers/net/ibm_newemac/core.c static int emac_poll_rx(void *param, int budget) · line 1664

Quoted 12 lines
drivers/net/ibm_newemac/core.c +7 -0
              skb_put(skb, len);
      push_packet:
+             if (skb->len < ETH_HLEN) {
+                     dev_kfree_skb(skb);
+                     printk(KERN_WARNING "%s: short packets dropped\n",
+                            dev->ndev->name);
+                     ++dev->estats.rx_dropped_stack;
+                     goto next;
+             }
              skb->dev = dev->ndev;
              skb->protocol = eth_type_trans(skb, dev->ndev);
              emac_rx_csum(dev, skb, ctrl);

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#3 lore raw
Quoted 9 lines

Actually , short packets are not allowed to flow through the higher layers, If any of the layer tried to use the extra room available may hit wit crash .
Since it is a invalid packet it has to be dropped and freed in driver. Actually if you see in code, the other invalid packets are also handelled similar.

My point is they should not. The rx skb should be kept in the ring for further rx (ie, the data ignored and re-use the skb). A bit like we do when we decide the packet is small enough to be copied to a new skb.

Ie. Move you test above the threshold test and recycle the skb.

We need to fix the usage of the dma operations in this driver anyway and this will make it easier as we'll be able to avoid re-mapping an skb we just recycle. (the current driver never unmaps which means it can't be used with an iommu, which is a problem on some cell based platforms).

Ben.