patch-2.1.25 linux/net/core/firewall.c
Next file: linux/net/core/iovec.c
Previous file: linux/net/core/dev.c
Back to the patch index
Back to the overall index
- Lines: 77
- Date:
Sun Feb 2 15:18:49 1997
- Orig file:
v2.1.24/linux/net/core/firewall.c
- Orig date:
Wed Jan 15 19:45:47 1997
diff -u --recursive --new-file v2.1.24/linux/net/core/firewall.c linux/net/core/firewall.c
@@ -10,8 +10,9 @@
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/firewall.h>
+#include <asm/semaphore.h>
-static int firewall_lock=0;
+struct semaphore firewall_sem = MUTEX;
static int firewall_policy[NPROTO];
static struct firewall_ops *firewall_chain[NPROTO];
@@ -30,13 +31,7 @@
* Don't allow two people to adjust at once.
*/
- /*
- * FIXME: Swap for a kernel semaphore object
- */
-
- while(firewall_lock)
- schedule();
- firewall_lock=1;
+ down(&firewall_sem);
p=&firewall_chain[pf];
@@ -47,7 +42,6 @@
p=&((*p)->next);
}
-
/*
* We need to use a memory barrier to make sure that this
* works correctly even in SMP with weakly ordered writes.
@@ -56,6 +50,7 @@
* chain), but not wrt itself (so you can't call this from
* an interrupt. Not that you'd want to).
*/
+
fw->next=*p;
mb();
*p = fw;
@@ -64,7 +59,7 @@
* And release the sleep lock
*/
- firewall_lock=0;
+ up(&firewall_sem);
return 0;
}
@@ -83,9 +78,7 @@
* Don't allow two people to adjust at once.
*/
- while(firewall_lock)
- schedule();
- firewall_lock=1;
+ down(&firewall_sem);
nl=&firewall_chain[pf];
@@ -95,12 +88,12 @@
{
struct firewall_ops *f=fw->next;
*nl = f;
- firewall_lock=0;
+ up(&firewall_sem);
return 0;
}
nl=&((*nl)->next);
}
- firewall_lock=0;
+ up(&firewall_sem);
return -ENOENT;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov