[865] in linux-net channel archive

home help back first fref pref prev next nref lref last post

patch for skbuff.c

daemon@ATHENA.MIT.EDU (Felix A. KOOP)
Fri Aug 11 00:27:52 1995

Date: Thu, 10 Aug 1995 09:03:12 +0200 (MET DST)
From: "Felix A. KOOP" <koop@biene.u-strasbg.fr>
To: Alan Cox <iialan@iifeak.swan.ac.uk>
cc: linux-net@vger.rutgers.edu


Hi,

after reading the source of skbuff.c I'm not quite sure why there are
not cli()/sti() pairs on all accesses to the global variables. I included
a patch for the rest. If it's not neccessary, perhaps you can tell me why?

While reading I also found a double line in procedure alloc_skb.
skb->localroute is set to 0 twice. 

Greetings

Felix A. Koop (Felix.Koop@ensps.u-strasbg.fr)

<A HREF="http://sneezy.u-strasbg.fr/~felix/">Felix A. Koop</A>

Disclaimer:  Any suggestions, comments, or ideas promulgated are absolutely
and positively disclaimed to be claimed for the purposes herein, whereas, and
therefore.  Any resemblance to intelligent ideas are purely coincidental.

diff -u skbuff.c.old skbuff.c
--- skbuff.c.old	Thu Aug 10 08:41:27 1995
+++ skbuff.c	Thu Aug 10 08:53:04 1995
@@ -446,7 +446,10 @@
 	if (skb->lock)
 	{
 		skb->free = 3;    /* Free when unlocked */
+		save_flags(flags);
+		cli();
 		net_free_locked++;
+		restore_flags(flags);
 		return;
   	}
   	if (skb->free == 2)
@@ -516,7 +519,10 @@
 	bptr=(unsigned char *)kmalloc(size,priority);
 	if (bptr == NULL)
 	{
+		save_flags(flags);
+		cli();
 		net_fails++;
+		restore_flags(flags);
 		return NULL;
 	}
 #ifdef PARANOID_BUGHUNT_MODE
@@ -530,7 +536,10 @@
 	 *	by doing the following. Which is to deliberately put the
 	 *	skb at the _end_ not the start of the memory block.
 	 */
+	save_flags(flags);
+	cli();
 	net_allocs++;
+	restore_flags(flags);
 	
 	skb=(struct sk_buff *)(bptr+size)-1;
 
@@ -541,7 +550,6 @@
 	skb->link3 = NULL;
 	skb->sk = NULL;
 	skb->truesize=size;
-	skb->localroute=0;
 	skb->stamp.tv_sec=0;	/* No idea about time */
 	skb->localroute = 0;
 	skb->ip_summed = 0;
@@ -642,7 +650,12 @@
 	if(skb->lock)
 		printk("double lock on device queue!\n");
 	else
+		{
+		save_flags(flags);
+		cli();
 		net_locked++;
+		restore_flags(flags);
+		}
 	skb->lock++;
 }
 
@@ -652,7 +665,12 @@
 		printk("double unlock on device queue!\n");
 	skb->lock--;
 	if(skb->lock==0)
+		{
+		save_flags(flags);
+		cli();
 		net_locked--;
+		restore(flags(flags);
+		}
 }
 
 void dev_kfree_skb(struct sk_buff *skb, int mode)

home help back first fref pref prev next nref lref last post