diff options
author | Simon Horman <horms@verge.net.au> | 2011-03-21 11:18:01 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-21 23:39:24 -0400 |
commit | 736561a01f11114146b1b7f82d486fa9c95828ef (patch) | |
tree | 804709a3163df1c6e33e2a1da5ec91f719bce17c /net | |
parent | f40f94fc6c3b5a5542d5ed976e9ff69a3b463802 (diff) |
IPVS: Use global mutex in ip_vs_app.c
As part of the work to make IPVS network namespace aware
__ip_vs_app_mutex was replaced by a per-namespace lock,
ipvs->app_mutex. ipvs->app_key is also supplied for debugging purposes.
Unfortunately this implementation results in ipvs->app_key residing
in non-static storage which at the very least causes a lockdep warning.
This patch takes the rather heavy-handed approach of reinstating
__ip_vs_app_mutex which will cover access to the ipvs->list_head
of all network namespaces.
[ 12.610000] IPVS: Creating netns size=2456 id=0
[ 12.630000] IPVS: Registered protocols (TCP, UDP, SCTP, AH, ESP)
[ 12.640000] BUG: key ffff880003bbf1a0 not in .data!
[ 12.640000] ------------[ cut here ]------------
[ 12.640000] WARNING: at kernel/lockdep.c:2701 lockdep_init_map+0x37b/0x570()
[ 12.640000] Hardware name: Bochs
[ 12.640000] Pid: 1, comm: swapper Tainted: G W 2.6.38-kexec-06330-g69b7efe-dirty #122
[ 12.650000] Call Trace:
[ 12.650000] [<ffffffff8102e685>] warn_slowpath_common+0x75/0xb0
[ 12.650000] [<ffffffff8102e6d5>] warn_slowpath_null+0x15/0x20
[ 12.650000] [<ffffffff8105967b>] lockdep_init_map+0x37b/0x570
[ 12.650000] [<ffffffff8105829d>] ? trace_hardirqs_on+0xd/0x10
[ 12.650000] [<ffffffff81055ad8>] debug_mutex_init+0x38/0x50
[ 12.650000] [<ffffffff8104bc4c>] __mutex_init+0x5c/0x70
[ 12.650000] [<ffffffff81685ee7>] __ip_vs_app_init+0x64/0x86
[ 12.660000] [<ffffffff81685a3b>] ? ip_vs_init+0x0/0xff
[ 12.660000] [<ffffffff811b1c33>] T.620+0x43/0x170
[ 12.660000] [<ffffffff811b1e9a>] ? register_pernet_subsys+0x1a/0x40
[ 12.660000] [<ffffffff81685a3b>] ? ip_vs_init+0x0/0xff
[ 12.660000] [<ffffffff81685a3b>] ? ip_vs_init+0x0/0xff
[ 12.660000] [<ffffffff811b1db7>] register_pernet_operations+0x57/0xb0
[ 12.660000] [<ffffffff81685a3b>] ? ip_vs_init+0x0/0xff
[ 12.670000] [<ffffffff811b1ea9>] register_pernet_subsys+0x29/0x40
[ 12.670000] [<ffffffff81685f19>] ip_vs_app_init+0x10/0x12
[ 12.670000] [<ffffffff81685a87>] ip_vs_init+0x4c/0xff
[ 12.670000] [<ffffffff8166562c>] do_one_initcall+0x7a/0x12e
[ 12.670000] [<ffffffff8166583e>] kernel_init+0x13e/0x1c2
[ 12.670000] [<ffffffff8128c134>] kernel_thread_helper+0x4/0x10
[ 12.670000] [<ffffffff8128ad40>] ? restore_args+0x0/0x30
[ 12.680000] [<ffffffff81665700>] ? kernel_init+0x0/0x1c2
[ 12.680000] [<ffffffff8128c130>] ? kernel_thread_helper+0x0/0x1global0
Signed-off-by: Simon Horman <horms@verge.net.au>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Julian Anastasov <ja@ssi.bg>
Cc: Hans Schillstrom <hans@schillstrom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/ipvs/ip_vs_app.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/net/netfilter/ipvs/ip_vs_app.c b/net/netfilter/ipvs/ip_vs_app.c index 5c48ffb60c28..2dc6de13ac18 100644 --- a/net/netfilter/ipvs/ip_vs_app.c +++ b/net/netfilter/ipvs/ip_vs_app.c | |||
@@ -43,6 +43,8 @@ EXPORT_SYMBOL(register_ip_vs_app); | |||
43 | EXPORT_SYMBOL(unregister_ip_vs_app); | 43 | EXPORT_SYMBOL(unregister_ip_vs_app); |
44 | EXPORT_SYMBOL(register_ip_vs_app_inc); | 44 | EXPORT_SYMBOL(register_ip_vs_app_inc); |
45 | 45 | ||
46 | static DEFINE_MUTEX(__ip_vs_app_mutex); | ||
47 | |||
46 | /* | 48 | /* |
47 | * Get an ip_vs_app object | 49 | * Get an ip_vs_app object |
48 | */ | 50 | */ |
@@ -167,14 +169,13 @@ int | |||
167 | register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app, __u16 proto, | 169 | register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app, __u16 proto, |
168 | __u16 port) | 170 | __u16 port) |
169 | { | 171 | { |
170 | struct netns_ipvs *ipvs = net_ipvs(net); | ||
171 | int result; | 172 | int result; |
172 | 173 | ||
173 | mutex_lock(&ipvs->app_mutex); | 174 | mutex_lock(&__ip_vs_app_mutex); |
174 | 175 | ||
175 | result = ip_vs_app_inc_new(net, app, proto, port); | 176 | result = ip_vs_app_inc_new(net, app, proto, port); |
176 | 177 | ||
177 | mutex_unlock(&ipvs->app_mutex); | 178 | mutex_unlock(&__ip_vs_app_mutex); |
178 | 179 | ||
179 | return result; | 180 | return result; |
180 | } | 181 | } |
@@ -189,11 +190,11 @@ int register_ip_vs_app(struct net *net, struct ip_vs_app *app) | |||
189 | /* increase the module use count */ | 190 | /* increase the module use count */ |
190 | ip_vs_use_count_inc(); | 191 | ip_vs_use_count_inc(); |
191 | 192 | ||
192 | mutex_lock(&ipvs->app_mutex); | 193 | mutex_lock(&__ip_vs_app_mutex); |
193 | 194 | ||
194 | list_add(&app->a_list, &ipvs->app_list); | 195 | list_add(&app->a_list, &ipvs->app_list); |
195 | 196 | ||
196 | mutex_unlock(&ipvs->app_mutex); | 197 | mutex_unlock(&__ip_vs_app_mutex); |
197 | 198 | ||
198 | return 0; | 199 | return 0; |
199 | } | 200 | } |
@@ -205,10 +206,9 @@ int register_ip_vs_app(struct net *net, struct ip_vs_app *app) | |||
205 | */ | 206 | */ |
206 | void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app) | 207 | void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app) |
207 | { | 208 | { |
208 | struct netns_ipvs *ipvs = net_ipvs(net); | ||
209 | struct ip_vs_app *inc, *nxt; | 209 | struct ip_vs_app *inc, *nxt; |
210 | 210 | ||
211 | mutex_lock(&ipvs->app_mutex); | 211 | mutex_lock(&__ip_vs_app_mutex); |
212 | 212 | ||
213 | list_for_each_entry_safe(inc, nxt, &app->incs_list, a_list) { | 213 | list_for_each_entry_safe(inc, nxt, &app->incs_list, a_list) { |
214 | ip_vs_app_inc_release(net, inc); | 214 | ip_vs_app_inc_release(net, inc); |
@@ -216,7 +216,7 @@ void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app) | |||
216 | 216 | ||
217 | list_del(&app->a_list); | 217 | list_del(&app->a_list); |
218 | 218 | ||
219 | mutex_unlock(&ipvs->app_mutex); | 219 | mutex_unlock(&__ip_vs_app_mutex); |
220 | 220 | ||
221 | /* decrease the module use count */ | 221 | /* decrease the module use count */ |
222 | ip_vs_use_count_dec(); | 222 | ip_vs_use_count_dec(); |
@@ -501,7 +501,7 @@ static void *ip_vs_app_seq_start(struct seq_file *seq, loff_t *pos) | |||
501 | struct net *net = seq_file_net(seq); | 501 | struct net *net = seq_file_net(seq); |
502 | struct netns_ipvs *ipvs = net_ipvs(net); | 502 | struct netns_ipvs *ipvs = net_ipvs(net); |
503 | 503 | ||
504 | mutex_lock(&ipvs->app_mutex); | 504 | mutex_lock(&__ip_vs_app_mutex); |
505 | 505 | ||
506 | return *pos ? ip_vs_app_idx(ipvs, *pos - 1) : SEQ_START_TOKEN; | 506 | return *pos ? ip_vs_app_idx(ipvs, *pos - 1) : SEQ_START_TOKEN; |
507 | } | 507 | } |
@@ -535,9 +535,7 @@ static void *ip_vs_app_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
535 | 535 | ||
536 | static void ip_vs_app_seq_stop(struct seq_file *seq, void *v) | 536 | static void ip_vs_app_seq_stop(struct seq_file *seq, void *v) |
537 | { | 537 | { |
538 | struct netns_ipvs *ipvs = net_ipvs(seq_file_net(seq)); | 538 | mutex_unlock(&__ip_vs_app_mutex); |
539 | |||
540 | mutex_unlock(&ipvs->app_mutex); | ||
541 | } | 539 | } |
542 | 540 | ||
543 | static int ip_vs_app_seq_show(struct seq_file *seq, void *v) | 541 | static int ip_vs_app_seq_show(struct seq_file *seq, void *v) |
@@ -583,7 +581,6 @@ static int __net_init __ip_vs_app_init(struct net *net) | |||
583 | struct netns_ipvs *ipvs = net_ipvs(net); | 581 | struct netns_ipvs *ipvs = net_ipvs(net); |
584 | 582 | ||
585 | INIT_LIST_HEAD(&ipvs->app_list); | 583 | INIT_LIST_HEAD(&ipvs->app_list); |
586 | __mutex_init(&ipvs->app_mutex, "ipvs->app_mutex", &ipvs->app_key); | ||
587 | proc_net_fops_create(net, "ip_vs_app", 0, &ip_vs_app_fops); | 584 | proc_net_fops_create(net, "ip_vs_app", 0, &ip_vs_app_fops); |
588 | return 0; | 585 | return 0; |
589 | } | 586 | } |