aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/discover.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2015-01-09 02:27:04 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-12 16:24:32 -0500
commitc93d3baa24095887005647984cff5de8c63d3611 (patch)
tree1c7917d92605991696960243fe97dfef9d14913a /net/tipc/discover.c
parent54fef04ad05f15984082c225fe47ce6af8ea1c5c (diff)
tipc: involve namespace infrastructure
Involve namespace infrastructure, make the "tipc_net_id" global variable aware of per namespace, and rename it to "net_id". In order that the conversion can be successfully done, an instance of networking namespace must be passed to relevant functions, allowing them to access the "net_id" variable of per namespace. Signed-off-by: Ying Xue <ying.xue@windriver.com> Tested-by: Tero Aho <Tero.Aho@coriant.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/discover.c')
-rw-r--r--net/tipc/discover.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 1a3a98582034..246a23788ded 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -72,12 +72,14 @@ struct tipc_link_req {
72 72
73/** 73/**
74 * tipc_disc_init_msg - initialize a link setup message 74 * tipc_disc_init_msg - initialize a link setup message
75 * @net: the applicable net namespace
75 * @type: message type (request or response) 76 * @type: message type (request or response)
76 * @b_ptr: ptr to bearer issuing message 77 * @b_ptr: ptr to bearer issuing message
77 */ 78 */
78static void tipc_disc_init_msg(struct sk_buff *buf, u32 type, 79static void tipc_disc_init_msg(struct net *net, struct sk_buff *buf, u32 type,
79 struct tipc_bearer *b_ptr) 80 struct tipc_bearer *b_ptr)
80{ 81{
82 struct tipc_net *tn = net_generic(net, tipc_net_id);
81 struct tipc_msg *msg; 83 struct tipc_msg *msg;
82 u32 dest_domain = b_ptr->domain; 84 u32 dest_domain = b_ptr->domain;
83 85
@@ -86,7 +88,7 @@ static void tipc_disc_init_msg(struct sk_buff *buf, u32 type,
86 msg_set_non_seq(msg, 1); 88 msg_set_non_seq(msg, 1);
87 msg_set_node_sig(msg, tipc_random); 89 msg_set_node_sig(msg, tipc_random);
88 msg_set_dest_domain(msg, dest_domain); 90 msg_set_dest_domain(msg, dest_domain);
89 msg_set_bc_netid(msg, tipc_net_id); 91 msg_set_bc_netid(msg, tn->net_id);
90 b_ptr->media->addr2msg(msg_media_addr(msg), &b_ptr->addr); 92 b_ptr->media->addr2msg(msg_media_addr(msg), &b_ptr->addr);
91} 93}
92 94
@@ -111,11 +113,14 @@ static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr,
111 113
112/** 114/**
113 * tipc_disc_rcv - handle incoming discovery message (request or response) 115 * tipc_disc_rcv - handle incoming discovery message (request or response)
116 * @net: the applicable net namespace
114 * @buf: buffer containing message 117 * @buf: buffer containing message
115 * @bearer: bearer that message arrived on 118 * @bearer: bearer that message arrived on
116 */ 119 */
117void tipc_disc_rcv(struct sk_buff *buf, struct tipc_bearer *bearer) 120void tipc_disc_rcv(struct net *net, struct sk_buff *buf,
121 struct tipc_bearer *bearer)
118{ 122{
123 struct tipc_net *tn = net_generic(net, tipc_net_id);
119 struct tipc_node *node; 124 struct tipc_node *node;
120 struct tipc_link *link; 125 struct tipc_link *link;
121 struct tipc_media_addr maddr; 126 struct tipc_media_addr maddr;
@@ -137,7 +142,7 @@ void tipc_disc_rcv(struct sk_buff *buf, struct tipc_bearer *bearer)
137 kfree_skb(buf); 142 kfree_skb(buf);
138 143
139 /* Ensure message from node is valid and communication is permitted */ 144 /* Ensure message from node is valid and communication is permitted */
140 if (net_id != tipc_net_id) 145 if (net_id != tn->net_id)
141 return; 146 return;
142 if (maddr.broadcast) 147 if (maddr.broadcast)
143 return; 148 return;
@@ -248,7 +253,7 @@ void tipc_disc_rcv(struct sk_buff *buf, struct tipc_bearer *bearer)
248 if (respond && (mtyp == DSC_REQ_MSG)) { 253 if (respond && (mtyp == DSC_REQ_MSG)) {
249 rbuf = tipc_buf_acquire(INT_H_SIZE); 254 rbuf = tipc_buf_acquire(INT_H_SIZE);
250 if (rbuf) { 255 if (rbuf) {
251 tipc_disc_init_msg(rbuf, DSC_RESP_MSG, bearer); 256 tipc_disc_init_msg(net, rbuf, DSC_RESP_MSG, bearer);
252 tipc_bearer_send(bearer->identity, rbuf, &maddr); 257 tipc_bearer_send(bearer->identity, rbuf, &maddr);
253 kfree_skb(rbuf); 258 kfree_skb(rbuf);
254 } 259 }
@@ -341,13 +346,15 @@ exit:
341 346
342/** 347/**
343 * tipc_disc_create - create object to send periodic link setup requests 348 * tipc_disc_create - create object to send periodic link setup requests
349 * @net: the applicable net namespace
344 * @b_ptr: ptr to bearer issuing requests 350 * @b_ptr: ptr to bearer issuing requests
345 * @dest: destination address for request messages 351 * @dest: destination address for request messages
346 * @dest_domain: network domain to which links can be established 352 * @dest_domain: network domain to which links can be established
347 * 353 *
348 * Returns 0 if successful, otherwise -errno. 354 * Returns 0 if successful, otherwise -errno.
349 */ 355 */
350int tipc_disc_create(struct tipc_bearer *b_ptr, struct tipc_media_addr *dest) 356int tipc_disc_create(struct net *net, struct tipc_bearer *b_ptr,
357 struct tipc_media_addr *dest)
351{ 358{
352 struct tipc_link_req *req; 359 struct tipc_link_req *req;
353 360
@@ -361,7 +368,7 @@ int tipc_disc_create(struct tipc_bearer *b_ptr, struct tipc_media_addr *dest)
361 return -ENOMEM; 368 return -ENOMEM;
362 } 369 }
363 370
364 tipc_disc_init_msg(req->buf, DSC_REQ_MSG, b_ptr); 371 tipc_disc_init_msg(net, req->buf, DSC_REQ_MSG, b_ptr);
365 memcpy(&req->dest, dest, sizeof(*dest)); 372 memcpy(&req->dest, dest, sizeof(*dest));
366 req->bearer_id = b_ptr->identity; 373 req->bearer_id = b_ptr->identity;
367 req->domain = b_ptr->domain; 374 req->domain = b_ptr->domain;
@@ -388,15 +395,16 @@ void tipc_disc_delete(struct tipc_link_req *req)
388 395
389/** 396/**
390 * tipc_disc_reset - reset object to send periodic link setup requests 397 * tipc_disc_reset - reset object to send periodic link setup requests
398 * @net: the applicable net namespace
391 * @b_ptr: ptr to bearer issuing requests 399 * @b_ptr: ptr to bearer issuing requests
392 * @dest_domain: network domain to which links can be established 400 * @dest_domain: network domain to which links can be established
393 */ 401 */
394void tipc_disc_reset(struct tipc_bearer *b_ptr) 402void tipc_disc_reset(struct net *net, struct tipc_bearer *b_ptr)
395{ 403{
396 struct tipc_link_req *req = b_ptr->link_req; 404 struct tipc_link_req *req = b_ptr->link_req;
397 405
398 spin_lock_bh(&req->lock); 406 spin_lock_bh(&req->lock);
399 tipc_disc_init_msg(req->buf, DSC_REQ_MSG, b_ptr); 407 tipc_disc_init_msg(net, req->buf, DSC_REQ_MSG, b_ptr);
400 req->bearer_id = b_ptr->identity; 408 req->bearer_id = b_ptr->identity;
401 req->domain = b_ptr->domain; 409 req->domain = b_ptr->domain;
402 req->num_nodes = 0; 410 req->num_nodes = 0;