aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
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
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')
-rw-r--r--net/tipc/discover.c2
-rw-r--r--net/tipc/link.c27
-rw-r--r--net/tipc/link.h3
-rw-r--r--net/tipc/node.c30
-rw-r--r--net/tipc/node.h2
5 files changed, 28 insertions, 36 deletions
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 580b50a79e43..caac5c93b7f7 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -169,7 +169,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
169 169
170 /* Create a link endpoint for this bearer, if necessary */ 170 /* Create a link endpoint for this bearer, if necessary */
171 if (!link) { 171 if (!link) {
172 link = tipc_link_create(b_ptr, orig, &media_addr); 172 link = tipc_link_create(n_ptr, b_ptr, &media_addr);
173 if (!link) { 173 if (!link) {
174 tipc_node_unlock(n_ptr); 174 tipc_node_unlock(n_ptr);
175 return; 175 return;
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);
diff --git a/net/tipc/link.h b/net/tipc/link.h
index a7794e7ede29..e6a30dbe1aaa 100644
--- a/net/tipc/link.h
+++ b/net/tipc/link.h
@@ -207,7 +207,8 @@ struct link {
207 207
208struct tipc_port; 208struct tipc_port;
209 209
210struct link *tipc_link_create(struct tipc_bearer *b_ptr, const u32 peer, 210struct link *tipc_link_create(struct tipc_node *n_ptr,
211 struct tipc_bearer *b_ptr,
211 const struct tipc_media_addr *media_addr); 212 const struct tipc_media_addr *media_addr);
212void tipc_link_delete(struct link *l_ptr); 213void tipc_link_delete(struct link *l_ptr);
213void tipc_link_changeover(struct link *l_ptr); 214void tipc_link_changeover(struct link *l_ptr);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index ca09b33fb87f..2d106ef4fa4c 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -238,33 +238,11 @@ int tipc_node_is_up(struct tipc_node *n_ptr)
238 return tipc_node_active_links(n_ptr); 238 return tipc_node_active_links(n_ptr);
239} 239}
240 240
241struct tipc_node *tipc_node_attach_link(struct link *l_ptr) 241void tipc_node_attach_link(struct tipc_node *n_ptr, struct link *l_ptr)
242{ 242{
243 struct tipc_node *n_ptr = tipc_node_find(l_ptr->addr); 243 n_ptr->links[l_ptr->b_ptr->identity] = l_ptr;
244 244 atomic_inc(&tipc_num_links);
245 if (!n_ptr) 245 n_ptr->link_cnt++;
246 n_ptr = tipc_node_create(l_ptr->addr);
247 if (n_ptr) {
248 u32 bearer_id = l_ptr->b_ptr->identity;
249 char addr_string[16];
250
251 if (n_ptr->link_cnt >= 2) {
252 err("Attempt to create third link to %s\n",
253 tipc_addr_string_fill(addr_string, n_ptr->addr));
254 return NULL;
255 }
256
257 if (!n_ptr->links[bearer_id]) {
258 n_ptr->links[bearer_id] = l_ptr;
259 atomic_inc(&tipc_num_links);
260 n_ptr->link_cnt++;
261 return n_ptr;
262 }
263 err("Attempt to establish second link on <%s> to %s\n",
264 l_ptr->b_ptr->name,
265 tipc_addr_string_fill(addr_string, l_ptr->addr));
266 }
267 return NULL;
268} 246}
269 247
270void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr) 248void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr)
diff --git a/net/tipc/node.h b/net/tipc/node.h
index dde316576f81..5c61afc7a0b9 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -111,7 +111,7 @@ extern u32 tipc_own_tag;
111struct tipc_node *tipc_node_find(u32 addr); 111struct tipc_node *tipc_node_find(u32 addr);
112struct tipc_node *tipc_node_create(u32 addr); 112struct tipc_node *tipc_node_create(u32 addr);
113void tipc_node_delete(struct tipc_node *n_ptr); 113void tipc_node_delete(struct tipc_node *n_ptr);
114struct tipc_node *tipc_node_attach_link(struct link *l_ptr); 114void tipc_node_attach_link(struct tipc_node *n_ptr, struct link *l_ptr);
115void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr); 115void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr);
116void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr); 116void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr);
117void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr); 117void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr);