aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/config.c3
-rw-r--r--net/tipc/core.c19
-rw-r--r--net/tipc/core.h4
-rw-r--r--net/tipc/msg.c4
-rw-r--r--net/tipc/msg.h2
-rw-r--r--net/tipc/name_distr.c37
-rw-r--r--net/tipc/name_distr.h4
-rw-r--r--net/tipc/name_table.c128
-rw-r--r--net/tipc/name_table.h25
-rw-r--r--net/tipc/net.c2
-rw-r--r--net/tipc/server.c3
-rw-r--r--net/tipc/server.h10
-rw-r--r--net/tipc/socket.c11
-rw-r--r--net/tipc/subscr.c16
-rw-r--r--net/tipc/subscr.h2
15 files changed, 154 insertions, 116 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c
index 20b1c5812f00..974723a1e32e 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -248,7 +248,8 @@ struct sk_buff *tipc_cfg_do_cmd(struct net *net, u32 orig_node, u16 cmd,
248 req_tlv_space); 248 req_tlv_space);
249 break; 249 break;
250 case TIPC_CMD_SHOW_NAME_TABLE: 250 case TIPC_CMD_SHOW_NAME_TABLE:
251 rep_tlv_buf = tipc_nametbl_get(req_tlv_area, req_tlv_space); 251 rep_tlv_buf = tipc_nametbl_get(net, req_tlv_area,
252 req_tlv_space);
252 break; 253 break;
253 case TIPC_CMD_GET_BEARER_NAMES: 254 case TIPC_CMD_GET_BEARER_NAMES:
254 rep_tlv_buf = tipc_bearer_get_names(net); 255 rep_tlv_buf = tipc_bearer_get_names(net);
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 23ff3caa1ce6..63cde8148aaf 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -62,12 +62,24 @@ static int __net_init tipc_init_net(struct net *net)
62 spin_lock_init(&tn->node_list_lock); 62 spin_lock_init(&tn->node_list_lock);
63 63
64 err = tipc_sk_rht_init(net); 64 err = tipc_sk_rht_init(net);
65 if (err)
66 goto out_sk_rht;
67
68 err = tipc_nametbl_init(net);
69 if (err)
70 goto out_nametbl;
71 return 0;
72
73out_nametbl:
74 tipc_sk_rht_destroy(net);
75out_sk_rht:
65 return err; 76 return err;
66} 77}
67 78
68static void __net_exit tipc_exit_net(struct net *net) 79static void __net_exit tipc_exit_net(struct net *net)
69{ 80{
70 tipc_net_stop(net); 81 tipc_net_stop(net);
82 tipc_nametbl_stop(net);
71 tipc_sk_rht_destroy(net); 83 tipc_sk_rht_destroy(net);
72} 84}
73 85
@@ -98,10 +110,6 @@ static int __init tipc_init(void)
98 if (err) 110 if (err)
99 goto out_pernet; 111 goto out_pernet;
100 112
101 err = tipc_nametbl_init();
102 if (err)
103 goto out_nametbl;
104
105 err = tipc_netlink_start(); 113 err = tipc_netlink_start();
106 if (err) 114 if (err)
107 goto out_netlink; 115 goto out_netlink;
@@ -133,8 +141,6 @@ out_sysctl:
133out_socket: 141out_socket:
134 tipc_netlink_stop(); 142 tipc_netlink_stop();
135out_netlink: 143out_netlink:
136 tipc_nametbl_stop();
137out_nametbl:
138 unregister_pernet_subsys(&tipc_net_ops); 144 unregister_pernet_subsys(&tipc_net_ops);
139out_pernet: 145out_pernet:
140 pr_err("Unable to start in single node mode\n"); 146 pr_err("Unable to start in single node mode\n");
@@ -147,7 +153,6 @@ static void __exit tipc_exit(void)
147 tipc_bearer_cleanup(); 153 tipc_bearer_cleanup();
148 tipc_netlink_stop(); 154 tipc_netlink_stop();
149 tipc_subscr_stop(); 155 tipc_subscr_stop();
150 tipc_nametbl_stop();
151 tipc_socket_stop(); 156 tipc_socket_stop();
152 tipc_unregister_sysctl(); 157 tipc_unregister_sysctl();
153 158
diff --git a/net/tipc/core.h b/net/tipc/core.h
index 1a7f81643668..893992944570 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -105,6 +105,10 @@ struct tipc_net {
105 105
106 /* Socket hash table */ 106 /* Socket hash table */
107 struct rhashtable sk_rht; 107 struct rhashtable sk_rht;
108
109 /* Name table */
110 spinlock_t nametbl_lock;
111 struct name_table *nametbl;
108}; 112};
109 113
110#ifdef CONFIG_SYSCTL 114#ifdef CONFIG_SYSCTL
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index a38f6a680df1..642fb137463c 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -426,7 +426,7 @@ exit:
426 * Returns 0 (TIPC_OK) if message ok and we can try again, -TIPC error 426 * Returns 0 (TIPC_OK) if message ok and we can try again, -TIPC error
427 * code if message to be rejected 427 * code if message to be rejected
428 */ 428 */
429int tipc_msg_eval(struct sk_buff *buf, u32 *dnode) 429int tipc_msg_eval(struct net *net, struct sk_buff *buf, u32 *dnode)
430{ 430{
431 struct tipc_msg *msg = buf_msg(buf); 431 struct tipc_msg *msg = buf_msg(buf);
432 u32 dport; 432 u32 dport;
@@ -441,7 +441,7 @@ int tipc_msg_eval(struct sk_buff *buf, u32 *dnode)
441 return -TIPC_ERR_NO_NAME; 441 return -TIPC_ERR_NO_NAME;
442 442
443 *dnode = addr_domain(msg_lookup_scope(msg)); 443 *dnode = addr_domain(msg_lookup_scope(msg));
444 dport = tipc_nametbl_translate(msg_nametype(msg), 444 dport = tipc_nametbl_translate(net, msg_nametype(msg),
445 msg_nameinst(msg), 445 msg_nameinst(msg),
446 dnode); 446 dnode);
447 if (!dport) 447 if (!dport)
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 75f324287244..69f37e652a8e 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -749,7 +749,7 @@ static inline u32 msg_tot_origport(struct tipc_msg *m)
749 749
750struct sk_buff *tipc_buf_acquire(u32 size); 750struct sk_buff *tipc_buf_acquire(u32 size);
751bool tipc_msg_reverse(struct sk_buff *buf, u32 *dnode, int err); 751bool tipc_msg_reverse(struct sk_buff *buf, u32 *dnode, int err);
752int tipc_msg_eval(struct sk_buff *buf, u32 *dnode); 752int tipc_msg_eval(struct net *net, struct sk_buff *buf, u32 *dnode);
753void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize, 753void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize,
754 u32 destnode); 754 u32 destnode);
755struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz, 755struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz,
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index d40df588263e..ba421321d15d 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -109,13 +109,14 @@ void named_cluster_distribute(struct net *net, struct sk_buff *skb)
109/** 109/**
110 * tipc_named_publish - tell other nodes about a new publication by this node 110 * tipc_named_publish - tell other nodes about a new publication by this node
111 */ 111 */
112struct sk_buff *tipc_named_publish(struct publication *publ) 112struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ)
113{ 113{
114 struct tipc_net *tn = net_generic(net, tipc_net_id);
114 struct sk_buff *buf; 115 struct sk_buff *buf;
115 struct distr_item *item; 116 struct distr_item *item;
116 117
117 list_add_tail_rcu(&publ->local_list, 118 list_add_tail_rcu(&publ->local_list,
118 &tipc_nametbl->publ_list[publ->scope]); 119 &tn->nametbl->publ_list[publ->scope]);
119 120
120 if (publ->scope == TIPC_NODE_SCOPE) 121 if (publ->scope == TIPC_NODE_SCOPE)
121 return NULL; 122 return NULL;
@@ -206,15 +207,16 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,
206 */ 207 */
207void tipc_named_node_up(struct net *net, u32 dnode) 208void tipc_named_node_up(struct net *net, u32 dnode)
208{ 209{
210 struct tipc_net *tn = net_generic(net, tipc_net_id);
209 struct sk_buff_head head; 211 struct sk_buff_head head;
210 212
211 __skb_queue_head_init(&head); 213 __skb_queue_head_init(&head);
212 214
213 rcu_read_lock(); 215 rcu_read_lock();
214 named_distribute(net, &head, dnode, 216 named_distribute(net, &head, dnode,
215 &tipc_nametbl->publ_list[TIPC_CLUSTER_SCOPE]); 217 &tn->nametbl->publ_list[TIPC_CLUSTER_SCOPE]);
216 named_distribute(net, &head, dnode, 218 named_distribute(net, &head, dnode,
217 &tipc_nametbl->publ_list[TIPC_ZONE_SCOPE]); 219 &tn->nametbl->publ_list[TIPC_ZONE_SCOPE]);
218 rcu_read_unlock(); 220 rcu_read_unlock();
219 221
220 tipc_link_xmit(net, &head, dnode, dnode); 222 tipc_link_xmit(net, &head, dnode, dnode);
@@ -262,14 +264,15 @@ static void tipc_publ_unsubscribe(struct net *net, struct publication *publ,
262 */ 264 */
263static void tipc_publ_purge(struct net *net, struct publication *publ, u32 addr) 265static void tipc_publ_purge(struct net *net, struct publication *publ, u32 addr)
264{ 266{
267 struct tipc_net *tn = net_generic(net, tipc_net_id);
265 struct publication *p; 268 struct publication *p;
266 269
267 spin_lock_bh(&tipc_nametbl_lock); 270 spin_lock_bh(&tn->nametbl_lock);
268 p = tipc_nametbl_remove_publ(publ->type, publ->lower, 271 p = tipc_nametbl_remove_publ(net, publ->type, publ->lower,
269 publ->node, publ->ref, publ->key); 272 publ->node, publ->ref, publ->key);
270 if (p) 273 if (p)
271 tipc_publ_unsubscribe(net, p, addr); 274 tipc_publ_unsubscribe(net, p, addr);
272 spin_unlock_bh(&tipc_nametbl_lock); 275 spin_unlock_bh(&tn->nametbl_lock);
273 276
274 if (p != publ) { 277 if (p != publ) {
275 pr_err("Unable to remove publication from failed node\n" 278 pr_err("Unable to remove publication from failed node\n"
@@ -302,7 +305,8 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i,
302 struct publication *publ = NULL; 305 struct publication *publ = NULL;
303 306
304 if (dtype == PUBLICATION) { 307 if (dtype == PUBLICATION) {
305 publ = tipc_nametbl_insert_publ(ntohl(i->type), ntohl(i->lower), 308 publ = tipc_nametbl_insert_publ(net, ntohl(i->type),
309 ntohl(i->lower),
306 ntohl(i->upper), 310 ntohl(i->upper),
307 TIPC_CLUSTER_SCOPE, node, 311 TIPC_CLUSTER_SCOPE, node,
308 ntohl(i->ref), ntohl(i->key)); 312 ntohl(i->ref), ntohl(i->key));
@@ -311,7 +315,8 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i,
311 return true; 315 return true;
312 } 316 }
313 } else if (dtype == WITHDRAWAL) { 317 } else if (dtype == WITHDRAWAL) {
314 publ = tipc_nametbl_remove_publ(ntohl(i->type), ntohl(i->lower), 318 publ = tipc_nametbl_remove_publ(net, ntohl(i->type),
319 ntohl(i->lower),
315 node, ntohl(i->ref), 320 node, ntohl(i->ref),
316 ntohl(i->key)); 321 ntohl(i->key));
317 if (publ) { 322 if (publ) {
@@ -376,19 +381,20 @@ void tipc_named_process_backlog(struct net *net)
376 */ 381 */
377void tipc_named_rcv(struct net *net, struct sk_buff *buf) 382void tipc_named_rcv(struct net *net, struct sk_buff *buf)
378{ 383{
384 struct tipc_net *tn = net_generic(net, tipc_net_id);
379 struct tipc_msg *msg = buf_msg(buf); 385 struct tipc_msg *msg = buf_msg(buf);
380 struct distr_item *item = (struct distr_item *)msg_data(msg); 386 struct distr_item *item = (struct distr_item *)msg_data(msg);
381 u32 count = msg_data_sz(msg) / ITEM_SIZE; 387 u32 count = msg_data_sz(msg) / ITEM_SIZE;
382 u32 node = msg_orignode(msg); 388 u32 node = msg_orignode(msg);
383 389
384 spin_lock_bh(&tipc_nametbl_lock); 390 spin_lock_bh(&tn->nametbl_lock);
385 while (count--) { 391 while (count--) {
386 if (!tipc_update_nametbl(net, item, node, msg_type(msg))) 392 if (!tipc_update_nametbl(net, item, node, msg_type(msg)))
387 tipc_named_add_backlog(item, msg_type(msg), node); 393 tipc_named_add_backlog(item, msg_type(msg), node);
388 item++; 394 item++;
389 } 395 }
390 tipc_named_process_backlog(net); 396 tipc_named_process_backlog(net);
391 spin_unlock_bh(&tipc_nametbl_lock); 397 spin_unlock_bh(&tn->nametbl_lock);
392 kfree_skb(buf); 398 kfree_skb(buf);
393} 399}
394 400
@@ -399,17 +405,18 @@ void tipc_named_rcv(struct net *net, struct sk_buff *buf)
399 * All name table entries published by this node are updated to reflect 405 * All name table entries published by this node are updated to reflect
400 * the node's new network address. 406 * the node's new network address.
401 */ 407 */
402void tipc_named_reinit(void) 408void tipc_named_reinit(struct net *net)
403{ 409{
410 struct tipc_net *tn = net_generic(net, tipc_net_id);
404 struct publication *publ; 411 struct publication *publ;
405 int scope; 412 int scope;
406 413
407 spin_lock_bh(&tipc_nametbl_lock); 414 spin_lock_bh(&tn->nametbl_lock);
408 415
409 for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_NODE_SCOPE; scope++) 416 for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_NODE_SCOPE; scope++)
410 list_for_each_entry_rcu(publ, &tipc_nametbl->publ_list[scope], 417 list_for_each_entry_rcu(publ, &tn->nametbl->publ_list[scope],
411 local_list) 418 local_list)
412 publ->node = tipc_own_addr; 419 publ->node = tipc_own_addr;
413 420
414 spin_unlock_bh(&tipc_nametbl_lock); 421 spin_unlock_bh(&tn->nametbl_lock);
415} 422}
diff --git a/net/tipc/name_distr.h b/net/tipc/name_distr.h
index 8039d84351b3..1ed2d7e48290 100644
--- a/net/tipc/name_distr.h
+++ b/net/tipc/name_distr.h
@@ -67,12 +67,12 @@ struct distr_item {
67 __be32 key; 67 __be32 key;
68}; 68};
69 69
70struct sk_buff *tipc_named_publish(struct publication *publ); 70struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ);
71struct sk_buff *tipc_named_withdraw(struct publication *publ); 71struct sk_buff *tipc_named_withdraw(struct publication *publ);
72void named_cluster_distribute(struct net *net, struct sk_buff *buf); 72void named_cluster_distribute(struct net *net, struct sk_buff *buf);
73void tipc_named_node_up(struct net *net, u32 dnode); 73void tipc_named_node_up(struct net *net, u32 dnode);
74void tipc_named_rcv(struct net *net, struct sk_buff *buf); 74void tipc_named_rcv(struct net *net, struct sk_buff *buf);
75void tipc_named_reinit(void); 75void tipc_named_reinit(struct net *net);
76void tipc_named_process_backlog(struct net *net); 76void tipc_named_process_backlog(struct net *net);
77void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr); 77void tipc_publ_notify(struct net *net, struct list_head *nsub_list, u32 addr);
78 78
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index beed5fdda004..57e39c16a8c3 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -34,6 +34,7 @@
34 * POSSIBILITY OF SUCH DAMAGE. 34 * POSSIBILITY OF SUCH DAMAGE.
35 */ 35 */
36 36
37#include <net/sock.h>
37#include "core.h" 38#include "core.h"
38#include "config.h" 39#include "config.h"
39#include "name_table.h" 40#include "name_table.h"
@@ -106,9 +107,6 @@ struct name_seq {
106 struct rcu_head rcu; 107 struct rcu_head rcu;
107}; 108};
108 109
109struct name_table *tipc_nametbl;
110DEFINE_SPINLOCK(tipc_nametbl_lock);
111
112static int hash(int x) 110static int hash(int x)
113{ 111{
114 return x & (TIPC_NAMETBL_SIZE - 1); 112 return x & (TIPC_NAMETBL_SIZE - 1);
@@ -448,12 +446,13 @@ static void tipc_nameseq_subscribe(struct name_seq *nseq,
448 } 446 }
449} 447}
450 448
451static struct name_seq *nametbl_find_seq(u32 type) 449static struct name_seq *nametbl_find_seq(struct net *net, u32 type)
452{ 450{
451 struct tipc_net *tn = net_generic(net, tipc_net_id);
453 struct hlist_head *seq_head; 452 struct hlist_head *seq_head;
454 struct name_seq *ns; 453 struct name_seq *ns;
455 454
456 seq_head = &tipc_nametbl->seq_hlist[hash(type)]; 455 seq_head = &tn->nametbl->seq_hlist[hash(type)];
457 hlist_for_each_entry_rcu(ns, seq_head, ns_list) { 456 hlist_for_each_entry_rcu(ns, seq_head, ns_list) {
458 if (ns->type == type) 457 if (ns->type == type)
459 return ns; 458 return ns;
@@ -462,11 +461,13 @@ static struct name_seq *nametbl_find_seq(u32 type)
462 return NULL; 461 return NULL;
463}; 462};
464 463
465struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, 464struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type,
466 u32 scope, u32 node, u32 port, u32 key) 465 u32 lower, u32 upper, u32 scope,
466 u32 node, u32 port, u32 key)
467{ 467{
468 struct tipc_net *tn = net_generic(net, tipc_net_id);
468 struct publication *publ; 469 struct publication *publ;
469 struct name_seq *seq = nametbl_find_seq(type); 470 struct name_seq *seq = nametbl_find_seq(net, type);
470 int index = hash(type); 471 int index = hash(type);
471 472
472 if ((scope < TIPC_ZONE_SCOPE) || (scope > TIPC_NODE_SCOPE) || 473 if ((scope < TIPC_ZONE_SCOPE) || (scope > TIPC_NODE_SCOPE) ||
@@ -477,8 +478,7 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
477 } 478 }
478 479
479 if (!seq) 480 if (!seq)
480 seq = tipc_nameseq_create(type, 481 seq = tipc_nameseq_create(type, &tn->nametbl->seq_hlist[index]);
481 &tipc_nametbl->seq_hlist[index]);
482 if (!seq) 482 if (!seq)
483 return NULL; 483 return NULL;
484 484
@@ -489,11 +489,12 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
489 return publ; 489 return publ;
490} 490}
491 491
492struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, 492struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type,
493 u32 node, u32 ref, u32 key) 493 u32 lower, u32 node, u32 ref,
494 u32 key)
494{ 495{
495 struct publication *publ; 496 struct publication *publ;
496 struct name_seq *seq = nametbl_find_seq(type); 497 struct name_seq *seq = nametbl_find_seq(net, type);
497 498
498 if (!seq) 499 if (!seq)
499 return NULL; 500 return NULL;
@@ -524,7 +525,8 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
524 * - if name translation is attempted and fails, sets 'destnode' to 0 525 * - if name translation is attempted and fails, sets 'destnode' to 0
525 * and returns 0 526 * and returns 0
526 */ 527 */
527u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) 528u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance,
529 u32 *destnode)
528{ 530{
529 struct sub_seq *sseq; 531 struct sub_seq *sseq;
530 struct name_info *info; 532 struct name_info *info;
@@ -537,7 +539,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
537 return 0; 539 return 0;
538 540
539 rcu_read_lock(); 541 rcu_read_lock();
540 seq = nametbl_find_seq(type); 542 seq = nametbl_find_seq(net, type);
541 if (unlikely(!seq)) 543 if (unlikely(!seq))
542 goto not_found; 544 goto not_found;
543 spin_lock_bh(&seq->lock); 545 spin_lock_bh(&seq->lock);
@@ -610,8 +612,8 @@ not_found:
610 * 612 *
611 * Returns non-zero if any off-node ports overlap 613 * Returns non-zero if any off-node ports overlap
612 */ 614 */
613int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, 615int tipc_nametbl_mc_translate(struct net *net, u32 type, u32 lower, u32 upper,
614 struct tipc_port_list *dports) 616 u32 limit, struct tipc_port_list *dports)
615{ 617{
616 struct name_seq *seq; 618 struct name_seq *seq;
617 struct sub_seq *sseq; 619 struct sub_seq *sseq;
@@ -620,7 +622,7 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
620 int res = 0; 622 int res = 0;
621 623
622 rcu_read_lock(); 624 rcu_read_lock();
623 seq = nametbl_find_seq(type); 625 seq = nametbl_find_seq(net, type);
624 if (!seq) 626 if (!seq)
625 goto exit; 627 goto exit;
626 628
@@ -657,24 +659,25 @@ struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower,
657{ 659{
658 struct publication *publ; 660 struct publication *publ;
659 struct sk_buff *buf = NULL; 661 struct sk_buff *buf = NULL;
662 struct tipc_net *tn = net_generic(net, tipc_net_id);
660 663
661 spin_lock_bh(&tipc_nametbl_lock); 664 spin_lock_bh(&tn->nametbl_lock);
662 if (tipc_nametbl->local_publ_count >= TIPC_MAX_PUBLICATIONS) { 665 if (tn->nametbl->local_publ_count >= TIPC_MAX_PUBLICATIONS) {
663 pr_warn("Publication failed, local publication limit reached (%u)\n", 666 pr_warn("Publication failed, local publication limit reached (%u)\n",
664 TIPC_MAX_PUBLICATIONS); 667 TIPC_MAX_PUBLICATIONS);
665 spin_unlock_bh(&tipc_nametbl_lock); 668 spin_unlock_bh(&tn->nametbl_lock);
666 return NULL; 669 return NULL;
667 } 670 }
668 671
669 publ = tipc_nametbl_insert_publ(type, lower, upper, scope, 672 publ = tipc_nametbl_insert_publ(net, type, lower, upper, scope,
670 tipc_own_addr, port_ref, key); 673 tipc_own_addr, port_ref, key);
671 if (likely(publ)) { 674 if (likely(publ)) {
672 tipc_nametbl->local_publ_count++; 675 tn->nametbl->local_publ_count++;
673 buf = tipc_named_publish(publ); 676 buf = tipc_named_publish(net, publ);
674 /* Any pending external events? */ 677 /* Any pending external events? */
675 tipc_named_process_backlog(net); 678 tipc_named_process_backlog(net);
676 } 679 }
677 spin_unlock_bh(&tipc_nametbl_lock); 680 spin_unlock_bh(&tn->nametbl_lock);
678 681
679 if (buf) 682 if (buf)
680 named_cluster_distribute(net, buf); 683 named_cluster_distribute(net, buf);
@@ -689,11 +692,13 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
689{ 692{
690 struct publication *publ; 693 struct publication *publ;
691 struct sk_buff *skb = NULL; 694 struct sk_buff *skb = NULL;
695 struct tipc_net *tn = net_generic(net, tipc_net_id);
692 696
693 spin_lock_bh(&tipc_nametbl_lock); 697 spin_lock_bh(&tn->nametbl_lock);
694 publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key); 698 publ = tipc_nametbl_remove_publ(net, type, lower, tipc_own_addr,
699 ref, key);
695 if (likely(publ)) { 700 if (likely(publ)) {
696 tipc_nametbl->local_publ_count--; 701 tn->nametbl->local_publ_count--;
697 skb = tipc_named_withdraw(publ); 702 skb = tipc_named_withdraw(publ);
698 /* Any pending external events? */ 703 /* Any pending external events? */
699 tipc_named_process_backlog(net); 704 tipc_named_process_backlog(net);
@@ -704,7 +709,7 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
704 "(type=%u, lower=%u, ref=%u, key=%u)\n", 709 "(type=%u, lower=%u, ref=%u, key=%u)\n",
705 type, lower, ref, key); 710 type, lower, ref, key);
706 } 711 }
707 spin_unlock_bh(&tipc_nametbl_lock); 712 spin_unlock_bh(&tn->nametbl_lock);
708 713
709 if (skb) { 714 if (skb) {
710 named_cluster_distribute(net, skb); 715 named_cluster_distribute(net, skb);
@@ -718,15 +723,15 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
718 */ 723 */
719void tipc_nametbl_subscribe(struct tipc_subscription *s) 724void tipc_nametbl_subscribe(struct tipc_subscription *s)
720{ 725{
726 struct tipc_net *tn = net_generic(s->net, tipc_net_id);
721 u32 type = s->seq.type; 727 u32 type = s->seq.type;
722 int index = hash(type); 728 int index = hash(type);
723 struct name_seq *seq; 729 struct name_seq *seq;
724 730
725 spin_lock_bh(&tipc_nametbl_lock); 731 spin_lock_bh(&tn->nametbl_lock);
726 seq = nametbl_find_seq(type); 732 seq = nametbl_find_seq(s->net, type);
727 if (!seq) 733 if (!seq)
728 seq = tipc_nameseq_create(type, 734 seq = tipc_nameseq_create(type, &tn->nametbl->seq_hlist[index]);
729 &tipc_nametbl->seq_hlist[index]);
730 if (seq) { 735 if (seq) {
731 spin_lock_bh(&seq->lock); 736 spin_lock_bh(&seq->lock);
732 tipc_nameseq_subscribe(seq, s); 737 tipc_nameseq_subscribe(seq, s);
@@ -735,7 +740,7 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s)
735 pr_warn("Failed to create subscription for {%u,%u,%u}\n", 740 pr_warn("Failed to create subscription for {%u,%u,%u}\n",
736 s->seq.type, s->seq.lower, s->seq.upper); 741 s->seq.type, s->seq.lower, s->seq.upper);
737 } 742 }
738 spin_unlock_bh(&tipc_nametbl_lock); 743 spin_unlock_bh(&tn->nametbl_lock);
739} 744}
740 745
741/** 746/**
@@ -743,10 +748,11 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s)
743 */ 748 */
744void tipc_nametbl_unsubscribe(struct tipc_subscription *s) 749void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
745{ 750{
751 struct tipc_net *tn = net_generic(s->net, tipc_net_id);
746 struct name_seq *seq; 752 struct name_seq *seq;
747 753
748 spin_lock_bh(&tipc_nametbl_lock); 754 spin_lock_bh(&tn->nametbl_lock);
749 seq = nametbl_find_seq(s->seq.type); 755 seq = nametbl_find_seq(s->net, s->seq.type);
750 if (seq != NULL) { 756 if (seq != NULL) {
751 spin_lock_bh(&seq->lock); 757 spin_lock_bh(&seq->lock);
752 list_del_init(&s->nameseq_list); 758 list_del_init(&s->nameseq_list);
@@ -759,7 +765,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
759 spin_unlock_bh(&seq->lock); 765 spin_unlock_bh(&seq->lock);
760 } 766 }
761 } 767 }
762 spin_unlock_bh(&tipc_nametbl_lock); 768 spin_unlock_bh(&tn->nametbl_lock);
763} 769}
764 770
765/** 771/**
@@ -861,9 +867,10 @@ static int nametbl_header(char *buf, int len, u32 depth)
861/** 867/**
862 * nametbl_list - print specified name table contents into the given buffer 868 * nametbl_list - print specified name table contents into the given buffer
863 */ 869 */
864static int nametbl_list(char *buf, int len, u32 depth_info, 870static int nametbl_list(struct net *net, char *buf, int len, u32 depth_info,
865 u32 type, u32 lowbound, u32 upbound) 871 u32 type, u32 lowbound, u32 upbound)
866{ 872{
873 struct tipc_net *tn = net_generic(net, tipc_net_id);
867 struct hlist_head *seq_head; 874 struct hlist_head *seq_head;
868 struct name_seq *seq; 875 struct name_seq *seq;
869 int all_types; 876 int all_types;
@@ -883,7 +890,7 @@ static int nametbl_list(char *buf, int len, u32 depth_info,
883 lowbound = 0; 890 lowbound = 0;
884 upbound = ~0; 891 upbound = ~0;
885 for (i = 0; i < TIPC_NAMETBL_SIZE; i++) { 892 for (i = 0; i < TIPC_NAMETBL_SIZE; i++) {
886 seq_head = &tipc_nametbl->seq_hlist[i]; 893 seq_head = &tn->nametbl->seq_hlist[i];
887 hlist_for_each_entry_rcu(seq, seq_head, ns_list) { 894 hlist_for_each_entry_rcu(seq, seq_head, ns_list) {
888 ret += nameseq_list(seq, buf + ret, len - ret, 895 ret += nameseq_list(seq, buf + ret, len - ret,
889 depth, seq->type, 896 depth, seq->type,
@@ -899,7 +906,7 @@ static int nametbl_list(char *buf, int len, u32 depth_info,
899 } 906 }
900 ret += nametbl_header(buf + ret, len - ret, depth); 907 ret += nametbl_header(buf + ret, len - ret, depth);
901 i = hash(type); 908 i = hash(type);
902 seq_head = &tipc_nametbl->seq_hlist[i]; 909 seq_head = &tn->nametbl->seq_hlist[i];
903 hlist_for_each_entry_rcu(seq, seq_head, ns_list) { 910 hlist_for_each_entry_rcu(seq, seq_head, ns_list) {
904 if (seq->type == type) { 911 if (seq->type == type) {
905 ret += nameseq_list(seq, buf + ret, len - ret, 912 ret += nameseq_list(seq, buf + ret, len - ret,
@@ -912,7 +919,8 @@ static int nametbl_list(char *buf, int len, u32 depth_info,
912 return ret; 919 return ret;
913} 920}
914 921
915struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space) 922struct sk_buff *tipc_nametbl_get(struct net *net, const void *req_tlv_area,
923 int req_tlv_space)
916{ 924{
917 struct sk_buff *buf; 925 struct sk_buff *buf;
918 struct tipc_name_table_query *argv; 926 struct tipc_name_table_query *argv;
@@ -933,7 +941,7 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space)
933 pb_len = ULTRA_STRING_MAX_LEN; 941 pb_len = ULTRA_STRING_MAX_LEN;
934 argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area); 942 argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area);
935 rcu_read_lock(); 943 rcu_read_lock();
936 str_len = nametbl_list(pb, pb_len, ntohl(argv->depth), 944 str_len = nametbl_list(net, pb, pb_len, ntohl(argv->depth),
937 ntohl(argv->type), 945 ntohl(argv->type),
938 ntohl(argv->lowbound), ntohl(argv->upbound)); 946 ntohl(argv->lowbound), ntohl(argv->upbound));
939 rcu_read_unlock(); 947 rcu_read_unlock();
@@ -944,8 +952,10 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space)
944 return buf; 952 return buf;
945} 953}
946 954
947int tipc_nametbl_init(void) 955int tipc_nametbl_init(struct net *net)
948{ 956{
957 struct tipc_net *tn = net_generic(net, tipc_net_id);
958 struct name_table *tipc_nametbl;
949 int i; 959 int i;
950 960
951 tipc_nametbl = kzalloc(sizeof(*tipc_nametbl), GFP_ATOMIC); 961 tipc_nametbl = kzalloc(sizeof(*tipc_nametbl), GFP_ATOMIC);
@@ -958,6 +968,8 @@ int tipc_nametbl_init(void)
958 INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_ZONE_SCOPE]); 968 INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_ZONE_SCOPE]);
959 INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_CLUSTER_SCOPE]); 969 INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_CLUSTER_SCOPE]);
960 INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_NODE_SCOPE]); 970 INIT_LIST_HEAD(&tipc_nametbl->publ_list[TIPC_NODE_SCOPE]);
971 tn->nametbl = tipc_nametbl;
972 spin_lock_init(&tn->nametbl_lock);
961 return 0; 973 return 0;
962} 974}
963 975
@@ -966,7 +978,7 @@ int tipc_nametbl_init(void)
966 * 978 *
967 * tipc_nametbl_lock must be held when calling this function 979 * tipc_nametbl_lock must be held when calling this function
968 */ 980 */
969static void tipc_purge_publications(struct name_seq *seq) 981static void tipc_purge_publications(struct net *net, struct name_seq *seq)
970{ 982{
971 struct publication *publ, *safe; 983 struct publication *publ, *safe;
972 struct sub_seq *sseq; 984 struct sub_seq *sseq;
@@ -976,8 +988,8 @@ static void tipc_purge_publications(struct name_seq *seq)
976 sseq = seq->sseqs; 988 sseq = seq->sseqs;
977 info = sseq->info; 989 info = sseq->info;
978 list_for_each_entry_safe(publ, safe, &info->zone_list, zone_list) { 990 list_for_each_entry_safe(publ, safe, &info->zone_list, zone_list) {
979 tipc_nametbl_remove_publ(publ->type, publ->lower, publ->node, 991 tipc_nametbl_remove_publ(net, publ->type, publ->lower,
980 publ->ref, publ->key); 992 publ->node, publ->ref, publ->key);
981 kfree_rcu(publ, rcu); 993 kfree_rcu(publ, rcu);
982 } 994 }
983 hlist_del_init_rcu(&seq->ns_list); 995 hlist_del_init_rcu(&seq->ns_list);
@@ -987,25 +999,27 @@ static void tipc_purge_publications(struct name_seq *seq)
987 kfree_rcu(seq, rcu); 999 kfree_rcu(seq, rcu);
988} 1000}
989 1001
990void tipc_nametbl_stop(void) 1002void tipc_nametbl_stop(struct net *net)
991{ 1003{
992 u32 i; 1004 u32 i;
993 struct name_seq *seq; 1005 struct name_seq *seq;
994 struct hlist_head *seq_head; 1006 struct hlist_head *seq_head;
1007 struct tipc_net *tn = net_generic(net, tipc_net_id);
1008 struct name_table *tipc_nametbl = tn->nametbl;
995 1009
996 /* Verify name table is empty and purge any lingering 1010 /* Verify name table is empty and purge any lingering
997 * publications, then release the name table 1011 * publications, then release the name table
998 */ 1012 */
999 spin_lock_bh(&tipc_nametbl_lock); 1013 spin_lock_bh(&tn->nametbl_lock);
1000 for (i = 0; i < TIPC_NAMETBL_SIZE; i++) { 1014 for (i = 0; i < TIPC_NAMETBL_SIZE; i++) {
1001 if (hlist_empty(&tipc_nametbl->seq_hlist[i])) 1015 if (hlist_empty(&tipc_nametbl->seq_hlist[i]))
1002 continue; 1016 continue;
1003 seq_head = &tipc_nametbl->seq_hlist[i]; 1017 seq_head = &tipc_nametbl->seq_hlist[i];
1004 hlist_for_each_entry_rcu(seq, seq_head, ns_list) { 1018 hlist_for_each_entry_rcu(seq, seq_head, ns_list) {
1005 tipc_purge_publications(seq); 1019 tipc_purge_publications(net, seq);
1006 } 1020 }
1007 } 1021 }
1008 spin_unlock_bh(&tipc_nametbl_lock); 1022 spin_unlock_bh(&tn->nametbl_lock);
1009 1023
1010 synchronize_net(); 1024 synchronize_net();
1011 kfree(tipc_nametbl); 1025 kfree(tipc_nametbl);
@@ -1109,9 +1123,10 @@ static int __tipc_nl_subseq_list(struct tipc_nl_msg *msg, struct name_seq *seq,
1109 return 0; 1123 return 0;
1110} 1124}
1111 1125
1112static int __tipc_nl_seq_list(struct tipc_nl_msg *msg, u32 *last_type, 1126static int tipc_nl_seq_list(struct net *net, struct tipc_nl_msg *msg,
1113 u32 *last_lower, u32 *last_publ) 1127 u32 *last_type, u32 *last_lower, u32 *last_publ)
1114{ 1128{
1129 struct tipc_net *tn = net_generic(net, tipc_net_id);
1115 struct hlist_head *seq_head; 1130 struct hlist_head *seq_head;
1116 struct name_seq *seq = NULL; 1131 struct name_seq *seq = NULL;
1117 int err; 1132 int err;
@@ -1123,10 +1138,10 @@ static int __tipc_nl_seq_list(struct tipc_nl_msg *msg, u32 *last_type,
1123 i = 0; 1138 i = 0;
1124 1139
1125 for (; i < TIPC_NAMETBL_SIZE; i++) { 1140 for (; i < TIPC_NAMETBL_SIZE; i++) {
1126 seq_head = &tipc_nametbl->seq_hlist[i]; 1141 seq_head = &tn->nametbl->seq_hlist[i];
1127 1142
1128 if (*last_type) { 1143 if (*last_type) {
1129 seq = nametbl_find_seq(*last_type); 1144 seq = nametbl_find_seq(net, *last_type);
1130 if (!seq) 1145 if (!seq)
1131 return -EPIPE; 1146 return -EPIPE;
1132 } else { 1147 } else {
@@ -1160,6 +1175,7 @@ int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb)
1160 u32 last_type = cb->args[0]; 1175 u32 last_type = cb->args[0];
1161 u32 last_lower = cb->args[1]; 1176 u32 last_lower = cb->args[1];
1162 u32 last_publ = cb->args[2]; 1177 u32 last_publ = cb->args[2];
1178 struct net *net = sock_net(skb->sk);
1163 struct tipc_nl_msg msg; 1179 struct tipc_nl_msg msg;
1164 1180
1165 if (done) 1181 if (done)
@@ -1170,7 +1186,7 @@ int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb)
1170 msg.seq = cb->nlh->nlmsg_seq; 1186 msg.seq = cb->nlh->nlmsg_seq;
1171 1187
1172 rcu_read_lock(); 1188 rcu_read_lock();
1173 err = __tipc_nl_seq_list(&msg, &last_type, &last_lower, &last_publ); 1189 err = tipc_nl_seq_list(net, &msg, &last_type, &last_lower, &last_publ);
1174 if (!err) { 1190 if (!err) {
1175 done = 1; 1191 done = 1;
1176 } else if (err != -EMSGSIZE) { 1192 } else if (err != -EMSGSIZE) {
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h
index efccaca7a5d5..f67b3d8d4b2f 100644
--- a/net/tipc/name_table.h
+++ b/net/tipc/name_table.h
@@ -95,28 +95,27 @@ struct name_table {
95 u32 local_publ_count; 95 u32 local_publ_count;
96}; 96};
97 97
98extern spinlock_t tipc_nametbl_lock;
99extern struct name_table *tipc_nametbl;
100
101int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb); 98int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb);
102 99
103struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space); 100struct sk_buff *tipc_nametbl_get(struct net *net, const void *req_tlv_area,
104u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); 101 int req_tlv_space);
105int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, 102u32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *node);
106 struct tipc_port_list *dports); 103int tipc_nametbl_mc_translate(struct net *net, u32 type, u32 lower, u32 upper,
104 u32 limit, struct tipc_port_list *dports);
107struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower, 105struct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower,
108 u32 upper, u32 scope, u32 port_ref, 106 u32 upper, u32 scope, u32 port_ref,
109 u32 key); 107 u32 key);
110int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref, 108int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
111 u32 key); 109 u32 key);
112struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, 110struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type,
113 u32 scope, u32 node, u32 ref, 111 u32 lower, u32 upper, u32 scope,
112 u32 node, u32 ref, u32 key);
113struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type,
114 u32 lower, u32 node, u32 ref,
114 u32 key); 115 u32 key);
115struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, u32 node,
116 u32 ref, u32 key);
117void tipc_nametbl_subscribe(struct tipc_subscription *s); 116void tipc_nametbl_subscribe(struct tipc_subscription *s);
118void tipc_nametbl_unsubscribe(struct tipc_subscription *s); 117void tipc_nametbl_unsubscribe(struct tipc_subscription *s);
119int tipc_nametbl_init(void); 118int tipc_nametbl_init(struct net *net);
120void tipc_nametbl_stop(void); 119void tipc_nametbl_stop(struct net *net);
121 120
122#endif 121#endif
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 44ccf47c79a3..04445d210e45 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -116,7 +116,7 @@ int tipc_net_start(struct net *net, u32 addr)
116 int res; 116 int res;
117 117
118 tipc_own_addr = addr; 118 tipc_own_addr = addr;
119 tipc_named_reinit(); 119 tipc_named_reinit(net);
120 tipc_sk_reinit(net); 120 tipc_sk_reinit(net);
121 res = tipc_bclink_init(net); 121 res = tipc_bclink_init(net);
122 if (res) 122 if (res)
diff --git a/net/tipc/server.c b/net/tipc/server.c
index 869eb0905754..b5bdaf721d70 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -256,7 +256,8 @@ static int tipc_receive_from_sock(struct tipc_conn *con)
256 goto out_close; 256 goto out_close;
257 } 257 }
258 258
259 s->tipc_conn_recvmsg(con->conid, &addr, con->usr_data, buf, ret); 259 s->tipc_conn_recvmsg(sock_net(con->sock->sk), con->conid, &addr,
260 con->usr_data, buf, ret);
260 261
261 kmem_cache_free(s->rcvbuf_cache, buf); 262 kmem_cache_free(s->rcvbuf_cache, buf);
262 263
diff --git a/net/tipc/server.h b/net/tipc/server.h
index 87bc05c70dce..9c979a01997c 100644
--- a/net/tipc/server.h
+++ b/net/tipc/server.h
@@ -38,6 +38,7 @@
38 38
39#include <linux/idr.h> 39#include <linux/idr.h>
40#include <linux/tipc.h> 40#include <linux/tipc.h>
41#include <net/net_namespace.h>
41 42
42#define TIPC_SERVER_NAME_LEN 32 43#define TIPC_SERVER_NAME_LEN 32
43 44
@@ -66,10 +67,11 @@ struct tipc_server {
66 struct workqueue_struct *rcv_wq; 67 struct workqueue_struct *rcv_wq;
67 struct workqueue_struct *send_wq; 68 struct workqueue_struct *send_wq;
68 int max_rcvbuf_size; 69 int max_rcvbuf_size;
69 void *(*tipc_conn_new) (int conid); 70 void *(*tipc_conn_new)(int conid);
70 void (*tipc_conn_shutdown) (int conid, void *usr_data); 71 void (*tipc_conn_shutdown)(int conid, void *usr_data);
71 void (*tipc_conn_recvmsg) (int conid, struct sockaddr_tipc *addr, 72 void (*tipc_conn_recvmsg)(struct net *net, int conid,
72 void *usr_data, void *buf, size_t len); 73 struct sockaddr_tipc *addr, void *usr_data,
74 void *buf, size_t len);
73 struct sockaddr_tipc *saddr; 75 struct sockaddr_tipc *saddr;
74 const char name[TIPC_SERVER_NAME_LEN]; 76 const char name[TIPC_SERVER_NAME_LEN];
75 int imp; 77 int imp;
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index accb02cb3527..4670e1e46c89 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -778,11 +778,8 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff *buf)
778 scope = TIPC_NODE_SCOPE; 778 scope = TIPC_NODE_SCOPE;
779 779
780 /* Create destination port list: */ 780 /* Create destination port list: */
781 tipc_nametbl_mc_translate(msg_nametype(msg), 781 tipc_nametbl_mc_translate(net, msg_nametype(msg), msg_namelower(msg),
782 msg_namelower(msg), 782 msg_nameupper(msg), scope, &dports);
783 msg_nameupper(msg),
784 scope,
785 &dports);
786 last = dports.count; 783 last = dports.count;
787 if (!last) { 784 if (!last) {
788 kfree_skb(buf); 785 kfree_skb(buf);
@@ -943,7 +940,7 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock,
943 msg_set_nametype(mhdr, type); 940 msg_set_nametype(mhdr, type);
944 msg_set_nameinst(mhdr, inst); 941 msg_set_nameinst(mhdr, inst);
945 msg_set_lookup_scope(mhdr, tipc_addr_scope(domain)); 942 msg_set_lookup_scope(mhdr, tipc_addr_scope(domain));
946 dport = tipc_nametbl_translate(type, inst, &dnode); 943 dport = tipc_nametbl_translate(net, type, inst, &dnode);
947 msg_set_destnode(mhdr, dnode); 944 msg_set_destnode(mhdr, dnode);
948 msg_set_destport(mhdr, dport); 945 msg_set_destport(mhdr, dport);
949 if (unlikely(!dport && !dnode)) { 946 if (unlikely(!dport && !dnode)) {
@@ -1765,7 +1762,7 @@ int tipc_sk_rcv(struct net *net, struct sk_buff *skb)
1765 /* Validate destination and message */ 1762 /* Validate destination and message */
1766 tsk = tipc_sk_lookup(net, dport); 1763 tsk = tipc_sk_lookup(net, dport);
1767 if (unlikely(!tsk)) { 1764 if (unlikely(!tsk)) {
1768 rc = tipc_msg_eval(skb, &dnode); 1765 rc = tipc_msg_eval(net, skb, &dnode);
1769 goto exit; 1766 goto exit;
1770 } 1767 }
1771 sk = &tsk->sk; 1768 sk = &tsk->sk;
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index e6cb959371dc..b71dbc0ae8f9 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -50,8 +50,9 @@ struct tipc_subscriber {
50 struct list_head subscription_list; 50 struct list_head subscription_list;
51}; 51};
52 52
53static void subscr_conn_msg_event(int conid, struct sockaddr_tipc *addr, 53static void subscr_conn_msg_event(struct net *net, int conid,
54 void *usr_data, void *buf, size_t len); 54 struct sockaddr_tipc *addr, void *usr_data,
55 void *buf, size_t len);
55static void *subscr_named_msg_event(int conid); 56static void *subscr_named_msg_event(int conid);
56static void subscr_conn_shutdown_event(int conid, void *usr_data); 57static void subscr_conn_shutdown_event(int conid, void *usr_data);
57 58
@@ -260,7 +261,7 @@ static void subscr_cancel(struct tipc_subscr *s,
260 * 261 *
261 * Called with subscriber lock held. 262 * Called with subscriber lock held.
262 */ 263 */
263static int subscr_subscribe(struct tipc_subscr *s, 264static int subscr_subscribe(struct net *net, struct tipc_subscr *s,
264 struct tipc_subscriber *subscriber, 265 struct tipc_subscriber *subscriber,
265 struct tipc_subscription **sub_p) { 266 struct tipc_subscription **sub_p) {
266 struct tipc_subscription *sub; 267 struct tipc_subscription *sub;
@@ -291,6 +292,7 @@ static int subscr_subscribe(struct tipc_subscr *s,
291 } 292 }
292 293
293 /* Initialize subscription object */ 294 /* Initialize subscription object */
295 sub->net = net;
294 sub->seq.type = htohl(s->seq.type, swap); 296 sub->seq.type = htohl(s->seq.type, swap);
295 sub->seq.lower = htohl(s->seq.lower, swap); 297 sub->seq.lower = htohl(s->seq.lower, swap);
296 sub->seq.upper = htohl(s->seq.upper, swap); 298 sub->seq.upper = htohl(s->seq.upper, swap);
@@ -323,14 +325,16 @@ static void subscr_conn_shutdown_event(int conid, void *usr_data)
323} 325}
324 326
325/* Handle one request to create a new subscription for the subscriber */ 327/* Handle one request to create a new subscription for the subscriber */
326static void subscr_conn_msg_event(int conid, struct sockaddr_tipc *addr, 328static void subscr_conn_msg_event(struct net *net, int conid,
327 void *usr_data, void *buf, size_t len) 329 struct sockaddr_tipc *addr, void *usr_data,
330 void *buf, size_t len)
328{ 331{
329 struct tipc_subscriber *subscriber = usr_data; 332 struct tipc_subscriber *subscriber = usr_data;
330 struct tipc_subscription *sub = NULL; 333 struct tipc_subscription *sub = NULL;
331 334
332 spin_lock_bh(&subscriber->lock); 335 spin_lock_bh(&subscriber->lock);
333 if (subscr_subscribe((struct tipc_subscr *)buf, subscriber, &sub) < 0) { 336 if (subscr_subscribe(net, (struct tipc_subscr *)buf, subscriber,
337 &sub) < 0) {
334 spin_unlock_bh(&subscriber->lock); 338 spin_unlock_bh(&subscriber->lock);
335 subscr_terminate(subscriber); 339 subscr_terminate(subscriber);
336 return; 340 return;
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h
index 0d3958956aca..670f57096635 100644
--- a/net/tipc/subscr.h
+++ b/net/tipc/subscr.h
@@ -49,6 +49,7 @@ struct tipc_subscriber;
49 * struct tipc_subscription - TIPC network topology subscription object 49 * struct tipc_subscription - TIPC network topology subscription object
50 * @subscriber: pointer to its subscriber 50 * @subscriber: pointer to its subscriber
51 * @seq: name sequence associated with subscription 51 * @seq: name sequence associated with subscription
52 * @net: point to network namespace
52 * @timeout: duration of subscription (in ms) 53 * @timeout: duration of subscription (in ms)
53 * @filter: event filtering to be done for subscription 54 * @filter: event filtering to be done for subscription
54 * @timer: timer governing subscription duration (optional) 55 * @timer: timer governing subscription duration (optional)
@@ -61,6 +62,7 @@ struct tipc_subscriber;
61struct tipc_subscription { 62struct tipc_subscription {
62 struct tipc_subscriber *subscriber; 63 struct tipc_subscriber *subscriber;
63 struct tipc_name_seq seq; 64 struct tipc_name_seq seq;
65 struct net *net;
64 unsigned long timeout; 66 unsigned long timeout;
65 u32 filter; 67 u32 filter;
66 struct timer_list timer; 68 struct timer_list timer;