Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fd706d6957b3c66ae70b4bbdb9e13993213697f7
Commit:     fd706d6957b3c66ae70b4bbdb9e13993213697f7
Parent:     d486dd1fb8573fad5b8dab61a7d1406116fd4baf
Author:     Patrick McHardy <[EMAIL PROTECTED]>
AuthorDate: Mon Feb 12 11:10:14 2007 -0800
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon Feb 12 11:10:14 2007 -0800

    [NETFILTER]: Switch nf_register_hook/nf_unregister_hook to mutex
    
    The spinlock is only used in process context (register/unregister)
    since RCU is used for the nf_hook lists, switch to a mutex.
    
    Signed-off-by: Patrick McHardy <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/netfilter/core.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 716603f..f61e0c2 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -61,28 +61,31 @@ EXPORT_SYMBOL_GPL(nf_unregister_afinfo);
  * packets come back: if the hook is gone, the packet is discarded. */
 struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS] __read_mostly;
 EXPORT_SYMBOL(nf_hooks);
-static DEFINE_SPINLOCK(nf_hook_lock);
+static DEFINE_MUTEX(nf_hook_mutex);
 
 int nf_register_hook(struct nf_hook_ops *reg)
 {
        struct list_head *i;
+       int err;
 
-       spin_lock_bh(&nf_hook_lock);
+       err = mutex_lock_interruptible(&nf_hook_mutex);
+       if (err < 0)
+               return err;
        list_for_each(i, &nf_hooks[reg->pf][reg->hooknum]) {
                if (reg->priority < ((struct nf_hook_ops *)i)->priority)
                        break;
        }
        list_add_rcu(&reg->list, i->prev);
-       spin_unlock_bh(&nf_hook_lock);
+       mutex_unlock(&nf_hook_mutex);
        return 0;
 }
 EXPORT_SYMBOL(nf_register_hook);
 
 void nf_unregister_hook(struct nf_hook_ops *reg)
 {
-       spin_lock_bh(&nf_hook_lock);
+       mutex_lock(&nf_hook_mutex);
        list_del_rcu(&reg->list);
-       spin_unlock_bh(&nf_hook_lock);
+       mutex_unlock(&nf_hook_mutex);
 
        synchronize_net();
 }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to