diff options
| author | Patrick McHardy <kaber@trash.net> | 2008-01-31 07:38:58 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2008-01-31 22:27:54 -0500 |
| commit | f8ba1affa18398610e765736153fff614309ccc8 (patch) | |
| tree | b2143ef65aa92e5995070824798b04d935044e24 | |
| parent | 76507f69c44ed199a1a68086145398459e55835d (diff) | |
[NETFILTER]: nf_conntrack: switch rwlock to spinlock
With the RCU conversion only write_lock usages of nf_conntrack_lock are
left (except one read_lock that should actually use write_lock in the
H.323 helper). Switch to a spinlock.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | include/net/netfilter/nf_conntrack_core.h | 2 | ||||
| -rw-r--r-- | net/netfilter/nf_conntrack_core.c | 38 | ||||
| -rw-r--r-- | net/netfilter/nf_conntrack_expect.c | 12 | ||||
| -rw-r--r-- | net/netfilter/nf_conntrack_h323_main.c | 4 | ||||
| -rw-r--r-- | net/netfilter/nf_conntrack_helper.c | 4 | ||||
| -rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 22 |
6 files changed, 41 insertions, 41 deletions
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h index 7ad0828f05cf..2b9e5713585a 100644 --- a/include/net/netfilter/nf_conntrack_core.h +++ b/include/net/netfilter/nf_conntrack_core.h | |||
| @@ -72,7 +72,7 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, | |||
| 72 | struct nf_conntrack_l4proto *proto); | 72 | struct nf_conntrack_l4proto *proto); |
| 73 | 73 | ||
| 74 | extern struct hlist_head *nf_conntrack_hash; | 74 | extern struct hlist_head *nf_conntrack_hash; |
| 75 | extern rwlock_t nf_conntrack_lock ; | 75 | extern spinlock_t nf_conntrack_lock ; |
| 76 | extern struct hlist_head unconfirmed; | 76 | extern struct hlist_head unconfirmed; |
| 77 | 77 | ||
| 78 | #endif /* _NF_CONNTRACK_CORE_H */ | 78 | #endif /* _NF_CONNTRACK_CORE_H */ |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index a54bfec61e79..f284dddfc899 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
| @@ -40,7 +40,7 @@ | |||
| 40 | 40 | ||
| 41 | #define NF_CONNTRACK_VERSION "0.5.0" | 41 | #define NF_CONNTRACK_VERSION "0.5.0" |
| 42 | 42 | ||
| 43 | DEFINE_RWLOCK(nf_conntrack_lock); | 43 | DEFINE_SPINLOCK(nf_conntrack_lock); |
| 44 | EXPORT_SYMBOL_GPL(nf_conntrack_lock); | 44 | EXPORT_SYMBOL_GPL(nf_conntrack_lock); |
| 45 | 45 | ||
| 46 | /* nf_conntrack_standalone needs this */ | 46 | /* nf_conntrack_standalone needs this */ |
| @@ -199,7 +199,7 @@ destroy_conntrack(struct nf_conntrack *nfct) | |||
| 199 | 199 | ||
| 200 | rcu_read_unlock(); | 200 | rcu_read_unlock(); |
| 201 | 201 | ||
| 202 | write_lock_bh(&nf_conntrack_lock); | 202 | spin_lock_bh(&nf_conntrack_lock); |
| 203 | /* Expectations will have been removed in clean_from_lists, | 203 | /* Expectations will have been removed in clean_from_lists, |
| 204 | * except TFTP can create an expectation on the first packet, | 204 | * except TFTP can create an expectation on the first packet, |
| 205 | * before connection is in the list, so we need to clean here, | 205 | * before connection is in the list, so we need to clean here, |
| @@ -213,7 +213,7 @@ destroy_conntrack(struct nf_conntrack *nfct) | |||
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | NF_CT_STAT_INC(delete); | 215 | NF_CT_STAT_INC(delete); |
| 216 | write_unlock_bh(&nf_conntrack_lock); | 216 | spin_unlock_bh(&nf_conntrack_lock); |
| 217 | 217 | ||
| 218 | if (ct->master) | 218 | if (ct->master) |
| 219 | nf_ct_put(ct->master); | 219 | nf_ct_put(ct->master); |
| @@ -236,12 +236,12 @@ static void death_by_timeout(unsigned long ul_conntrack) | |||
| 236 | rcu_read_unlock(); | 236 | rcu_read_unlock(); |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | write_lock_bh(&nf_conntrack_lock); | 239 | spin_lock_bh(&nf_conntrack_lock); |
| 240 | /* Inside lock so preempt is disabled on module removal path. | 240 | /* Inside lock so preempt is disabled on module removal path. |
| 241 | * Otherwise we can get spurious warnings. */ | 241 | * Otherwise we can get spurious warnings. */ |
| 242 | NF_CT_STAT_INC(delete_list); | 242 | NF_CT_STAT_INC(delete_list); |
| 243 | clean_from_lists(ct); | 243 | clean_from_lists(ct); |
| 244 | write_unlock_bh(&nf_conntrack_lock); | 244 | spin_unlock_bh(&nf_conntrack_lock); |
| 245 | nf_ct_put(ct); | 245 | nf_ct_put(ct); |
| 246 | } | 246 | } |
| 247 | 247 | ||
| @@ -303,9 +303,9 @@ void nf_conntrack_hash_insert(struct nf_conn *ct) | |||
| 303 | hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); | 303 | hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); |
| 304 | repl_hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple); | 304 | repl_hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple); |
| 305 | 305 | ||
| 306 | write_lock_bh(&nf_conntrack_lock); | 306 | spin_lock_bh(&nf_conntrack_lock); |
| 307 | __nf_conntrack_hash_insert(ct, hash, repl_hash); | 307 | __nf_conntrack_hash_insert(ct, hash, repl_hash); |
| 308 | write_unlock_bh(&nf_conntrack_lock); | 308 | spin_unlock_bh(&nf_conntrack_lock); |
| 309 | } | 309 | } |
| 310 | EXPORT_SYMBOL_GPL(nf_conntrack_hash_insert); | 310 | EXPORT_SYMBOL_GPL(nf_conntrack_hash_insert); |
| 311 | 311 | ||
| @@ -342,7 +342,7 @@ __nf_conntrack_confirm(struct sk_buff *skb) | |||
| 342 | NF_CT_ASSERT(!nf_ct_is_confirmed(ct)); | 342 | NF_CT_ASSERT(!nf_ct_is_confirmed(ct)); |
| 343 | pr_debug("Confirming conntrack %p\n", ct); | 343 | pr_debug("Confirming conntrack %p\n", ct); |
| 344 | 344 | ||
| 345 | write_lock_bh(&nf_conntrack_lock); | 345 | spin_lock_bh(&nf_conntrack_lock); |
| 346 | 346 | ||
| 347 | /* See if there's one in the list already, including reverse: | 347 | /* See if there's one in the list already, including reverse: |
| 348 | NAT could have grabbed it without realizing, since we're | 348 | NAT could have grabbed it without realizing, since we're |
| @@ -368,7 +368,7 @@ __nf_conntrack_confirm(struct sk_buff *skb) | |||
| 368 | atomic_inc(&ct->ct_general.use); | 368 | atomic_inc(&ct->ct_general.use); |
| 369 | set_bit(IPS_CONFIRMED_BIT, &ct->status); | 369 | set_bit(IPS_CONFIRMED_BIT, &ct->status); |
| 370 | NF_CT_STAT_INC(insert); | 370 | NF_CT_STAT_INC(insert); |
| 371 | write_unlock_bh(&nf_conntrack_lock); | 371 | spin_unlock_bh(&nf_conntrack_lock); |
| 372 | help = nfct_help(ct); | 372 | help = nfct_help(ct); |
| 373 | if (help && help->helper) | 373 | if (help && help->helper) |
| 374 | nf_conntrack_event_cache(IPCT_HELPER, skb); | 374 | nf_conntrack_event_cache(IPCT_HELPER, skb); |
| @@ -383,7 +383,7 @@ __nf_conntrack_confirm(struct sk_buff *skb) | |||
| 383 | 383 | ||
| 384 | out: | 384 | out: |
| 385 | NF_CT_STAT_INC(insert_failed); | 385 | NF_CT_STAT_INC(insert_failed); |
| 386 | write_unlock_bh(&nf_conntrack_lock); | 386 | spin_unlock_bh(&nf_conntrack_lock); |
| 387 | return NF_DROP; | 387 | return NF_DROP; |
| 388 | } | 388 | } |
| 389 | EXPORT_SYMBOL_GPL(__nf_conntrack_confirm); | 389 | EXPORT_SYMBOL_GPL(__nf_conntrack_confirm); |
| @@ -538,7 +538,7 @@ init_conntrack(const struct nf_conntrack_tuple *tuple, | |||
| 538 | return NULL; | 538 | return NULL; |
| 539 | } | 539 | } |
| 540 | 540 | ||
| 541 | write_lock_bh(&nf_conntrack_lock); | 541 | spin_lock_bh(&nf_conntrack_lock); |
| 542 | exp = nf_ct_find_expectation(tuple); | 542 | exp = nf_ct_find_expectation(tuple); |
| 543 | if (exp) { | 543 | if (exp) { |
| 544 | pr_debug("conntrack: expectation arrives ct=%p exp=%p\n", | 544 | pr_debug("conntrack: expectation arrives ct=%p exp=%p\n", |
| @@ -576,7 +576,7 @@ init_conntrack(const struct nf_conntrack_tuple *tuple, | |||
| 576 | hlist_add_head(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL].hnode, | 576 | hlist_add_head(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL].hnode, |
| 577 | &unconfirmed); | 577 | &unconfirmed); |
| 578 | 578 | ||
| 579 | write_unlock_bh(&nf_conntrack_lock); | 579 | spin_unlock_bh(&nf_conntrack_lock); |
| 580 | 580 | ||
| 581 | if (exp) { | 581 | if (exp) { |
| 582 | if (exp->expectfn) | 582 | if (exp->expectfn) |
| @@ -787,7 +787,7 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, | |||
| 787 | NF_CT_ASSERT(ct->timeout.data == (unsigned long)ct); | 787 | NF_CT_ASSERT(ct->timeout.data == (unsigned long)ct); |
| 788 | NF_CT_ASSERT(skb); | 788 | NF_CT_ASSERT(skb); |
| 789 | 789 | ||
| 790 | write_lock_bh(&nf_conntrack_lock); | 790 | spin_lock_bh(&nf_conntrack_lock); |
| 791 | 791 | ||
| 792 | /* Only update if this is not a fixed timeout */ | 792 | /* Only update if this is not a fixed timeout */ |
| 793 | if (test_bit(IPS_FIXED_TIMEOUT_BIT, &ct->status)) | 793 | if (test_bit(IPS_FIXED_TIMEOUT_BIT, &ct->status)) |
| @@ -824,7 +824,7 @@ acct: | |||
| 824 | } | 824 | } |
| 825 | #endif | 825 | #endif |
| 826 | 826 | ||
| 827 | write_unlock_bh(&nf_conntrack_lock); | 827 | spin_unlock_bh(&nf_conntrack_lock); |
| 828 | 828 | ||
| 829 | /* must be unlocked when calling event cache */ | 829 | /* must be unlocked when calling event cache */ |
| 830 | if (event) | 830 | if (event) |
| @@ -909,7 +909,7 @@ get_next_corpse(int (*iter)(struct nf_conn *i, void *data), | |||
| 909 | struct nf_conn *ct; | 909 | struct nf_conn *ct; |
| 910 | struct hlist_node *n; | 910 | struct hlist_node *n; |
| 911 | 911 | ||
| 912 | write_lock_bh(&nf_conntrack_lock); | 912 | spin_lock_bh(&nf_conntrack_lock); |
| 913 | for (; *bucket < nf_conntrack_htable_size; (*bucket)++) { | 913 | for (; *bucket < nf_conntrack_htable_size; (*bucket)++) { |
| 914 | hlist_for_each_entry(h, n, &nf_conntrack_hash[*bucket], hnode) { | 914 | hlist_for_each_entry(h, n, &nf_conntrack_hash[*bucket], hnode) { |
| 915 | ct = nf_ct_tuplehash_to_ctrack(h); | 915 | ct = nf_ct_tuplehash_to_ctrack(h); |
| @@ -922,11 +922,11 @@ get_next_corpse(int (*iter)(struct nf_conn *i, void *data), | |||
| 922 | if (iter(ct, data)) | 922 | if (iter(ct, data)) |
| 923 | set_bit(IPS_DYING_BIT, &ct->status); | < | |
