aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2005-06-21 17:01:30 -0400
committerDavid S. Miller <davem@davemloft.net>2005-06-21 17:01:30 -0400
commite45b1be8bcb3643808975a426fa3e201a2588e87 (patch)
tree0c461d7bd90d0c2fb462b42e664cf8a099c750ec /include/linux
parentc9e3e8b6958e02230079e6817862ea2968509866 (diff)
[NETFILTER]: Kill lockhelp.h
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_core.h3
-rw-r--r--include/linux/netfilter_ipv4/ip_nat.h3
-rw-r--r--include/linux/netfilter_ipv4/listhelp.h1
-rw-r--r--include/linux/netfilter_ipv4/lockhelp.h129
4 files changed, 2 insertions, 134 deletions
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_core.h b/include/linux/netfilter_ipv4/ip_conntrack_core.h
index d84be02cb4fc..694aec9b4784 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_core.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_core.h
@@ -1,7 +1,6 @@
1#ifndef _IP_CONNTRACK_CORE_H 1#ifndef _IP_CONNTRACK_CORE_H
2#define _IP_CONNTRACK_CORE_H 2#define _IP_CONNTRACK_CORE_H
3#include <linux/netfilter.h> 3#include <linux/netfilter.h>
4#include <linux/netfilter_ipv4/lockhelp.h>
5 4
6/* This header is used to share core functionality between the 5/* This header is used to share core functionality between the
7 standalone connection tracking module, and the compatibility layer's use 6 standalone connection tracking module, and the compatibility layer's use
@@ -47,6 +46,6 @@ static inline int ip_conntrack_confirm(struct sk_buff **pskb)
47 46
48extern struct list_head *ip_conntrack_hash; 47extern struct list_head *ip_conntrack_hash;
49extern struct list_head ip_conntrack_expect_list; 48extern struct list_head ip_conntrack_expect_list;
50DECLARE_RWLOCK_EXTERN(ip_conntrack_lock); 49extern rwlock_t ip_conntrack_lock;
51#endif /* _IP_CONNTRACK_CORE_H */ 50#endif /* _IP_CONNTRACK_CORE_H */
52 51
diff --git a/include/linux/netfilter_ipv4/ip_nat.h b/include/linux/netfilter_ipv4/ip_nat.h
index 2b72b86176f0..e201ec6e9905 100644
--- a/include/linux/netfilter_ipv4/ip_nat.h
+++ b/include/linux/netfilter_ipv4/ip_nat.h
@@ -50,10 +50,9 @@ struct ip_nat_multi_range_compat
50 50
51#ifdef __KERNEL__ 51#ifdef __KERNEL__
52#include <linux/list.h> 52#include <linux/list.h>
53#include <linux/netfilter_ipv4/lockhelp.h>
54 53
55/* Protects NAT hash tables, and NAT-private part of conntracks. */ 54/* Protects NAT hash tables, and NAT-private part of conntracks. */
56DECLARE_RWLOCK_EXTERN(ip_nat_lock); 55extern rwlock_t ip_nat_lock;
57 56
58/* The structure embedded in the conntrack structure. */ 57/* The structure embedded in the conntrack structure. */
59struct ip_nat_info 58struct ip_nat_info
diff --git a/include/linux/netfilter_ipv4/listhelp.h b/include/linux/netfilter_ipv4/listhelp.h
index f2ae7c5e57bb..360429f48737 100644
--- a/include/linux/netfilter_ipv4/listhelp.h
+++ b/include/linux/netfilter_ipv4/listhelp.h
@@ -2,7 +2,6 @@
2#define _LISTHELP_H 2#define _LISTHELP_H
3#include <linux/config.h> 3#include <linux/config.h>
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/netfilter_ipv4/lockhelp.h>
6 5
7/* Header to do more comprehensive job than linux/list.h; assume list 6/* Header to do more comprehensive job than linux/list.h; assume list
8 is first entry in structure. */ 7 is first entry in structure. */
diff --git a/include/linux/netfilter_ipv4/lockhelp.h b/include/linux/netfilter_ipv4/lockhelp.h
deleted file mode 100644
index a3288633ab46..000000000000
--- a/include/linux/netfilter_ipv4/lockhelp.h
+++ /dev/null
@@ -1,129 +0,0 @@
1#ifndef _LOCKHELP_H
2#define _LOCKHELP_H
3#include <linux/config.h>
4
5#include <linux/spinlock.h>
6#include <asm/atomic.h>
7#include <linux/interrupt.h>
8#include <linux/smp.h>
9
10/* Header to do help in lock debugging. */
11
12#ifdef CONFIG_NETFILTER_DEBUG
13struct spinlock_debug
14{
15 spinlock_t l;
16 atomic_t locked_by;
17};
18
19struct rwlock_debug
20{
21 rwlock_t l;
22 long read_locked_map;
23 long write_locked_map;
24};
25
26#define DECLARE_LOCK(l) \
27struct spinlock_debug l = { SPIN_LOCK_UNLOCKED, ATOMIC_INIT(-1) }
28#define DECLARE_LOCK_EXTERN(l) \
29extern struct spinlock_debug l
30#define DECLARE_RWLOCK(l) \
31struct rwlock_debug l = { RW_LOCK_UNLOCKED, 0, 0 }
32#define DECLARE_RWLOCK_EXTERN(l) \
33extern struct rwlock_debug l
34
35#define MUST_BE_LOCKED(l) \
36do { if (atomic_read(&(l)->locked_by) != smp_processor_id()) \
37 printk("ASSERT %s:%u %s unlocked\n", __FILE__, __LINE__, #l); \
38} while(0)
39
40#define MUST_BE_UNLOCKED(l) \
41do { if (atomic_read(&(l)->locked_by) == smp_processor_id()) \
42 printk("ASSERT %s:%u %s locked\n", __FILE__, __LINE__, #l); \
43} while(0)
44
45/* Write locked OK as well. */
46#define MUST_BE_READ_LOCKED(l) \
47do { if (!((l)->read_locked_map & (1UL << smp_processor_id())) \
48 && !((l)->write_locked_map & (1UL << smp_processor_id()))) \
49 printk("ASSERT %s:%u %s not readlocked\n", __FILE__, __LINE__, #l); \
50} while(0)
51
52#define MUST_BE_WRITE_LOCKED(l) \
53do { if (!((l)->write_locked_map & (1UL << smp_processor_id()))) \
54 printk("ASSERT %s:%u %s not writelocked\n", __FILE__, __LINE__, #l); \
55} while(0)
56
57#define MUST_BE_READ_WRITE_UNLOCKED(l) \
58do { if ((l)->read_locked_map & (1UL << smp_processor_id())) \
59 printk("ASSERT %s:%u %s readlocked\n", __FILE__, __LINE__, #l); \
60 else if ((l)->write_locked_map & (1UL << smp_processor_id())) \
61 printk("ASSERT %s:%u %s writelocked\n", __FILE__, __LINE__, #l); \
62} while(0)
63
64#define LOCK_BH(lk) \
65do { \
66 MUST_BE_UNLOCKED(lk); \
67 spin_lock_bh(&(lk)->l); \
68 atomic_set(&(lk)->locked_by, smp_processor_id()); \
69} while(0)
70
71#define UNLOCK_BH(lk) \
72do { \
73 MUST_BE_LOCKED(lk); \
74 atomic_set(&(lk)->locked_by, -1); \
75 spin_unlock_bh(&(lk)->l); \
76} while(0)
77
78#define READ_LOCK(lk) \
79do { \
80 MUST_BE_READ_WRITE_UNLOCKED(lk); \
81 read_lock_bh(&(lk)->l); \
82 set_bit(smp_processor_id(), &(lk)->read_locked_map); \
83} while(0)
84
85#define WRITE_LOCK(lk) \
86do { \
87 MUST_BE_READ_WRITE_UNLOCKED(lk); \
88 write_lock_bh(&(lk)->l); \
89 set_bit(smp_processor_id(), &(lk)->write_locked_map); \
90} while(0)
91
92#define READ_UNLOCK(lk) \
93do { \
94 if (!((lk)->read_locked_map & (1UL << smp_processor_id()))) \
95 printk("ASSERT: %s:%u %s not readlocked\n", \
96 __FILE__, __LINE__, #lk); \
97 clear_bit(smp_processor_id(), &(lk)->read_locked_map); \
98 read_unlock_bh(&(lk)->l); \
99} while(0)
100
101#define WRITE_UNLOCK(lk) \
102do { \
103 MUST_BE_WRITE_LOCKED(lk); \
104 clear_bit(smp_processor_id(), &(lk)->write_locked_map); \
105 write_unlock_bh(&(lk)->l); \
106} while(0)
107
108#else
109#define DECLARE_LOCK(l) spinlock_t l = SPIN_LOCK_UNLOCKED
110#define DECLARE_LOCK_EXTERN(l) extern spinlock_t l
111#define DECLARE_RWLOCK(l) rwlock_t l = RW_LOCK_UNLOCKED
112#define DECLARE_RWLOCK_EXTERN(l) extern rwlock_t l
113
114#define MUST_BE_LOCKED(l)
115#define MUST_BE_UNLOCKED(l)
116#define MUST_BE_READ_LOCKED(l)
117#define MUST_BE_WRITE_LOCKED(l)
118#define MUST_BE_READ_WRITE_UNLOCKED(l)
119
120#define LOCK_BH(l) spin_lock_bh(l)
121#define UNLOCK_BH(l) spin_unlock_bh(l)
122
123#define READ_LOCK(l) read_lock_bh(l)
124#define WRITE_LOCK(l) write_lock_bh(l)
125#define READ_UNLOCK(l) read_unlock_bh(l)
126#define WRITE_UNLOCK(l) write_unlock_bh(l)
127#endif /*CONFIG_NETFILTER_DEBUG*/
128
129#endif /* _LOCKHELP_H */