patch-1.3.83 linux/net/core/firewall.c

Next file: linux/net/ipv4/tcp_input.c
Previous file: linux/mm/vmscan.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.82/linux/net/core/firewall.c linux/net/core/firewall.c
@@ -41,13 +41,18 @@
 		p=&((*p)->next);
 	}
 
-	fw->next=*p;
+	
 	/*
-	 *	We need to set p atomically in case someone runs down the list
-	 *	at the wrong moment. This saves locking it 
+	 * We need to use a memory barrier to make sure that this
+	 * works correctly even in SMP with weakly ordered writes.
+	 *
+	 * This is atomic wrt interrupts (and generally walking the
+	 * chain), but not wrt itself (so you can't call this from
+	 * an interrupt. Not that you'd want to).
 	 */
-	 
-	xchg(p,fw);
+	fw->next=*p;
+	mb();
+	*p = fw;
 
 	/*
 	 *	And release the sleep lock
@@ -83,7 +88,7 @@
 		if(*nl==fw)
 		{
 			struct firewall_ops *f=fw->next;
-			xchg(nl,f);
+			*nl = f;
 			firewall_lock=0;
 			return 0;
 		}			

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this