Skip to contentSkip to conversation

3C509: rx_bytes should not be increased when alloc_skb failed

PATCH Applied Wang Chen 2 participants 3 messages May 20, 2008 – May 22, 2008

Subsystems (2)
lore
Share & tools
lore

Wang Chen

author
#0 lore raw

PATCH 1/2 3C509: rx_bytes should not be increased when alloc_skb failed

If alloc_skb failed, the recieved packet will be dropped. Do not increase rx_bytes for dropped packet.

---
 drivers/net/3c509.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/3c509.c +1 -1
index e6c545f..fe6d841 100644
@@ -1063,7 +1063,6 @@ el3_rx(struct net_device *dev)
 			struct sk_buff *skb;
 
 			skb = dev_alloc_skb(pkt_len+5);
-			dev->stats.rx_bytes += pkt_len;
 			if (el3_debug > 4)
 				printk("Receiving packet size %d status %4.4x.\n",
 					   pkt_len, rx_status);
@@ -1078,6 +1077,7 @@ el3_rx(struct net_device *dev)
 				skb->protocol = eth_type_trans(skb,dev);
 				netif_rx(skb);
 				dev->last_rx = jiffies;
+				dev->stats.rx_bytes += pkt_len;
 				dev->stats.rx_packets++;
 				continue;
 			}
Signature · 1 line
1.5.3.4
author
#1 lore raw

PATCH 2/2 ibmveth: make sure skb is not null

There is no assurance to guarantee ibmveth_rxq_get_buffer won't return a NULL. So add an assertion here.

No device, not tested.

---
 drivers/net/ibmveth.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/ibmveth.c +1 -0
index 0052780..9d1523a 100644
@@ -945,6 +945,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
 			int csum_good = ibmveth_rxq_csum_good(adapter);
 
 			skb = ibmveth_rxq_get_buffer(adapter);
+			ibmveth_assert(skb != NULL);
 			if (csum_good)
 				skb->ip_summed = CHECKSUM_UNNECESSARY;
 
Signature · 1 line
1.5.3.4
Applied
#2 lore raw
In reply to Wang Chen
Quoted 21 lines · Wang Chen

If alloc_skb failed, the recieved packet will be dropped. Do not increase rx_bytes for dropped packet.

---
 drivers/net/3c509.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/3c509.c +0 -1
index e6c545f..fe6d841 100644
@@ -1063,7 +1063,6 @@ el3_rx(struct net_device *dev)
 			struct sk_buff *skb;
 
 			skb = dev_alloc_skb(pkt_len+5);
-			dev->stats.rx_bytes += pkt_len;
 			if (el3_debug > 4)
 				printk("Receiving packet size %d status %4.4x.\n",
 					   pkt_len, rx_status);

drivers/net/3c509.c el3_rx(struct net_device *dev) · line 1082

Quoted 6 lines
drivers/net/3c509.c +1 -0
@@ -1078,6 +1077,7 @@ el3_rx(struct net_device *dev)
 				skb->protocol = eth_type_trans(skb,dev);
 				netif_rx(skb);
 				dev->last_rx = jiffies;
+				dev->stats.rx_bytes += pkt_len;
 				dev->stats.rx_packets++;
 				continue;

applied