aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
authorAllan Stephens <Allan.Stephens@windriver.com>2011-02-28 11:32:27 -0500
committerPaul Gortmaker <paul.gortmaker@windriver.com>2011-03-13 16:35:18 -0400
commit37b9c08a88f9a82456bb11fa050cccb544e8dc60 (patch)
tree6e90ee920265bfd5e56a9919f1bc7667ab6aa182 /net/tipc/link.c
parentfa2bae2d5bede252445cc457737d00f9036c41c3 (diff)
tipc: Optimizations to link creation code
Enhances link creation code as follows: 1) Detects illegal attempts to add a requested link earlier in the link creation process. This prevents TIPC from wasting time initializing a link object it then throws away, and also eliminates the code needed to do the throwing away. 2) Passes in the node object associated with the requested link. This allows TIPC to eliminate a search to locate the node object, as well as code that attempted to create the node if it doesn't exist. Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r--net/tipc/link.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index e5f96d5ef1ad..b73adeb5cdee 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -293,19 +293,35 @@ static void link_set_timer(struct link *l_ptr, u32 time)
293 293
294/** 294/**
295 * tipc_link_create - create a new link 295 * tipc_link_create - create a new link
296 * @n_ptr: pointer to associated node
296 * @b_ptr: pointer to associated bearer 297 * @b_ptr: pointer to associated bearer
297 * @peer: network address of node at other end of link
298 * @media_addr: media address to use when sending messages over link 298 * @media_addr: media address to use when sending messages over link
299 * 299 *
300 * Returns pointer to link. 300 * Returns pointer to link.
301 */ 301 */
302 302
303struct link *tipc_link_create(struct tipc_bearer *b_ptr, const u32 peer, 303struct link *tipc_link_create(struct tipc_node *n_ptr,
304 struct tipc_bearer *b_ptr,
304 const struct tipc_media_addr *media_addr) 305 const struct tipc_media_addr *media_addr)
305{ 306{
306 struct link *l_ptr; 307 struct link *l_ptr;
307 struct tipc_msg *msg; 308 struct tipc_msg *msg;
308 char *if_name; 309 char *if_name;
310 char addr_string[16];
311 u32 peer = n_ptr->addr;
312
313 if (n_ptr->link_cnt >= 2) {
314 tipc_addr_string_fill(addr_string, n_ptr->addr);
315 err("Attempt to establish third link to %s\n", addr_string);
316 return NULL;
317 }
318
319 if (n_ptr->links[b_ptr->identity]) {
320 tipc_addr_string_fill(addr_string, n_ptr->addr);
321 err("Attempt to establish second link on <%s> to %s\n",
322 b_ptr->name, addr_string);
323 return NULL;
324 }
309 325
310 l_ptr = kzalloc(sizeof(*l_ptr), GFP_ATOMIC); 326 l_ptr = kzalloc(sizeof(*l_ptr), GFP_ATOMIC);
311 if (!l_ptr) { 327 if (!l_ptr) {
@@ -322,6 +338,7 @@ struct link *tipc_link_create(struct tipc_bearer *b_ptr, const u32 peer,
322 tipc_zone(peer), tipc_cluster(peer), tipc_node(peer)); 338 tipc_zone(peer), tipc_cluster(peer), tipc_node(peer));
323 /* note: peer i/f is appended to link name by reset/activate */ 339 /* note: peer i/f is appended to link name by reset/activate */
324 memcpy(&l_ptr->media_addr, media_addr, sizeof(*media_addr)); 340 memcpy(&l_ptr->media_addr, media_addr, sizeof(*media_addr));
341 l_ptr->owner = n_ptr;
325 l_ptr->checkpoint = 1; 342 l_ptr->checkpoint = 1;
326 l_ptr->b_ptr = b_ptr; 343 l_ptr->b_ptr = b_ptr;
327 link_set_supervision_props(l_ptr, b_ptr->media->tolerance); 344 link_set_supervision_props(l_ptr, b_ptr->media->tolerance);
@@ -345,11 +362,7 @@ struct link *tipc_link_create(struct tipc_bearer *b_ptr, const u32 peer,
345 362
346 link_reset_statistics(l_ptr); 363 link_reset_statistics(l_ptr);
347 364
348 l_ptr->owner = tipc_node_attach_link(l_ptr); 365 tipc_node_attach_link(n_ptr, l_ptr);
349 if (!l_ptr->owner) {
350 kfree(l_ptr);
351 return NULL;
352 }
353 366
354 k_init_timer(&l_ptr->timer, (Handler)link_timeout, (unsigned long)l_ptr); 367 k_init_timer(&l_ptr->timer, (Handler)link_timeout, (unsigned long)l_ptr);
355 list_add_tail(&l_ptr->link_list, &b_ptr->links); 368 list_add_tail(&l_ptr->link_list, &b_ptr->links);