aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/node.c')
-rw-r--r--net/tipc/node.c73
1 files changed, 25 insertions, 48 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c
index b634942caba5..b4d87eb2dc5d 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -50,7 +50,8 @@ void node_print(struct print_buf *buf, struct tipc_node *n_ptr, char *str);
50static void node_lost_contact(struct tipc_node *n_ptr); 50static void node_lost_contact(struct tipc_node *n_ptr);
51static void node_established_contact(struct tipc_node *n_ptr); 51static void node_established_contact(struct tipc_node *n_ptr);
52 52
53struct tipc_node *tipc_nodes = NULL; /* sorted list of nodes within cluster */ 53/* sorted list of nodes within cluster */
54static struct tipc_node *tipc_nodes = NULL;
54 55
55static DEFINE_SPINLOCK(node_create_lock); 56static DEFINE_SPINLOCK(node_create_lock);
56 57
@@ -125,16 +126,6 @@ void tipc_node_delete(struct tipc_node *n_ptr)
125 if (!n_ptr) 126 if (!n_ptr)
126 return; 127 return;
127 128
128#if 0
129 /* Not needed because links are already deleted via tipc_bearer_stop() */
130
131 u32 l_num;
132
133 for (l_num = 0; l_num < MAX_BEARERS; l_num++) {
134 link_delete(n_ptr->links[l_num]);
135 }
136#endif
137
138 dbg("node %x deleted\n", n_ptr->addr); 129 dbg("node %x deleted\n", n_ptr->addr);
139 kfree(n_ptr); 130 kfree(n_ptr);
140} 131}
@@ -237,23 +228,22 @@ void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr)
237 228
238int tipc_node_has_active_links(struct tipc_node *n_ptr) 229int tipc_node_has_active_links(struct tipc_node *n_ptr)
239{ 230{
240 return (n_ptr && 231 return n_ptr->active_links[0] != NULL;
241 ((n_ptr->active_links[0]) || (n_ptr->active_links[1])));
242} 232}
243 233
244int tipc_node_has_redundant_links(struct tipc_node *n_ptr) 234int tipc_node_has_redundant_links(struct tipc_node *n_ptr)
245{ 235{
246 return (n_ptr->working_links > 1); 236 return n_ptr->working_links > 1;
247} 237}
248 238
249static int tipc_node_has_active_routes(struct tipc_node *n_ptr) 239static int tipc_node_has_active_routes(struct tipc_node *n_ptr)
250{ 240{
251 return (n_ptr && (n_ptr->last_router >= 0)); 241 return n_ptr && (n_ptr->last_router >= 0);
252} 242}
253 243
254int tipc_node_is_up(struct tipc_node *n_ptr) 244int tipc_node_is_up(struct tipc_node *n_ptr)
255{ 245{
256 return (tipc_node_has_active_links(n_ptr) || tipc_node_has_active_routes(n_ptr)); 246 return tipc_node_has_active_links(n_ptr) || tipc_node_has_active_routes(n_ptr);
257} 247}
258 248
259struct tipc_node *tipc_node_attach_link(struct link *l_ptr) 249struct tipc_node *tipc_node_attach_link(struct link *l_ptr)
@@ -384,6 +374,20 @@ static void node_established_contact(struct tipc_node *n_ptr)
384 tipc_highest_allowed_slave); 374 tipc_highest_allowed_slave);
385} 375}
386 376
377static void node_cleanup_finished(unsigned long node_addr)
378{
379 struct tipc_node *n_ptr;
380
381 read_lock_bh(&tipc_net_lock);
382 n_ptr = tipc_node_find(node_addr);
383 if (n_ptr) {
384 tipc_node_lock(n_ptr);
385 n_ptr->cleanup_required = 0;
386 tipc_node_unlock(n_ptr);
387 }
388 read_unlock_bh(&tipc_net_lock);
389}
390
387static void node_lost_contact(struct tipc_node *n_ptr) 391static void node_lost_contact(struct tipc_node *n_ptr)
388{ 392{
389 struct cluster *c_ptr; 393 struct cluster *c_ptr;
@@ -458,6 +462,11 @@ static void node_lost_contact(struct tipc_node *n_ptr)
458 tipc_k_signal((Handler)ns->handle_node_down, 462 tipc_k_signal((Handler)ns->handle_node_down,
459 (unsigned long)ns->usr_handle); 463 (unsigned long)ns->usr_handle);
460 } 464 }
465
466 /* Prevent re-contact with node until all cleanup is done */
467
468 n_ptr->cleanup_required = 1;
469 tipc_k_signal((Handler)node_cleanup_finished, n_ptr->addr);
461} 470}
462 471
463/** 472/**
@@ -579,38 +588,6 @@ void tipc_node_remove_router(struct tipc_node *n_ptr, u32 router)
579 node_lost_contact(n_ptr); 588 node_lost_contact(n_ptr);
580} 589}
581 590
582#if 0
583void node_print(struct print_buf *buf, struct tipc_node *n_ptr, char *str)
584{
585 u32 i;
586
587 tipc_printf(buf, "\n\n%s", str);
588 for (i = 0; i < MAX_BEARERS; i++) {
589 if (!n_ptr->links[i])
590 continue;
591 tipc_printf(buf, "Links[%u]: %x, ", i, n_ptr->links[i]);
592 }
593 tipc_printf(buf, "Active links: [%x,%x]\n",
594 n_ptr->active_links[0], n_ptr->active_links[1]);
595}
596#endif
597
598u32 tipc_available_nodes(const u32 domain)
599{
600 struct tipc_node *n_ptr;
601 u32 cnt = 0;
602
603 read_lock_bh(&tipc_net_lock);
604 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
605 if (!tipc_in_scope(domain, n_ptr->addr))
606 continue;
607 if (tipc_node_is_up(n_ptr))
608 cnt++;
609 }
610 read_unlock_bh(&tipc_net_lock);
611 return cnt;
612}
613
614struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) 591struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
615{ 592{
616 u32 domain; 593 u32 domain;