Skip to contentSkip to conversation

3c589_cs: don't reference skb after passing it to netif_rx

PATCH In review Arnaldo Carvalho de Melo 2 participants 5 messages Feb 27, 2001

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 3c589_cs: don't reference skb after passing it to netif_rx

now to pcmcia ones

Em Mon, Feb 26, 2001 at 08:33:59PM -0300, Arnaldo Carvalho de Melo escreveu:
Hi,

I've just read davem's post at netdev about the brokeness of
referencing skbs after passing it to netif_rx, so please consider applying this patch. Ah, this was just added to the Janitor's TODO list at
http://bazar.conectiva.com.br/~acme/TODO and I'm doing a quick audit in the net drivers searching for this, maybe some more patches will follow.

- Arnaldo

drivers/net/pcmcia/3c589_cs.c +1 -1
@@ -992,9 +992,9 @@
 			(pkt_len+3)>>2);
 		skb->protocol = eth_type_trans(skb, dev);
 		
+		lp->stats.rx_bytes += skb->len;
 		netif_rx(skb);
 		lp->stats.rx_packets++;
-		lp->stats.rx_bytes += skb->len;
 	    } else {
 		DEBUG(1, "%s: couldn't allocate a sk_buff of"
 		      " size %d.\n", dev->name, pkt_len);
#1 lore raw

drivers/net/pcmcia/3c589_cs.c Mon Feb 26 22:44:00 2001 line 997

Quoted 10 lines · Arnaldo Carvalho de Melo
drivers/net/pcmcia/3c589_cs.c Mon Feb 26 22:44:00 2001 renamed from drivers/net/pcmcia/3c589_cs.c Tue Feb 13 19:15:05 2001 +1 -1
@@ -992,9 +992,9 @@
                        (pkt_len+3)>>2);
                skb->protocol = eth_type_trans(skb, dev);
 
+               lp->stats.rx_bytes += skb->len;
                netif_rx(skb);
                lp->stats.rx_packets++;
-               lp->stats.rx_bytes += skb->len;

I prefer the attached patch instead. It makes use of the existing local 'pkt_len', and it checks off another item that should probably be on the janitor's todo list: Set 'dev->last_rx=jiffies' immediately after netif_rx.

Jeff

Signature · 3 lines
Jeff Garzik       | "You see, in this world there's two kinds of
Building 1024     |  people, my friend: Those with loaded guns
MandrakeSoft      |  and those who dig. You dig."  --Blondie

Index: drivers/net/pcmcia/3c589_cs.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/net/pcmcia/3c589_cs.c,v retrieving revision 1.1.1.10.18.1

net/pcmcia/3c589_cs.c +2 -1
diff -u -r1.1.1.10.18.1 3c589_cs.c
@@ -993,8 +993,9 @@
 		skb->protocol = eth_type_trans(skb, dev);
 		
 		netif_rx(skb);
+		dev->last_rx = jiffies;
 		lp->stats.rx_packets++;
-		lp->stats.rx_bytes += skb->len;
+		lp->stats.rx_bytes += pkt_len;
 	    } else {
 		DEBUG(1, "%s: couldn't allocate a sk_buff of"
 		      " size %d.\n", dev->name, pkt_len);
#2 lore raw
In reply to Arnaldo Carvalho de Melo

Em Mon, Feb 26, 2001 at 08:56:06PM -0500, Jeff Garzik escreveu:

Quoted 7 lines
Quoted 6 lines · Arnaldo Carvalho de Melo
drivers/net/pcmcia/3c589_cs.c Mon Feb 26 22:44:00 2001 renamed from drivers/net/pcmcia/3c589_cs.c Tue Feb 13 19:15:05 2001 +0 -0
@@ -992,9 +992,9 @@
                        (pkt_len+3)>>2);
                skb->protocol = eth_type_trans(skb, dev);
 
Quoted 9 lines

drivers/net/pcmcia/3c589_cs.c Mon Feb 26 22:44:00 2001 line 997

Quoted 4 lines
drivers/net/pcmcia/3c589_cs.c Mon Feb 26 22:44:00 2001 renamed from drivers/net/pcmcia/3c589_cs.c Tue Feb 13 19:15:05 2001 +1 -1
+               lp->stats.rx_bytes += skb->len;
                netif_rx(skb);
                lp->stats.rx_packets++;
-               lp->stats.rx_bytes += skb->len;

I prefer the attached patch instead. It makes use of the existing local 'pkt_len', and it checks off another item that should probably be on the janitor's todo list: Set 'dev->last_rx=jiffies' immediately after netif_rx.

Thanks, I've added your comments and Donald one about grouping the stat updates, as always the Janitor's TODO list is available at
http://bazar.conectiva.com.br/~acme/TODO, so get your broom and keep on cleaning 8)

- Arnaldo

#3 lore raw
In reply to Arnaldo Carvalho de Melo

And here are the rest of the ones in pcmcia.

Signature · 3 lines
Jeff Garzik       | "You see, in this world there's two kinds of
Building 1024     |  people, my friend: Those with loaded guns
MandrakeSoft      |  and those who dig. You dig."  --Blondie

Index: drivers/net/pcmcia/3c574_cs.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/net/pcmcia/3c574_cs.c,v retrieving revision 1.1.1.11

net/pcmcia/3c574_cs.c +2 -0
diff -u -r1.1.1.11 3c574_cs.c
@@ -1166,7 +1166,9 @@
 
 				skb->protocol = eth_type_trans(skb, dev);
 				netif_rx(skb);
+				dev->last_rx = jiffies;
 				lp->stats.rx_packets++;
+				lp->stats.rx_bytes += pkt_len;
 			} else {
 				DEBUG(1, "%s: couldn't allocate a sk_buff of"
 					  " size %d.\n", dev->name, pkt_len);

Index: drivers/net/pcmcia/netwave_cs.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/net/pcmcia/netwave_cs.c,v retrieving revision 1.1.1.8

net/pcmcia/netwave_cs.c +5 -5
diff -u -r1.1.1.8 netwave_cs.c
@@ -1463,16 +1463,16 @@
 	skb->protocol = eth_type_trans(skb,dev);
 	/* Queue packet for network layer */
 	netif_rx(skb);
-		
+
+	dev->last_rx = jiffies;
+	priv->stats.rx_packets++;
+	priv->stats.rx_bytes += rcvLen;
+
 	/* Got the packet, tell the adapter to skip it */
 	wait_WOC(iobase);
 	writeb(NETWAVE_CMD_SRP, ramBase + NETWAVE_EREG_CB + 0);
 	writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1);
 	DEBUG(3, "Packet reception ok\n");
-		
-	priv->stats.rx_packets++;
-
-	priv->stats.rx_bytes += skb->len;
     }
     return 0;
 }

Index: drivers/net/pcmcia/nmclan_cs.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/net/pcmcia/nmclan_cs.c,v retrieving revision 1.1.1.9

net/pcmcia/nmclan_cs.c +2 -2
diff -u -r1.1.1.9 nmclan_cs.c
@@ -1288,9 +1288,9 @@
 	skb->protocol = eth_type_trans(skb, dev);
 	
 	netif_rx(skb); /* Send the packet to the upper (protocol) layers. */
-
+	dev->last_rx = jiffies;
 	lp->linux_stats.rx_packets++;
-	lp->linux_stats.rx_bytes += skb->len;
+	lp->linux_stats.rx_bytes += pkt_len;
 	outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */
 	continue;
       } else {

Index: drivers/net/pcmcia/ray_cs.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/net/pcmcia/ray_cs.c,v retrieving revision 1.1.1.8

net/pcmcia/ray_cs.c +2 -2
diff -u -r1.1.1.8 ray_cs.c
@@ -2219,9 +2219,9 @@
 
     skb->protocol = eth_type_trans(skb,dev);
     netif_rx(skb);
-
+    dev->last_rx = jiffies;
     local->stats.rx_packets++;
-    local->stats.rx_bytes += skb->len;
+    local->stats.rx_bytes += total_len;
 
     /* Gather signal strength per address */
 #ifdef WIRELESS_SPY

Index: drivers/net/pcmcia/smc91c92_cs.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/net/pcmcia/smc91c92_cs.c,v retrieving revision 1.1.1.12.2.2

net/pcmcia/smc91c92_cs.c +2 -1
diff -u -r1.1.1.12.2.2 smc91c92_cs.c
@@ -1617,8 +1617,9 @@
 	
 	skb->dev = dev;
 	netif_rx(skb);
+	dev->last_rx = jiffies;
 	smc->stats.rx_packets++;
-	smc->stats.rx_bytes += skb->len;
+	smc->stats.rx_bytes += packet_length;
 	if (rx_status & RS_MULTICAST)
 	    smc->stats.multicast++;
     } else {

Index: drivers/net/pcmcia/wavelan_cs.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/net/pcmcia/wavelan_cs.c,v retrieving revision 1.1.1.16.2.1

net/pcmcia/wavelan_cs.c +2 -1
diff -u -r1.1.1.16.2.1 wavelan_cs.c
@@ -2733,8 +2733,9 @@
   netif_rx(skb);
 
   /* Keep stats up to date */
+  dev->last_rx = jiffies;
   lp->stats.rx_packets++;
-  lp->stats.rx_bytes += skb->len;
+  lp->stats.rx_bytes += sksize;
 
 #ifdef DEBUG_RX_TRACE
   printk(KERN_DEBUG "%s: <-wv_packet_read()\n", dev->name);

Index: drivers/net/pcmcia/xirc2ps_cs.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/net/pcmcia/xirc2ps_cs.c,v retrieving revision 1.1.1.14.2.2

net/pcmcia/xirc2ps_cs.c +1 -0
diff -u -r1.1.1.14.2.2 xirc2ps_cs.c
@@ -1420,6 +1420,7 @@
 		skb->protocol = eth_type_trans(skb, dev);
 		skb->dev = dev;
 		netif_rx(skb);
+		dev->last_rx = jiffies;
 		lp->stats.rx_packets++;
 		lp->stats.rx_bytes += pktlen;
 		if (!(rsr & PhyPkt))
#4 lore raw
In reply to Arnaldo Carvalho de Melo

Em Mon, Feb 26, 2001 at 09:07:49PM -0500, Jeff Garzik escreveu:

Quoted 1 line

And here are the rest of the ones in pcmcia.

Hey man, thats what I call cooperation 8) I was now on the netwave one, but had to stop to get another beer, when I came back... Jeff, go get a beer please, I'll pay you by March, 31, if I meet you in California 8)

- Arnaldo