aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Schillstrom <hans.schillstrom@ericsson.com>2011-01-03 08:44:53 -0500
committerSimon Horman <horms@verge.net.au>2011-01-12 20:30:28 -0500
commitab8a5e8408c3df2d654611bffc3aaf04f418b266 (patch)
tree665454a0426b9209a53018ee71103914b29d95a7
parent9bbac6a904d0816dae58b454692c54d6773cc20d (diff)
IPVS: netns awareness to ip_vs_app
All variables moved to struct ipvs, most external changes fixed (i.e. init_net removed) in ip_vs_protocol param struct net *net added to: - register_app() - unregister_app() This affected almost all proto_xxx.c files Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com> Acked-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--include/net/ip_vs.h12
-rw-r--r--include/net/netns/ip_vs.h5
-rw-r--r--net/netfilter/ipvs/ip_vs_app.c73
-rw-r--r--net/netfilter/ipvs/ip_vs_ftp.c8
-rw-r--r--net/netfilter/ipvs/ip_vs_proto_sctp.c12
-rw-r--r--net/netfilter/ipvs/ip_vs_proto_tcp.c12
-rw-r--r--net/netfilter/ipvs/ip_vs_proto_udp.c12
7 files changed, 76 insertions, 58 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index cc6ae621a9b..0cdd8ce454c 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -402,9 +402,9 @@ struct ip_vs_protocol {
402 const struct sk_buff *skb, 402 const struct sk_buff *skb,
403 struct ip_vs_proto_data *pd); 403 struct ip_vs_proto_data *pd);
404 404
405 int (*register_app)(struct ip_vs_app *inc); 405 int (*register_app)(struct net *net, struct ip_vs_app *inc);
406 406
407 void (*unregister_app)(struct ip_vs_app *inc); 407 void (*unregister_app)(struct net *net, struct ip_vs_app *inc);
408 408
409 int (*app_conn_bind)(struct ip_vs_conn *cp); 409 int (*app_conn_bind)(struct ip_vs_conn *cp);
410 410
@@ -871,12 +871,12 @@ ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp)
871 * (from ip_vs_app.c) 871 * (from ip_vs_app.c)
872 */ 872 */
873#define IP_VS_APP_MAX_PORTS 8 873#define IP_VS_APP_MAX_PORTS 8
874extern int register_ip_vs_app(struct ip_vs_app *app); 874extern int register_ip_vs_app(struct net *net, struct ip_vs_app *app);
875extern void unregister_ip_vs_app(struct ip_vs_app *app); 875extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app);
876extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); 876extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
877extern void ip_vs_unbind_app(struct ip_vs_conn *cp); 877extern void ip_vs_unbind_app(struct ip_vs_conn *cp);
878extern int 878extern int register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app,
879register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port); 879 __u16 proto, __u16 port);
880extern int ip_vs_app_inc_get(struct ip_vs_app *inc); 880extern int ip_vs_app_inc_get(struct ip_vs_app *inc);
881extern void ip_vs_app_inc_put(struct ip_vs_app *inc); 881extern void ip_vs_app_inc_put(struct ip_vs_app *inc);
882 882
diff --git a/include/net/netns/ip_vs.h b/include/net/netns/ip_vs.h
index 58bd3fd85a9..03f7fe1bede 100644
--- a/include/net/netns/ip_vs.h
+++ b/include/net/netns/ip_vs.h
@@ -28,6 +28,11 @@ struct netns_ipvs {
28 #define IP_VS_RTAB_MASK (IP_VS_RTAB_SIZE - 1) 28 #define IP_VS_RTAB_MASK (IP_VS_RTAB_SIZE - 1)
29 29
30 struct list_head rs_table[IP_VS_RTAB_SIZE]; 30 struct list_head rs_table[IP_VS_RTAB_SIZE];
31 /* ip_vs_app */
32 struct list_head app_list;
33 struct mutex app_mutex;
34 struct lock_class_key app_key; /* mutex debuging */
35
31 /* ip_vs_proto */ 36 /* ip_vs_proto */
32 #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */ 37 #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */
33 struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE]; 38 struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE];
diff --git a/net/netfilter/ipvs/ip_vs_app.c b/net/netfilter/ipvs/ip_vs_app.c
index 40b09ccc489..286f46594e0 100644
--- a/net/netfilter/ipvs/ip_vs_app.c
+++ b/net/netfilter/ipvs/ip_vs_app.c
@@ -43,11 +43,6 @@ EXPORT_SYMBOL(register_ip_vs_app);
43EXPORT_SYMBOL(unregister_ip_vs_app); 43EXPORT_SYMBOL(unregister_ip_vs_app);
44EXPORT_SYMBOL(register_ip_vs_app_inc); 44EXPORT_SYMBOL(register_ip_vs_app_inc);
45 45
46/* ipvs application list head */
47static LIST_HEAD(ip_vs_app_list);
48static DEFINE_MUTEX(__ip_vs_app_mutex);
49
50
51/* 46/*
52 * Get an ip_vs_app object 47 * Get an ip_vs_app object
53 */ 48 */
@@ -67,7 +62,8 @@ static inline void ip_vs_app_put(struct ip_vs_app *app)
67 * Allocate/initialize app incarnation and register it in proto apps. 62 * Allocate/initialize app incarnation and register it in proto apps.
68 */ 63 */
69static int 64static int
70ip_vs_app_inc_new(struct ip_vs_app *app, __u16 proto, __u16 port) 65ip_vs_app_inc_new(struct net *net, struct ip_vs_app *app, __u16 proto,
66 __u16 port)
71{ 67{
72 struct ip_vs_protocol *pp; 68 struct ip_vs_protocol *pp;
73 struct ip_vs_app *inc; 69 struct ip_vs_app *inc;
@@ -98,7 +94,7 @@ ip_vs_app_inc_new(struct ip_vs_app *app, __u16 proto, __u16 port)
98 } 94 }
99 } 95 }
100 96
101 ret = pp->register_app(inc); 97 ret = pp->register_app(net, inc);
102 if (ret) 98 if (ret)
103 goto out; 99 goto out;
104 100
@@ -119,7 +115,7 @@ ip_vs_app_inc_new(struct ip_vs_app *app, __u16 proto, __u16 port)
119 * Release app incarnation 115 * Release app incarnation
120 */ 116 */
121static void 117static void
122ip_vs_app_inc_release(struct ip_vs_app *inc) 118ip_vs_app_inc_release(struct net *net, struct ip_vs_app *inc)
123{ 119{
124 struct ip_vs_protocol *pp; 120 struct ip_vs_protocol *pp;
125 121
@@ -127,7 +123,7 @@ ip_vs_app_inc_release(struct ip_vs_app *inc)
127 return; 123 return;
128 124
129 if (pp->unregister_app) 125 if (pp->unregister_app)
130 pp->unregister_app(inc); 126 pp->unregister_app(net, inc);
131 127
132 IP_VS_DBG(9, "%s App %s:%u unregistered\n", 128 IP_VS_DBG(9, "%s App %s:%u unregistered\n",
133 pp->name, inc->name, ntohs(inc->port)); 129 pp->name, inc->name, ntohs(inc->port));
@@ -168,15 +164,17 @@ void ip_vs_app_inc_put(struct ip_vs_app *inc)
168 * Register an application incarnation in protocol applications 164 * Register an application incarnation in protocol applications
169 */ 165 */
170int 166int
171register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port) 167register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app, __u16 proto,
168 __u16 port)
172{ 169{
170 struct netns_ipvs *ipvs = net_ipvs(net);
173 int result; 171 int result;
174 172
175 mutex_lock(&__ip_vs_app_mutex); 173 mutex_lock(&ipvs->app_mutex);
176 174
177 result = ip_vs_app_inc_new(app, proto, port); 175 result = ip_vs_app_inc_new(net, app, proto, port);
178 176
179 mutex_unlock(&__ip_vs_app_mutex); 177 mutex_unlock(&ipvs->app_mutex);
180 178
181 return result; 179 return result;
182} 180}
@@ -185,16 +183,17 @@ register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port)
185/* 183/*
186 * ip_vs_app registration routine 184 * ip_vs_app registration routine
187 */ 185 */
188int register_ip_vs_app(struct ip_vs_app *app) 186int register_ip_vs_app(struct net *net, struct ip_vs_app *app)
189{ 187{
188 struct netns_ipvs *ipvs = net_ipvs(net);
190 /* increase the module use count */ 189 /* increase the module use count */
191 ip_vs_use_count_inc(); 190 ip_vs_use_count_inc();
192 191
193 mutex_lock(&__ip_vs_app_mutex); 192 mutex_lock(&ipvs->app_mutex);
194 193
195 list_add(&app->a_list, &ip_vs_app_list); 194 list_add(&app->a_list, &ipvs->app_list);
196 195
197 mutex_unlock(&__ip_vs_app_mutex); 196 mutex_unlock(&ipvs->app_mutex);
198 197
199 return 0; 198 return 0;
200} 199}
@@ -204,19 +203,20 @@ int register_ip_vs_app(struct ip_vs_app *app)
204 * ip_vs_app unregistration routine 203 * ip_vs_app unregistration routine
205 * We are sure there are no app incarnations attached to services 204 * We are sure there are no app incarnations attached to services
206 */ 205 */
207void unregister_ip_vs_app(struct ip_vs_app *app) 206void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app)
208{ 207{
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(&__ip_vs_app_mutex); 211 mutex_lock(&ipvs->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(inc); 214 ip_vs_app_inc_release(net, inc);
215 } 215 }
216 216
217 list_del(&app->a_list); 217 list_del(&app->a_list);
218 218
219 mutex_unlock(&__ip_vs_app_mutex); 219 mutex_unlock(&ipvs->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();
@@ -226,7 +226,8 @@ void unregister_ip_vs_app(struct ip_vs_app *app)
226/* 226/*
227 * Bind ip_vs_conn to its ip_vs_app (called by cp constructor) 227 * Bind ip_vs_conn to its ip_vs_app (called by cp constructor)
228 */ 228 */
229int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp) 229int ip_vs_bind_app(struct ip_vs_conn *cp,
230 struct ip_vs_protocol *pp)
230{ 231{
231 return pp->app_conn_bind(cp); 232 return pp->app_conn_bind(cp);
232} 233}
@@ -481,11 +482,11 @@ int ip_vs_app_pkt_in(struct ip_vs_conn *cp, struct sk_buff *skb)
481 * /proc/net/ip_vs_app entry function 482 * /proc/net/ip_vs_app entry function
482 */ 483 */
483 484
484static struct ip_vs_app *ip_vs_app_idx(loff_t pos) 485static struct ip_vs_app *ip_vs_app_idx(struct netns_ipvs *ipvs, loff_t pos)
485{ 486{
486 struct ip_vs_app *app, *inc; 487 struct ip_vs_app *app, *inc;
487 488
488 list_for_each_entry(app, &ip_vs_app_list, a_list) { 489 list_for_each_entry(app, &ipvs->app_list, a_list) {
489 list_for_each_entry(inc, &app->incs_list, a_list) { 490 list_for_each_entry(inc, &app->incs_list, a_list) {
490 if (pos-- == 0) 491 if (pos-- == 0)
491 return inc; 492 return inc;
@@ -497,19 +498,24 @@ static struct ip_vs_app *ip_vs_app_idx(loff_t pos)
497 498
498static void *ip_vs_app_seq_start(struct seq_file *seq, loff_t *pos) 499static void *ip_vs_app_seq_start(struct seq_file *seq, loff_t *pos)
499{ 500{
500 mutex_lock(&__ip_vs_app_mutex); 501 struct net *net = seq_file_net(seq);
502 struct netns_ipvs *ipvs = net_ipvs(net);
503
504 mutex_lock(&ipvs->app_mutex);
501 505
502 return *pos ? ip_vs_app_idx(*pos - 1) : SEQ_START_TOKEN; 506 return *pos ? ip_vs_app_idx(ipvs, *pos - 1) : SEQ_START_TOKEN;
503} 507}
504 508
505static void *ip_vs_app_seq_next(struct seq_file *seq, void *v, loff_t *pos) 509static void *ip_vs_app_seq_next(struct seq_file *seq, void *v, loff_t *pos)
506{ 510{
507 struct ip_vs_app *inc, *app; 511 struct ip_vs_app *inc, *app;
508 struct list_head *e; 512 struct list_head *e;
513 struct net *net = seq_file_net(seq);
514 struct netns_ipvs *ipvs = net_ipvs(net);
509 515
510 ++*pos; 516 ++*pos;
511 if (v == SEQ_START_TOKEN) 517 if (v == SEQ_START_TOKEN)
512 return ip_vs_app_idx(0); 518 return ip_vs_app_idx(ipvs, 0);
513 519
514 inc = v; 520 inc = v;
515 app = inc->app; 521 app = inc->app;
@@ -518,7 +524,7 @@ static void *ip_vs_app_seq_next(struct seq_file *seq, void *v, loff_t *pos)
518 return list_entry(e, struct ip_vs_app, a_list); 524 return list_entry(e, struct ip_vs_app, a_list);
519 525
520 /* go on to next application */ 526 /* go on to next application */
521 for (e = app->a_list.next; e != &ip_vs_app_list; e = e->next) { 527 for (e = app->a_list.next; e != &ipvs->app_list; e = e->next) {
522 app = list_entry(e, struct ip_vs_app, a_list); 528 app = list_entry(e, struct ip_vs_app, a_list);
523 list_for_each_entry(inc, &app->incs_list, a_list) { 529 list_for_each_entry(inc, &app->incs_list, a_list) {
524 return inc; 530 return inc;
@@ -529,7 +535,9 @@ static void *ip_vs_app_seq_next(struct seq_file *seq, void *v, loff_t *pos)
529 535
530static void ip_vs_app_seq_stop(struct seq_file *seq, void *v) 536static void ip_vs_app_seq_stop(struct seq_file *seq, void *v)
531{ 537{
532 mutex_unlock(&__ip_vs_app_mutex); 538 struct netns_ipvs *ipvs = net_ipvs(seq_file_net(seq));
539
540 mutex_unlock(&ipvs->app_mutex);
533} 541}
534 542
535static int ip_vs_app_seq_show(struct seq_file *seq, void *v) 543static int ip_vs_app_seq_show(struct seq_file *seq, void *v)
@@ -557,7 +565,8 @@ static const struct seq_operations ip_vs_app_seq_ops = {
557 565
558static int ip_vs_app_open(struct inode *inode, struct file *file) 566static int ip_vs_app_open(struct inode *inode, struct file *file)
559{ 567{
560 return seq_open(file, &ip_vs_app_seq_ops); 568 return seq_open_net(inode, file, &ip_vs_app_seq_ops,
569 sizeof(struct seq_net_private));
561} 570}
562 571
563static const struct file_operations ip_vs_app_fops = { 572static const struct file_operations ip_vs_app_fops = {
@@ -571,9 +580,13 @@ static const struct file_operations ip_vs_app_fops = {
571 580
572static int __net_init __ip_vs_app_init(struct net *net) 581static int __net_init __ip_vs_app_init(struct net *net)
573{ 582{
583 struct netns_ipvs *ipvs = net_ipvs(net);
584
574 if (!net_eq(net, &init_net)) /* netns not enabled yet */ 585 if (!net_eq(net, &init_net)) /* netns not enabled yet */
575 return -EPERM; 586 return -EPERM;
576 587
588 INIT_LIST_HEAD(&ipvs->app_list);
589 __mutex_init(&ipvs->app_mutex, "ipvs->app_mutex", &ipvs->app_key);
577 proc_net_fops_create(net, "ip_vs_app", 0, &ip_vs_app_fops); 590 proc_net_fops_create(net, "ip_vs_app", 0, &ip_vs_app_fops);
578 return 0; 591 return 0;
579} 592}
diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c
index b38ae941f67..77b0036dcb7 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -414,14 +414,14 @@ static int __net_init __ip_vs_ftp_init(struct net *net)
414 if (!net_eq(net, &init_net)) /* netns not enabled yet */ 414 if (!net_eq(net, &init_net)) /* netns not enabled yet */
415 return -EPERM; 415 return -EPERM;
416 416
417 ret = register_ip_vs_app(app); 417 ret = register_ip_vs_app(net, app);
418 if (ret) 418 if (ret)
419 return ret; 419 return ret;
420 420
421 for (i=0; i<IP_VS_APP_MAX_PORTS; i++) { 421 for (i=0; i<IP_VS_APP_MAX_PORTS; i++) {
422 if (!ports[i]) 422 if (!ports[i])
423 continue; 423 continue;
424 ret = register_ip_vs_app_inc(app, app->protocol, ports[i]); 424 ret = register_ip_vs_app_inc(net, app, app->protocol, ports[i]);
425 if (ret) 425 if (ret)
426 break; 426 break;
427 pr_info("%s: loaded support on port[%d] = %d\n", 427 pr_info("%s: loaded support on port[%d] = %d\n",
@@ -429,7 +429,7 @@ static int __net_init __ip_vs_ftp_init(struct net *net)
429 } 429 }
430 430
431 if (ret) 431 if (ret)
432 unregister_ip_vs_app(app); 432 unregister_ip_vs_app(net, app);
433 433
434 return ret; 434 return ret;
435} 435}
@@ -443,7 +443,7 @@ static void __ip_vs_ftp_exit(struct net *net)
443 if (!net_eq(net, &init_net)) /* netns not enabled yet */ 443 if (!net_eq(net, &init_net)) /* netns not enabled yet */
444 return; 444 return;
445 445
446 unregister_ip_vs_app(app); 446 unregister_ip_vs_app(net, app);
447} 447}
448 448
449static struct pernet_operations ip_vs_ftp_ops = { 449static struct pernet_operations ip_vs_ftp_ops = {
diff --git a/net/netfilter/ipvs/ip_vs_proto_sctp.c b/net/netfilter/ipvs/ip_vs_proto_sctp.c
index 0f14f793318..569e77bf08c 100644
--- a/net/netfilter/ipvs/ip_vs_proto_sctp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_sctp.c
@@ -1016,14 +1016,14 @@ static inline __u16 sctp_app_hashkey(__be16 port)
1016 & SCTP_APP_TAB_MASK; 1016 & SCTP_APP_TAB_MASK;
1017} 1017}
1018 1018
1019static int sctp_register_app(struct ip_vs_app *inc) 1019static int sctp_register_app(struct net *net, struct ip_vs_app *inc)
1020{ 1020{
1021 struct ip_vs_app *i; 1021 struct ip_vs_app *i;
1022 __u16 hash; 1022 __u16 hash;
1023 __be16 port = inc->port; 1023 __be16 port = inc->port;
1024 int ret = 0; 1024 int ret = 0;
1025 struct netns_ipvs *ipvs = net_ipvs(&init_net); 1025 struct netns_ipvs *ipvs = net_ipvs(net);
1026 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, IPPROTO_SCTP); 1026 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(net, IPPROTO_SCTP);
1027 1027
1028 hash = sctp_app_hashkey(port); 1028 hash = sctp_app_hashkey(port);
1029 1029
@@ -1042,10 +1042,10 @@ out:
1042 return ret; 1042 return ret;
1043} 1043}
1044 1044
1045static void sctp_unregister_app(struct ip_vs_app *inc) 1045static void sctp_unregister_app(struct net *net, struct ip_vs_app *inc)
1046{ 1046{
1047 struct netns_ipvs *ipvs = net_ipvs(&init_net); 1047 struct netns_ipvs *ipvs = net_ipvs(net);
1048 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, IPPROTO_SCTP); 1048 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(net, IPPROTO_SCTP);
1049 1049
1050 spin_lock_bh(&ipvs->sctp_app_lock); 1050 spin_lock_bh(&ipvs->sctp_app_lock);
1051 atomic_dec(&pd->appcnt); 1051 atomic_dec(&pd->appcnt);
diff --git a/net/netfilter/ipvs/ip_vs_proto_tcp.c b/net/netfilter/ipvs/ip_vs_proto_tcp.c
index 290b3803d8c..757aaaf083b 100644
--- a/net/netfilter/ipvs/ip_vs_proto_tcp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_tcp.c
@@ -577,14 +577,14 @@ static inline __u16 tcp_app_hashkey(__be16 port)
577} 577}
578 578
579 579
580static int tcp_register_app(struct ip_vs_app *inc) 580static int tcp_register_app(struct net *net, struct ip_vs_app *inc)
581{ 581{
582 struct ip_vs_app *i; 582 struct ip_vs_app *i;
583 __u16 hash; 583 __u16 hash;
584 __be16 port = inc->port; 584 __be16 port = inc->port;
585 int ret = 0; 585 int ret = 0;
586 struct netns_ipvs *ipvs = net_ipvs(&init_net); 586 struct netns_ipvs *ipvs = net_ipvs(net);
587 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, IPPROTO_TCP); 587 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(net, IPPROTO_TCP);
588 588
589 hash = tcp_app_hashkey(port); 589 hash = tcp_app_hashkey(port);
590 590
@@ -605,10 +605,10 @@ static int tcp_register_app(struct ip_vs_app *inc)
605 605
606 606
607static void 607static void
608tcp_unregister_app(struct ip_vs_app *inc) 608tcp_unregister_app(struct net *net, struct ip_vs_app *inc)
609{ 609{
610 struct netns_ipvs *ipvs = net_ipvs(&init_net); 610 struct netns_ipvs *ipvs = net_ipvs(net);
611 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, IPPROTO_TCP); 611 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(net, IPPROTO_TCP);
612 612
613 spin_lock_bh(&ipvs->tcp_app_lock); 613 spin_lock_bh(&ipvs->tcp_app_lock);
614 atomic_dec(&pd->appcnt); 614 atomic_dec(&pd->appcnt);
diff --git a/net/netfilter/ipvs/ip_vs_proto_udp.c b/net/netfilter/ipvs/ip_vs_proto_udp.c
index 3719837a8fd..1dc394100fa 100644
--- a/net/netfilter/ipvs/ip_vs_proto_udp.c
+++ b/net/netfilter/ipvs/ip_vs_proto_udp.c
@@ -353,14 +353,14 @@ static inline __u16 udp_app_hashkey(__be16 port)
353} 353}
354 354
355 355
356static int udp_register_app(struct ip_vs_app *inc) 356static int udp_register_app(struct net *net, struct ip_vs_app *inc)
357{ 357{
358 struct ip_vs_app *i; 358 struct ip_vs_app *i;
359 __u16 hash; 359 __u16 hash;
360 __be16 port = inc->port; 360 __be16 port = inc->port;
361 int ret = 0; 361 int ret = 0;
362 struct netns_ipvs *ipvs = net_ipvs(&init_net); 362 struct netns_ipvs *ipvs = net_ipvs(net);
363 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, IPPROTO_UDP); 363 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(net, IPPROTO_UDP);
364 364
365 hash = udp_app_hashkey(port); 365 hash = udp_app_hashkey(port);
366 366
@@ -382,10 +382,10 @@ static int udp_register_app(struct ip_vs_app *inc)
382 382
383 383
384static void 384static void
385udp_unregister_app(struct ip_vs_app *inc) 385udp_unregister_app(struct net *net, struct ip_vs_app *inc)
386{ 386{
387 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(&init_net, IPPROTO_UDP); 387 struct ip_vs_proto_data *pd = ip_vs_proto_data_get(net, IPPROTO_UDP);
388 struct netns_ipvs *ipvs = net_ipvs(&init_net); 388 struct netns_ipvs *ipvs = net_ipvs(net);
389 389
390 spin_lock_bh(&ipvs->udp_app_lock); 390 spin_lock_bh(&ipvs->udp_app_lock);
391 atomic_dec(&pd->appcnt); 391 atomic_dec(&pd->appcnt);