summaryrefslogtreecommitdiff
path: root/net/tipc/node.c
diff options
context:
space:
mode:
authorAllan Stephens <Allan.Stephens@windriver.com>2011-02-24 21:20:20 +0300
committerPaul Gortmaker <paul.gortmaker@windriver.com>2011-03-13 23:35:16 +0300
commit9df3b7eb6ec1c7734482f782bf8335a2737c02f0 (patch)
treee54c8857773a3e54c213dd4f825b48fdd7ab295e /net/tipc/node.c
parent71092ea122062012f8e4b7fb2f9a747212d1479c (diff)
downloadlinux-9df3b7eb6ec1c7734482f782bf8335a2737c02f0.tar.xz
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/node.c')
-rw-r--r--net/tipc/node.c7
1 files changed, 4 insertions, 3 deletions
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)
if (!n_ptr->links[bearer_id]) {
n_ptr->links[bearer_id] = l_ptr;
- tipc_net.links++;
+ atomic_inc(&tipc_net.links);
n_ptr->link_cnt++;
return n_ptr;
}
@@ -247,7 +247,7 @@ struct tipc_node *tipc_node_attach_link(struct link *l_ptr)
void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr)
{
n_ptr->links[l_ptr->b_ptr->identity] = NULL;
- tipc_net.links--;
+ atomic_dec(&tipc_net.links);
n_ptr->link_cnt--;
}
@@ -450,7 +450,8 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
/* Get space for all unicast links + multicast link */
- payload_size = TLV_SPACE(sizeof(link_info)) * (tipc_net.links + 1);
+ payload_size = TLV_SPACE(sizeof(link_info)) *
+ (atomic_read(&tipc_net.links) + 1);
if (payload_size > 32768u) {
read_unlock_bh(&tipc_net_lock);
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED