diff options
author | Allan Stephens <Allan.Stephens@windriver.com> | 2011-02-24 13:20:20 -0500 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-03-13 16:35:16 -0400 |
commit | 9df3b7eb6ec1c7734482f782bf8335a2737c02f0 (patch) | |
tree | e54c8857773a3e54c213dd4f825b48fdd7ab295e /net/tipc | |
parent | 71092ea122062012f8e4b7fb2f9a747212d1479c (diff) |
tipc: Fix problem with missing link in "tipc-config -l" output
Removes a race condition that could cause TIPC's internal counter
of the number of links it has to neighboring nodes to have the
incorrect value if two independent threads of control simultaneously
create new link endpoints connecting to two different nodes using two
different bearers. Such under counting would result in TIPC failing to
list the final link(s) in its response to a configuration request to
list all of the node's links. The counter is now updated atomically
to ensure that simultaneous increments do not interfere with each
other.
Thanks go to Peter Butler <pbutler@pt.com> for his assistance in
diagnosing and fixing this problem.
Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/net.c | 3 | ||||
-rw-r--r-- | net/tipc/net.h | 4 | ||||
-rw-r--r-- | net/tipc/node.c | 7 |
3 files changed, 8 insertions, 6 deletions
diff --git a/net/tipc/net.c b/net/tipc/net.c index 9bacfd00b91e..dd78d869829f 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/net.c: TIPC network routing code | 2 | * net/tipc/net.c: TIPC network routing code |
3 | * | 3 | * |
4 | * Copyright (c) 1995-2006, Ericsson AB | 4 | * Copyright (c) 1995-2006, Ericsson AB |
5 | * Copyright (c) 2005, Wind River Systems | 5 | * Copyright (c) 2005, 2010-2011, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -115,6 +115,7 @@ static int net_start(void) | |||
115 | tipc_net.nodes = kcalloc(tipc_max_nodes + 1, | 115 | tipc_net.nodes = kcalloc(tipc_max_nodes + 1, |
116 | sizeof(*tipc_net.nodes), GFP_ATOMIC); | 116 | sizeof(*tipc_net.nodes), GFP_ATOMIC); |
117 | tipc_net.highest_node = 0; | 117 | tipc_net.highest_node = 0; |
118 | atomic_set(&tipc_net.links, 0); | ||
118 | 119 | ||
119 | return tipc_net.nodes ? 0 : -ENOMEM; | 120 | return tipc_net.nodes ? 0 : -ENOMEM; |
120 | } | 121 | } |
diff --git a/net/tipc/net.h b/net/tipc/net.h index 4ae59ad04893..aa431ef8b7bf 100644 --- a/net/tipc/net.h +++ b/net/tipc/net.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/net.h: Include file for TIPC network routing code | 2 | * net/tipc/net.h: Include file for TIPC network routing code |
3 | * | 3 | * |
4 | * Copyright (c) 1995-2006, Ericsson AB | 4 | * Copyright (c) 1995-2006, Ericsson AB |
5 | * Copyright (c) 2005, Wind River Systems | 5 | * Copyright (c) 2005, 2010-2011, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -49,7 +49,7 @@ struct tipc_node; | |||
49 | struct network { | 49 | struct network { |
50 | struct tipc_node **nodes; | 50 | struct tipc_node **nodes; |
51 | u32 highest_node; | 51 | u32 highest_node; |
52 | u32 links; | 52 | atomic_t links; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | 55 | ||
diff --git a/net/tipc/node.c b/net/tipc/node.c index 713ab5d7c54f..a24fad32345e 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -233,7 +233,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr) | |||
233 | 233 | ||
234 | if (!n_ptr->links[bearer_id]) { | 234 | if (!n_ptr->links[bearer_id]) { |
235 | n_ptr->links[bearer_id] = l_ptr; | 235 | n_ptr->links[bearer_id] = l_ptr; |
236 | tipc_net.links++; | 236 | atomic_inc(&tipc_net.links); |
237 | n_ptr->link_cnt++; | 237 | n_ptr->link_cnt++; |
238 | return n_ptr; | 238 | return n_ptr; |
239 | } | 239 | } |
@@ -247,7 +247,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr) | |||
247 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr) | 247 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr) |
248 | { | 248 | { |
249 | n_ptr->links[l_ptr->b_ptr->identity] = NULL; | 249 | n_ptr->links[l_ptr->b_ptr->identity] = NULL; |
250 | tipc_net.links--; | 250 | atomic_dec(&tipc_net.links); |
251 | n_ptr->link_cnt--; | 251 | n_ptr->link_cnt--; |
252 | } | 252 | } |
253 | 253 | ||
@@ -450,7 +450,8 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
450 | 450 | ||
451 | /* Get space for all unicast links + multicast link */ | 451 | /* Get space for all unicast links + multicast link */ |
452 | 452 | ||
453 | payload_size = TLV_SPACE(sizeof(link_info)) * (tipc_net.links + 1); | 453 | payload_size = TLV_SPACE(sizeof(link_info)) * |
454 | (atomic_read(&tipc_net.links) + 1); | ||
454 | if (payload_size > 32768u) { | 455 | if (payload_size > 32768u) { |
455 | read_unlock_bh(&tipc_net_lock); | 456 | read_unlock_bh(&tipc_net_lock); |
456 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 457 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |