aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/discover.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/discover.c')
-rw-r--r--net/tipc/discover.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index ecc758c6eacf..412ff41b8611 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -50,6 +50,7 @@
50 * @dest: destination address for request messages 50 * @dest: destination address for request messages
51 * @domain: network domain to which links can be established 51 * @domain: network domain to which links can be established
52 * @num_nodes: number of nodes currently discovered (i.e. with an active link) 52 * @num_nodes: number of nodes currently discovered (i.e. with an active link)
53 * @lock: spinlock for controlling access to requests
53 * @buf: request message to be (repeatedly) sent 54 * @buf: request message to be (repeatedly) sent
54 * @timer: timer governing period between requests 55 * @timer: timer governing period between requests
55 * @timer_intv: current interval between requests (in ms) 56 * @timer_intv: current interval between requests (in ms)
@@ -59,6 +60,7 @@ struct tipc_link_req {
59 struct tipc_media_addr dest; 60 struct tipc_media_addr dest;
60 u32 domain; 61 u32 domain;
61 int num_nodes; 62 int num_nodes;
63 spinlock_t lock;
62 struct sk_buff *buf; 64 struct sk_buff *buf;
63 struct timer_list timer; 65 struct timer_list timer;
64 unsigned int timer_intv; 66 unsigned int timer_intv;
@@ -239,7 +241,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
239 /* Accept discovery message & send response, if necessary */ 241 /* Accept discovery message & send response, if necessary */
240 link_fully_up = link_working_working(link); 242 link_fully_up = link_working_working(link);
241 243
242 if ((type == DSC_REQ_MSG) && !link_fully_up && !b_ptr->blocked) { 244 if ((type == DSC_REQ_MSG) && !link_fully_up) {
243 rbuf = tipc_disc_init_msg(DSC_RESP_MSG, orig, b_ptr); 245 rbuf = tipc_disc_init_msg(DSC_RESP_MSG, orig, b_ptr);
244 if (rbuf) { 246 if (rbuf) {
245 tipc_bearer_send(b_ptr, rbuf, &media_addr); 247 tipc_bearer_send(b_ptr, rbuf, &media_addr);
@@ -274,7 +276,9 @@ static void disc_update(struct tipc_link_req *req)
274 */ 276 */
275void tipc_disc_add_dest(struct tipc_link_req *req) 277void tipc_disc_add_dest(struct tipc_link_req *req)
276{ 278{
279 spin_lock_bh(&req->lock);
277 req->num_nodes++; 280 req->num_nodes++;
281 spin_unlock_bh(&req->lock);
278} 282}
279 283
280/** 284/**
@@ -283,18 +287,10 @@ void tipc_disc_add_dest(struct tipc_link_req *req)
283 */ 287 */
284void tipc_disc_remove_dest(struct tipc_link_req *req) 288void tipc_disc_remove_dest(struct tipc_link_req *req)
285{ 289{
290 spin_lock_bh(&req->lock);
286 req->num_nodes--; 291 req->num_nodes--;
287 disc_update(req); 292 disc_update(req);
288} 293 spin_unlock_bh(&req->lock);
289
290/**
291 * disc_send_msg - send link setup request message
292 * @req: ptr to link request structure
293 */
294static void disc_send_msg(struct tipc_link_req *req)
295{
296 if (!req->bearer->blocked)
297 tipc_bearer_send(req->bearer, req->buf, &req->dest);
298} 294}
299 295
300/** 296/**
@@ -307,7 +303,7 @@ static void disc_timeout(struct tipc_link_req *req)
307{ 303{
308 int max_delay; 304 int max_delay;
309 305
310 spin_lock_bh(&req->bearer->lock); 306 spin_lock_bh(&req->lock);
311 307
312 /* Stop searching if only desired node has been found */ 308 /* Stop searching if only desired node has been found */
313 if (tipc_node(req->domain) && req->num_nodes) { 309 if (tipc_node(req->domain) && req->num_nodes) {
@@ -322,7 +318,8 @@ static void disc_timeout(struct tipc_link_req *req)
322 * hold at fast polling rate if don't have any associated nodes, 318 * hold at fast polling rate if don't have any associated nodes,
323 * otherwise hold at slow polling rate 319 * otherwise hold at slow polling rate
324 */ 320 */
325 disc_send_msg(req); 321 tipc_bearer_send(req->bearer, req->buf, &req->dest);
322
326 323
327 req->timer_intv *= 2; 324 req->timer_intv *= 2;
328 if (req->num_nodes) 325 if (req->num_nodes)
@@ -334,7 +331,7 @@ static void disc_timeout(struct tipc_link_req *req)
334 331
335 k_start_timer(&req->timer, req->timer_intv); 332 k_start_timer(&req->timer, req->timer_intv);
336exit: 333exit:
337 spin_unlock_bh(&req->bearer->lock); 334 spin_unlock_bh(&req->lock);
338} 335}
339 336
340/** 337/**
@@ -365,10 +362,11 @@ int tipc_disc_create(struct tipc_bearer *b_ptr, struct tipc_media_addr *dest,
365 req->domain = dest_domain; 362 req->domain = dest_domain;
366 req->num_nodes = 0; 363 req->num_nodes = 0;
367 req->timer_intv = TIPC_LINK_REQ_INIT; 364 req->timer_intv = TIPC_LINK_REQ_INIT;
365 spin_lock_init(&req->lock);
368 k_init_timer(&req->timer, (Handler)disc_timeout, (unsigned long)req); 366 k_init_timer(&req->timer, (Handler)disc_timeout, (unsigned long)req);
369 k_start_timer(&req->timer, req->timer_intv); 367 k_start_timer(&req->timer, req->timer_intv);
370 b_ptr->link_req = req; 368 b_ptr->link_req = req;
371 disc_send_msg(req); 369 tipc_bearer_send(req->bearer, req->buf, &req->dest);
372 return 0; 370 return 0;
373} 371}
374 372