From: Patrick McHardy Date: Mon, 12 Feb 2007 19:09:55 +0000 (-0800) Subject: [NETFILTER]: Switch nf_register_afinfo/nf_unregister_afinfo to mutex X-Git-Tag: v2.6.21-rc1~274^2~1^2~22 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=d486dd1fb8573fad5b8dab61a7d1406116fd4baf;p=linux-2.6-omap-h63xx.git [NETFILTER]: Switch nf_register_afinfo/nf_unregister_afinfo to mutex The spinlock is only used in process context (register/unregister), switch to a mutex. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- diff --git a/net/netfilter/core.c b/net/netfilter/core.c index a66bd6af44f..716603f05c0 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c @@ -22,29 +22,34 @@ #include #include #include +#include #include #include "nf_internals.h" -static DEFINE_SPINLOCK(afinfo_lock); +static DEFINE_MUTEX(afinfo_mutex); struct nf_afinfo *nf_afinfo[NPROTO] __read_mostly; EXPORT_SYMBOL(nf_afinfo); int nf_register_afinfo(struct nf_afinfo *afinfo) { - spin_lock(&afinfo_lock); + int err; + + err = mutex_lock_interruptible(&afinfo_mutex); + if (err < 0) + return err; rcu_assign_pointer(nf_afinfo[afinfo->family], afinfo); - spin_unlock(&afinfo_lock); + mutex_unlock(&afinfo_mutex); return 0; } EXPORT_SYMBOL_GPL(nf_register_afinfo); void nf_unregister_afinfo(struct nf_afinfo *afinfo) { - spin_lock(&afinfo_lock); + mutex_lock(&afinfo_mutex); rcu_assign_pointer(nf_afinfo[afinfo->family], NULL); - spin_unlock(&afinfo_lock); + mutex_unlock(&afinfo_mutex); synchronize_rcu(); } EXPORT_SYMBOL_GPL(nf_unregister_afinfo);