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.c68
1 files changed, 36 insertions, 32 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c
index b54462bd98d7..5f097547d3e3 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -61,34 +61,37 @@ struct node *tipc_node_create(u32 addr)
61 struct node **curr_node; 61 struct node **curr_node;
62 62
63 n_ptr = kmalloc(sizeof(*n_ptr),GFP_ATOMIC); 63 n_ptr = kmalloc(sizeof(*n_ptr),GFP_ATOMIC);
64 if (n_ptr != NULL) { 64 if (!n_ptr) {
65 memset(n_ptr, 0, sizeof(*n_ptr)); 65 warn("Node creation failed, no memory\n");
66 n_ptr->addr = addr; 66 return NULL;
67 n_ptr->lock = SPIN_LOCK_UNLOCKED; 67 }
68 INIT_LIST_HEAD(&n_ptr->nsub); 68
69 69 c_ptr = tipc_cltr_find(addr);
70 c_ptr = tipc_cltr_find(addr); 70 if (!c_ptr) {
71 if (c_ptr == NULL) 71 c_ptr = tipc_cltr_create(addr);
72 c_ptr = tipc_cltr_create(addr); 72 }
73 if (c_ptr != NULL) { 73 if (!c_ptr) {
74 n_ptr->owner = c_ptr; 74 kfree(n_ptr);
75 tipc_cltr_attach_node(c_ptr, n_ptr); 75 return NULL;
76 n_ptr->last_router = -1; 76 }
77 77
78 /* Insert node into ordered list */ 78 memset(n_ptr, 0, sizeof(*n_ptr));
79 for (curr_node = &tipc_nodes; *curr_node; 79 n_ptr->addr = addr;
80 curr_node = &(*curr_node)->next) { 80 n_ptr->lock = SPIN_LOCK_UNLOCKED;
81 if (addr < (*curr_node)->addr) { 81 INIT_LIST_HEAD(&n_ptr->nsub);
82 n_ptr->next = *curr_node; 82 n_ptr->owner = c_ptr;
83 break; 83 tipc_cltr_attach_node(c_ptr, n_ptr);
84 } 84 n_ptr->last_router = -1;
85 } 85
86 (*curr_node) = n_ptr; 86 /* Insert node into ordered list */
87 } else { 87 for (curr_node = &tipc_nodes; *curr_node;
88 kfree(n_ptr); 88 curr_node = &(*curr_node)->next) {
89 n_ptr = NULL; 89 if (addr < (*curr_node)->addr) {
90 } 90 n_ptr->next = *curr_node;
91 } 91 break;
92 }
93 }
94 (*curr_node) = n_ptr;
92 return n_ptr; 95 return n_ptr;
93} 96}
94 97
@@ -132,7 +135,7 @@ void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr)
132 return; 135 return;
133 } 136 }
134 if (l_ptr->priority < active[0]->priority) { 137 if (l_ptr->priority < active[0]->priority) {
135 info("Link is standby\n"); 138 info("New link <%s> becomes standby\n", l_ptr->name);
136 return; 139 return;
137 } 140 }
138 tipc_link_send_duplicate(active[0], l_ptr); 141 tipc_link_send_duplicate(active[0], l_ptr);
@@ -140,8 +143,9 @@ void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr)
140 active[0] = l_ptr; 143 active[0] = l_ptr;
141 return; 144 return;
142 } 145 }
143 info("Link <%s> on network plane %c becomes standby\n", 146 info("Old link <%s> becomes standby\n", active[0]->name);
144 active[0]->name, active[0]->b_ptr->net_plane); 147 if (active[1] != active[0])
148 info("Old link <%s> becomes standby\n", active[1]->name);
145 active[0] = active[1] = l_ptr; 149 active[0] = active[1] = l_ptr;
146} 150}
147 151
@@ -248,7 +252,7 @@ struct node *tipc_node_attach_link(struct link *l_ptr)
248 n_ptr->link_cnt++; 252 n_ptr->link_cnt++;
249 return n_ptr; 253 return n_ptr;
250 } 254 }
251 err("Attempt to establish second link on <%s> to <%s> \n", 255 err("Attempt to establish second link on <%s> to %s \n",
252 l_ptr->b_ptr->publ.name, 256 l_ptr->b_ptr->publ.name,
253 addr_string_fill(addr_string, l_ptr->addr)); 257 addr_string_fill(addr_string, l_ptr->addr));
254 } 258 }