diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-31 07:43:06 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-31 22:28:00 -0500 |
commit | 02502f6224ba7735182a83e2a6b4cd5e69278d6d (patch) | |
tree | 96f25303012356e1a0b6739a779675bf71dc3e49 | |
parent | 4d354c5782dc352cec187845d17eedc2c2bfcf67 (diff) |
[NETFILTER]: nf_nat: switch rwlock to spinlock
Since we're using RCU, all users of nf_nat_lock take a write_lock.
Switch it to a spinlock.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/netfilter/nf_nat_core.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c index c7a985fa30ba..dd07362d2b8f 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <net/netfilter/nf_conntrack_l3proto.h> | 31 | #include <net/netfilter/nf_conntrack_l3proto.h> |
32 | #include <net/netfilter/nf_conntrack_l4proto.h> | 32 | #include <net/netfilter/nf_conntrack_l4proto.h> |
33 | 33 | ||
34 | static DEFINE_RWLOCK(nf_nat_lock); | 34 | static DEFINE_SPINLOCK(nf_nat_lock); |
35 | 35 | ||
36 | static struct nf_conntrack_l3proto *l3proto __read_mostly; | 36 | static struct nf_conntrack_l3proto *l3proto __read_mostly; |
37 | 37 | ||
@@ -330,12 +330,12 @@ nf_nat_setup_info(struct nf_conn *ct, | |||
330 | unsigned int srchash; | 330 | unsigned int srchash; |
331 | 331 | ||
332 | srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); | 332 | srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); |
333 | write_lock_bh(&nf_nat_lock); | 333 | spin_lock_bh(&nf_nat_lock); |
334 | /* nf_conntrack_alter_reply might re-allocate exntension aera */ | 334 | /* nf_conntrack_alter_reply might re-allocate exntension aera */ |
335 | nat = nfct_nat(ct); | 335 | nat = nfct_nat(ct); |
336 | nat->ct = ct; | 336 | nat->ct = ct; |
337 | hlist_add_head_rcu(&nat->bysource, &bysource[srchash]); | 337 | hlist_add_head_rcu(&nat->bysource, &bysource[srchash]); |
338 | write_unlock_bh(&nf_nat_lock); | 338 | spin_unlock_bh(&nf_nat_lock); |
339 | } | 339 | } |
340 | 340 | ||
341 | /* It's done. */ | 341 | /* It's done. */ |
@@ -521,14 +521,14 @@ int nf_nat_protocol_register(const struct nf_nat_protocol *proto) | |||
521 | { | 521 | { |
522 | int ret = 0; | 522 | int ret = 0; |
523 | 523 | ||
524 | write_lock_bh(&nf_nat_lock); | 524 | spin_lock_bh(&nf_nat_lock); |
525 | if (nf_nat_protos[proto->protonum] != &nf_nat_unknown_protocol) { | 525 | if (nf_nat_protos[proto->protonum] != &nf_nat_unknown_protocol) { |
526 | ret = -EBUSY; | 526 | ret = -EBUSY; |
527 | goto out; | 527 | goto out; |
528 | } | 528 | } |
529 | rcu_assign_pointer(nf_nat_protos[proto->protonum], proto); | 529 | rcu_assign_pointer(nf_nat_protos[proto->protonum], proto); |
530 | out: | 530 | out: |
531 | write_unlock_bh(&nf_nat_lock); | 531 | spin_unlock_bh(&nf_nat_lock); |
532 | return ret; | 532 | return ret; |
533 | } | 533 | } |
534 | EXPORT_SYMBOL(nf_nat_protocol_register); | 534 | EXPORT_SYMBOL(nf_nat_protocol_register); |
@@ -536,10 +536,10 @@ EXPORT_SYMBOL(nf_nat_protocol_register); | |||
536 | /* Noone stores the protocol anywhere; simply delete it. */ | 536 | /* Noone stores the protocol anywhere; simply delete it. */ |
537 | void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto) | 537 | void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto) |
538 | { | 538 | { |
539 | write_lock_bh(&nf_nat_lock); | 539 | spin_lock_bh(&nf_nat_lock); |
540 | rcu_assign_pointer(nf_nat_protos[proto->protonum], | 540 | rcu_assign_pointer(nf_nat_protos[proto->protonum], |
541 | &nf_nat_unknown_protocol); | 541 | &nf_nat_unknown_protocol); |
542 | write_unlock_bh(&nf_nat_lock); | 542 | spin_unlock_bh(&nf_nat_lock); |
543 | synchronize_rcu(); | 543 | synchronize_rcu(); |
544 | } | 544 | } |
545 | EXPORT_SYMBOL(nf_nat_protocol_unregister); | 545 | EXPORT_SYMBOL(nf_nat_protocol_unregister); |
@@ -594,10 +594,10 @@ static void nf_nat_cleanup_conntrack(struct nf_conn *ct) | |||
594 | 594 | ||
595 | NF_CT_ASSERT(nat->ct->status & IPS_NAT_DONE_MASK); | 595 | NF_CT_ASSERT(nat->ct->status & IPS_NAT_DONE_MASK); |
596 | 596 | ||
597 | write_lock_bh(&nf_nat_lock); | 597 | spin_lock_bh(&nf_nat_lock); |
598 | hlist_del_rcu(&nat->bysource); | 598 | hlist_del_rcu(&nat->bysource); |
599 | nat->ct = NULL; | 599 | nat->ct = NULL; |
600 | write_unlock_bh(&nf_nat_lock); | 600 | spin_unlock_bh(&nf_nat_lock); |
601 | } | 601 | } |
602 | 602 | ||
603 | static void nf_nat_move_storage(struct nf_conn *conntrack, void *old) | 603 | static void nf_nat_move_storage(struct nf_conn *conntrack, void *old) |
@@ -609,10 +609,10 @@ static void nf_nat_move_storage(struct nf_conn *conntrack, void *old) | |||
609 | if (!ct || !(ct->status & IPS_NAT_DONE_MASK)) | 609 | if (!ct || !(ct->status & IPS_NAT_DONE_MASK)) |
610 | return; | 610 | return; |
611 | 611 | ||
612 | write_lock_bh(&nf_nat_lock); | 612 | spin_lock_bh(&nf_nat_lock); |
613 | hlist_replace_rcu(&old_nat->bysource, &new_nat->bysource); | 613 | hlist_replace_rcu(&old_nat->bysource, &new_nat->bysource); |
614 | new_nat->ct = ct; | 614 | new_nat->ct = ct; |
615 | write_unlock_bh(&nf_nat_lock); | 615 | spin_unlock_bh(&nf_nat_lock); |
616 | } | 616 | } |
617 | 617 | ||
618 | static struct nf_ct_ext_type nat_extend __read_mostly = { | 618 | static struct nf_ct_ext_type nat_extend __read_mostly = { |
@@ -646,13 +646,13 @@ static int __init nf_nat_init(void) | |||
646 | } | 646 | } |
647 | 647 | ||
648 | /* Sew in builtin protocols. */ | 648 | /* Sew in builtin protocols. */ |
649 | write_lock_bh(&nf_nat_lock); | 649 | spin_lock_bh(&nf_nat_lock); |
650 | for (i = 0; i < MAX_IP_NAT_PROTO; i++) | 650 | for (i = 0; i < MAX_IP_NAT_PROTO; i++) |
651 | rcu_assign_pointer(nf_nat_protos[i], &nf_nat_unknown_protocol); | 651 | rcu_assign_pointer(nf_nat_protos[i], &nf_nat_unknown_protocol); |
652 | rcu_assign_pointer(nf_nat_protos[IPPROTO_TCP], &nf_nat_protocol_tcp); | 652 | rcu_assign_pointer(nf_nat_protos[IPPROTO_TCP], &nf_nat_protocol_tcp); |
653 | rcu_assign_pointer(nf_nat_protos[IPPROTO_UDP], &nf_nat_protocol_udp); | 653 | rcu_assign_pointer(nf_nat_protos[IPPROTO_UDP], &nf_nat_protocol_udp); |
654 | rcu_assign_pointer(nf_nat_protos[IPPROTO_ICMP], &nf_nat_protocol_icmp); | 654 | rcu_assign_pointer(nf_nat_protos[IPPROTO_ICMP], &nf_nat_protocol_icmp); |
655 | write_unlock_bh(&nf_nat_lock); | 655 | spin_unlock_bh(&nf_nat_lock); |
656 | 656 | ||
657 | /* Initialize fake conntrack so that NAT will skip it */ | 657 | /* Initialize fake conntrack so that NAT will skip it */ |
658 | nf_conntrack_untracked.status |= IPS_NAT_DONE_MASK; | 658 | nf_conntrack_untracked.status |= IPS_NAT_DONE_MASK; |