blob: b702c7bf580f8d9a2a780d2a24c6cc8c46a630bb [file] [log] [blame]
Per Lidenb97bf3f2006-01-02 19:04:38 +01001/*
2 * net/tipc/node.c: TIPC node management routines
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +09003 *
Per Liden593a5f22006-01-11 19:14:19 +01004 * Copyright (c) 2000-2006, Ericsson AB
Allan Stephensea138472006-06-29 12:33:20 -07005 * Copyright (c) 2005-2006, Wind River Systems
Per Lidenb97bf3f2006-01-02 19:04:38 +01006 * All rights reserved.
7 *
Per Liden9ea1fd32006-01-11 13:30:43 +01008 * Redistribution and use in source and binary forms, with or without
Per Lidenb97bf3f2006-01-02 19:04:38 +01009 * modification, are permitted provided that the following conditions are met:
10 *
Per Liden9ea1fd32006-01-11 13:30:43 +010011 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the names of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
Per Lidenb97bf3f2006-01-02 19:04:38 +010019 *
Per Liden9ea1fd32006-01-11 13:30:43 +010020 * Alternatively, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") version 2 as published by the Free
22 * Software Foundation.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Per Lidenb97bf3f2006-01-02 19:04:38 +010034 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#include "core.h"
38#include "config.h"
39#include "node.h"
40#include "cluster.h"
41#include "net.h"
42#include "addr.h"
43#include "node_subscr.h"
44#include "link.h"
45#include "port.h"
46#include "bearer.h"
47#include "name_distr.h"
Per Lidenb97bf3f2006-01-02 19:04:38 +010048
David S. Miller6c000552008-09-02 23:38:32 -070049void node_print(struct print_buf *buf, struct tipc_node *n_ptr, char *str);
50static void node_lost_contact(struct tipc_node *n_ptr);
51static void node_established_contact(struct tipc_node *n_ptr);
Per Lidenb97bf3f2006-01-02 19:04:38 +010052
David S. Miller6c000552008-09-02 23:38:32 -070053struct tipc_node *tipc_nodes = NULL; /* sorted list of nodes within cluster */
Per Lidenb97bf3f2006-01-02 19:04:38 +010054
Allan Stephens2ecb0922008-05-21 14:53:00 -070055static DEFINE_SPINLOCK(node_create_lock);
56
Per Lidenb97bf3f2006-01-02 19:04:38 +010057u32 tipc_own_tag = 0;
58
Allan Stephens2ecb0922008-05-21 14:53:00 -070059/**
60 * tipc_node_create - create neighboring node
61 *
62 * Currently, this routine is called by neighbor discovery code, which holds
63 * net_lock for reading only. We must take node_create_lock to ensure a node
64 * isn't created twice if two different bearers discover the node at the same
65 * time. (It would be preferable to switch to holding net_lock in write mode,
66 * but this is a non-trivial change.)
67 */
68
David S. Miller6c000552008-09-02 23:38:32 -070069struct tipc_node *tipc_node_create(u32 addr)
Per Lidenb97bf3f2006-01-02 19:04:38 +010070{
71 struct cluster *c_ptr;
David S. Miller6c000552008-09-02 23:38:32 -070072 struct tipc_node *n_ptr;
73 struct tipc_node **curr_node;
Per Lidenb97bf3f2006-01-02 19:04:38 +010074
Allan Stephens2ecb0922008-05-21 14:53:00 -070075 spin_lock_bh(&node_create_lock);
76
77 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
78 if (addr < n_ptr->addr)
79 break;
80 if (addr == n_ptr->addr) {
81 spin_unlock_bh(&node_create_lock);
82 return n_ptr;
83 }
84 }
85
Arnaldo Carvalho de Melo2710b572006-11-21 01:22:12 -020086 n_ptr = kzalloc(sizeof(*n_ptr),GFP_ATOMIC);
Allan Stephensa10bd922006-06-25 23:52:17 -070087 if (!n_ptr) {
Allan Stephens2ecb0922008-05-21 14:53:00 -070088 spin_unlock_bh(&node_create_lock);
Allan Stephensa10bd922006-06-25 23:52:17 -070089 warn("Node creation failed, no memory\n");
90 return NULL;
91 }
Per Lidenb97bf3f2006-01-02 19:04:38 +010092
Allan Stephensa10bd922006-06-25 23:52:17 -070093 c_ptr = tipc_cltr_find(addr);
94 if (!c_ptr) {
95 c_ptr = tipc_cltr_create(addr);
96 }
97 if (!c_ptr) {
Allan Stephens2ecb0922008-05-21 14:53:00 -070098 spin_unlock_bh(&node_create_lock);
Allan Stephensa10bd922006-06-25 23:52:17 -070099 kfree(n_ptr);
100 return NULL;
101 }
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900102
Allan Stephensa10bd922006-06-25 23:52:17 -0700103 n_ptr->addr = addr;
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900104 spin_lock_init(&n_ptr->lock);
Allan Stephensa10bd922006-06-25 23:52:17 -0700105 INIT_LIST_HEAD(&n_ptr->nsub);
106 n_ptr->owner = c_ptr;
107 tipc_cltr_attach_node(c_ptr, n_ptr);
108 n_ptr->last_router = -1;
109
110 /* Insert node into ordered list */
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900111 for (curr_node = &tipc_nodes; *curr_node;
Allan Stephensa10bd922006-06-25 23:52:17 -0700112 curr_node = &(*curr_node)->next) {
113 if (addr < (*curr_node)->addr) {
114 n_ptr->next = *curr_node;
115 break;
116 }
117 }
118 (*curr_node) = n_ptr;
Allan Stephens2ecb0922008-05-21 14:53:00 -0700119 spin_unlock_bh(&node_create_lock);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100120 return n_ptr;
121}
122
David S. Miller6c000552008-09-02 23:38:32 -0700123void tipc_node_delete(struct tipc_node *n_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100124{
125 if (!n_ptr)
126 return;
127
128#if 0
Per Liden4323add2006-01-18 00:38:21 +0100129 /* Not needed because links are already deleted via tipc_bearer_stop() */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100130
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);
139 kfree(n_ptr);
140}
141
142
143/**
Per Liden4323add2006-01-18 00:38:21 +0100144 * tipc_node_link_up - handle addition of link
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900145 *
Per Lidenb97bf3f2006-01-02 19:04:38 +0100146 * Link becomes active (alone or shared) or standby, depending on its priority.
147 */
148
David S. Miller6c000552008-09-02 23:38:32 -0700149void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100150{
151 struct link **active = &n_ptr->active_links[0];
152
Allan Stephens5392d642006-06-25 23:52:50 -0700153 n_ptr->working_links++;
154
Per Lidenb97bf3f2006-01-02 19:04:38 +0100155 info("Established link <%s> on network plane %c\n",
156 l_ptr->name, l_ptr->b_ptr->net_plane);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900157
Per Lidenb97bf3f2006-01-02 19:04:38 +0100158 if (!active[0]) {
159 dbg(" link %x into %x/%x\n", l_ptr, &active[0], &active[1]);
160 active[0] = active[1] = l_ptr;
161 node_established_contact(n_ptr);
162 return;
163 }
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900164 if (l_ptr->priority < active[0]->priority) {
Allan Stephensa10bd922006-06-25 23:52:17 -0700165 info("New link <%s> becomes standby\n", l_ptr->name);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100166 return;
167 }
Per Liden4323add2006-01-18 00:38:21 +0100168 tipc_link_send_duplicate(active[0], l_ptr);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900169 if (l_ptr->priority == active[0]->priority) {
Per Lidenb97bf3f2006-01-02 19:04:38 +0100170 active[0] = l_ptr;
171 return;
172 }
Allan Stephensa10bd922006-06-25 23:52:17 -0700173 info("Old link <%s> becomes standby\n", active[0]->name);
174 if (active[1] != active[0])
175 info("Old link <%s> becomes standby\n", active[1]->name);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100176 active[0] = active[1] = l_ptr;
177}
178
179/**
180 * node_select_active_links - select active link
181 */
182
David S. Miller6c000552008-09-02 23:38:32 -0700183static void node_select_active_links(struct tipc_node *n_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100184{
185 struct link **active = &n_ptr->active_links[0];
186 u32 i;
187 u32 highest_prio = 0;
188
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900189 active[0] = active[1] = NULL;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100190
191 for (i = 0; i < MAX_BEARERS; i++) {
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900192 struct link *l_ptr = n_ptr->links[i];
Per Lidenb97bf3f2006-01-02 19:04:38 +0100193
Per Liden4323add2006-01-18 00:38:21 +0100194 if (!l_ptr || !tipc_link_is_up(l_ptr) ||
Per Lidenb97bf3f2006-01-02 19:04:38 +0100195 (l_ptr->priority < highest_prio))
196 continue;
197
198 if (l_ptr->priority > highest_prio) {
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900199 highest_prio = l_ptr->priority;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100200 active[0] = active[1] = l_ptr;
201 } else {
202 active[1] = l_ptr;
203 }
204 }
205}
206
207/**
Per Liden4323add2006-01-18 00:38:21 +0100208 * tipc_node_link_down - handle loss of link
Per Lidenb97bf3f2006-01-02 19:04:38 +0100209 */
210
David S. Miller6c000552008-09-02 23:38:32 -0700211void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100212{
213 struct link **active;
214
Allan Stephens5392d642006-06-25 23:52:50 -0700215 n_ptr->working_links--;
216
Per Liden4323add2006-01-18 00:38:21 +0100217 if (!tipc_link_is_active(l_ptr)) {
Per Lidenb97bf3f2006-01-02 19:04:38 +0100218 info("Lost standby link <%s> on network plane %c\n",
219 l_ptr->name, l_ptr->b_ptr->net_plane);
220 return;
221 }
222 info("Lost link <%s> on network plane %c\n",
223 l_ptr->name, l_ptr->b_ptr->net_plane);
224
225 active = &n_ptr->active_links[0];
226 if (active[0] == l_ptr)
227 active[0] = active[1];
228 if (active[1] == l_ptr)
229 active[1] = active[0];
230 if (active[0] == l_ptr)
231 node_select_active_links(n_ptr);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900232 if (tipc_node_is_up(n_ptr))
Per Liden4323add2006-01-18 00:38:21 +0100233 tipc_link_changeover(l_ptr);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900234 else
Per Lidenb97bf3f2006-01-02 19:04:38 +0100235 node_lost_contact(n_ptr);
236}
237
David S. Miller6c000552008-09-02 23:38:32 -0700238int tipc_node_has_active_links(struct tipc_node *n_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100239{
Allan Stephens76ae0d72010-08-17 11:00:12 +0000240 return n_ptr->active_links[0] != NULL;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100241}
242
David S. Miller6c000552008-09-02 23:38:32 -0700243int tipc_node_has_redundant_links(struct tipc_node *n_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100244{
Allan Stephens5392d642006-06-25 23:52:50 -0700245 return (n_ptr->working_links > 1);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100246}
247
David S. Miller6c000552008-09-02 23:38:32 -0700248static int tipc_node_has_active_routes(struct tipc_node *n_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100249{
250 return (n_ptr && (n_ptr->last_router >= 0));
251}
252
David S. Miller6c000552008-09-02 23:38:32 -0700253int tipc_node_is_up(struct tipc_node *n_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100254{
Per Liden4323add2006-01-18 00:38:21 +0100255 return (tipc_node_has_active_links(n_ptr) || tipc_node_has_active_routes(n_ptr));
Per Lidenb97bf3f2006-01-02 19:04:38 +0100256}
257
David S. Miller6c000552008-09-02 23:38:32 -0700258struct tipc_node *tipc_node_attach_link(struct link *l_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100259{
David S. Miller6c000552008-09-02 23:38:32 -0700260 struct tipc_node *n_ptr = tipc_node_find(l_ptr->addr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100261
262 if (!n_ptr)
Per Liden4323add2006-01-18 00:38:21 +0100263 n_ptr = tipc_node_create(l_ptr->addr);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900264 if (n_ptr) {
Per Lidenb97bf3f2006-01-02 19:04:38 +0100265 u32 bearer_id = l_ptr->b_ptr->identity;
266 char addr_string[16];
267
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900268 if (n_ptr->link_cnt >= 2) {
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900269 err("Attempt to create third link to %s\n",
Allan Stephensc68ca7b2010-05-11 14:30:12 +0000270 tipc_addr_string_fill(addr_string, n_ptr->addr));
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900271 return NULL;
272 }
Per Lidenb97bf3f2006-01-02 19:04:38 +0100273
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900274 if (!n_ptr->links[bearer_id]) {
275 n_ptr->links[bearer_id] = l_ptr;
276 tipc_net.zones[tipc_zone(l_ptr->addr)]->links++;
277 n_ptr->link_cnt++;
278 return n_ptr;
279 }
Frans Popa570f092010-03-24 07:57:29 +0000280 err("Attempt to establish second link on <%s> to %s\n",
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900281 l_ptr->b_ptr->publ.name,
Allan Stephensc68ca7b2010-05-11 14:30:12 +0000282 tipc_addr_string_fill(addr_string, l_ptr->addr));
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900283 }
Sam Ravnborg1fc54d82006-03-20 22:36:47 -0800284 return NULL;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100285}
286
David S. Miller6c000552008-09-02 23:38:32 -0700287void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100288{
Sam Ravnborg1fc54d82006-03-20 22:36:47 -0800289 n_ptr->links[l_ptr->b_ptr->identity] = NULL;
Per Liden4323add2006-01-18 00:38:21 +0100290 tipc_net.zones[tipc_zone(l_ptr->addr)]->links--;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100291 n_ptr->link_cnt--;
292}
293
294/*
295 * Routing table management - five cases to handle:
296 *
297 * 1: A link towards a zone/cluster external node comes up.
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900298 * => Send a multicast message updating routing tables of all
299 * system nodes within own cluster that the new destination
300 * can be reached via this node.
Per Lidenb97bf3f2006-01-02 19:04:38 +0100301 * (node.establishedContact()=>cluster.multicastNewRoute())
302 *
303 * 2: A link towards a slave node comes up.
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900304 * => Send a multicast message updating routing tables of all
305 * system nodes within own cluster that the new destination
306 * can be reached via this node.
Per Lidenb97bf3f2006-01-02 19:04:38 +0100307 * (node.establishedContact()=>cluster.multicastNewRoute())
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900308 * => Send a message to the slave node about existence
Per Lidenb97bf3f2006-01-02 19:04:38 +0100309 * of all system nodes within cluster:
310 * (node.establishedContact()=>cluster.sendLocalRoutes())
311 *
312 * 3: A new cluster local system node becomes available.
313 * => Send message(s) to this particular node containing
314 * information about all cluster external and slave
315 * nodes which can be reached via this node.
316 * (node.establishedContact()==>network.sendExternalRoutes())
317 * (node.establishedContact()==>network.sendSlaveRoutes())
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900318 * => Send messages to all directly connected slave nodes
Per Lidenb97bf3f2006-01-02 19:04:38 +0100319 * containing information about the existence of the new node
320 * (node.establishedContact()=>cluster.multicastNewRoute())
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900321 *
Per Lidenb97bf3f2006-01-02 19:04:38 +0100322 * 4: The link towards a zone/cluster external node or slave
323 * node goes down.
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900324 * => Send a multcast message updating routing tables of all
Per Lidenb97bf3f2006-01-02 19:04:38 +0100325 * nodes within cluster that the new destination can not any
326 * longer be reached via this node.
327 * (node.lostAllLinks()=>cluster.bcastLostRoute())
328 *
329 * 5: A cluster local system node becomes unavailable.
330 * => Remove all references to this node from the local
331 * routing tables. Note: This is a completely node
332 * local operation.
333 * (node.lostAllLinks()=>network.removeAsRouter())
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900334 * => Send messages to all directly connected slave nodes
Per Lidenb97bf3f2006-01-02 19:04:38 +0100335 * containing information about loss of the node
336 * (node.establishedContact()=>cluster.multicastLostRoute())
337 *
338 */
339
David S. Miller6c000552008-09-02 23:38:32 -0700340static void node_established_contact(struct tipc_node *n_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100341{
342 struct cluster *c_ptr;
343
344 dbg("node_established_contact:-> %x\n", n_ptr->addr);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900345 if (!tipc_node_has_active_routes(n_ptr) && in_own_cluster(n_ptr->addr)) {
Per Liden4323add2006-01-18 00:38:21 +0100346 tipc_k_signal((Handler)tipc_named_node_up, n_ptr->addr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100347 }
348
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900349 /* Syncronize broadcast acks */
350 n_ptr->bclink.acked = tipc_bclink_get_last_sent();
Per Lidenb97bf3f2006-01-02 19:04:38 +0100351
352 if (is_slave(tipc_own_addr))
353 return;
354 if (!in_own_cluster(n_ptr->addr)) {
355 /* Usage case 1 (see above) */
Per Liden4323add2006-01-18 00:38:21 +0100356 c_ptr = tipc_cltr_find(tipc_own_addr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100357 if (!c_ptr)
Per Liden4323add2006-01-18 00:38:21 +0100358 c_ptr = tipc_cltr_create(tipc_own_addr);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900359 if (c_ptr)
360 tipc_cltr_bcast_new_route(c_ptr, n_ptr->addr, 1,
Per Liden4323add2006-01-18 00:38:21 +0100361 tipc_max_nodes);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100362 return;
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900363 }
Per Lidenb97bf3f2006-01-02 19:04:38 +0100364
365 c_ptr = n_ptr->owner;
366 if (is_slave(n_ptr->addr)) {
367 /* Usage case 2 (see above) */
Per Liden4323add2006-01-18 00:38:21 +0100368 tipc_cltr_bcast_new_route(c_ptr, n_ptr->addr, 1, tipc_max_nodes);
369 tipc_cltr_send_local_routes(c_ptr, n_ptr->addr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100370 return;
371 }
372
373 if (n_ptr->bclink.supported) {
Per Liden4323add2006-01-18 00:38:21 +0100374 tipc_nmap_add(&tipc_cltr_bcast_nodes, n_ptr->addr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100375 if (n_ptr->addr < tipc_own_addr)
376 tipc_own_tag++;
377 }
378
379 /* Case 3 (see above) */
Per Liden4323add2006-01-18 00:38:21 +0100380 tipc_net_send_external_routes(n_ptr->addr);
381 tipc_cltr_send_slave_routes(c_ptr, n_ptr->addr);
382 tipc_cltr_bcast_new_route(c_ptr, n_ptr->addr, LOWEST_SLAVE,
383 tipc_highest_allowed_slave);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100384}
385
Allan Stephens5a68d5e2010-08-17 11:00:16 +0000386static void node_cleanup_finished(unsigned long node_addr)
387{
388 struct tipc_node *n_ptr;
389
390 read_lock_bh(&tipc_net_lock);
391 n_ptr = tipc_node_find(node_addr);
392 if (n_ptr) {
393 tipc_node_lock(n_ptr);
394 n_ptr->cleanup_required = 0;
395 tipc_node_unlock(n_ptr);
396 }
397 read_unlock_bh(&tipc_net_lock);
398}
399
David S. Miller6c000552008-09-02 23:38:32 -0700400static void node_lost_contact(struct tipc_node *n_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100401{
402 struct cluster *c_ptr;
David S. Miller6c000552008-09-02 23:38:32 -0700403 struct tipc_node_subscr *ns, *tns;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100404 char addr_string[16];
405 u32 i;
406
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900407 /* Clean up broadcast reception remains */
408 n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = 0;
409 while (n_ptr->bclink.deferred_head) {
410 struct sk_buff* buf = n_ptr->bclink.deferred_head;
411 n_ptr->bclink.deferred_head = buf->next;
412 buf_discard(buf);
413 }
414 if (n_ptr->bclink.defragm) {
415 buf_discard(n_ptr->bclink.defragm);
416 n_ptr->bclink.defragm = NULL;
417 }
418 if (in_own_cluster(n_ptr->addr) && n_ptr->bclink.supported) {
419 tipc_bclink_acknowledge(n_ptr, mod(n_ptr->bclink.acked + 10000));
420 }
Per Lidenb97bf3f2006-01-02 19:04:38 +0100421
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900422 /* Update routing tables */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100423 if (is_slave(tipc_own_addr)) {
Per Liden4323add2006-01-18 00:38:21 +0100424 tipc_net_remove_as_router(n_ptr->addr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100425 } else {
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900426 if (!in_own_cluster(n_ptr->addr)) {
Per Lidenb97bf3f2006-01-02 19:04:38 +0100427 /* Case 4 (see above) */
Per Liden4323add2006-01-18 00:38:21 +0100428 c_ptr = tipc_cltr_find(tipc_own_addr);
429 tipc_cltr_bcast_lost_route(c_ptr, n_ptr->addr, 1,
430 tipc_max_nodes);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100431 } else {
432 /* Case 5 (see above) */
Per Liden4323add2006-01-18 00:38:21 +0100433 c_ptr = tipc_cltr_find(n_ptr->addr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100434 if (is_slave(n_ptr->addr)) {
Per Liden4323add2006-01-18 00:38:21 +0100435 tipc_cltr_bcast_lost_route(c_ptr, n_ptr->addr, 1,
436 tipc_max_nodes);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100437 } else {
438 if (n_ptr->bclink.supported) {
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900439 tipc_nmap_remove(&tipc_cltr_bcast_nodes,
Per Liden4323add2006-01-18 00:38:21 +0100440 n_ptr->addr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100441 if (n_ptr->addr < tipc_own_addr)
442 tipc_own_tag--;
443 }
Per Liden4323add2006-01-18 00:38:21 +0100444 tipc_net_remove_as_router(n_ptr->addr);
445 tipc_cltr_bcast_lost_route(c_ptr, n_ptr->addr,
446 LOWEST_SLAVE,
447 tipc_highest_allowed_slave);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100448 }
449 }
450 }
Per Liden4323add2006-01-18 00:38:21 +0100451 if (tipc_node_has_active_routes(n_ptr))
Per Lidenb97bf3f2006-01-02 19:04:38 +0100452 return;
453
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900454 info("Lost contact with %s\n",
Allan Stephensc68ca7b2010-05-11 14:30:12 +0000455 tipc_addr_string_fill(addr_string, n_ptr->addr));
Per Lidenb97bf3f2006-01-02 19:04:38 +0100456
457 /* Abort link changeover */
458 for (i = 0; i < MAX_BEARERS; i++) {
459 struct link *l_ptr = n_ptr->links[i];
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900460 if (!l_ptr)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100461 continue;
462 l_ptr->reset_checkpoint = l_ptr->next_in_no;
463 l_ptr->exp_msg_count = 0;
Per Liden4323add2006-01-18 00:38:21 +0100464 tipc_link_reset_fragments(l_ptr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100465 }
466
467 /* Notify subscribers */
468 list_for_each_entry_safe(ns, tns, &n_ptr->nsub, nodesub_list) {
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900469 ns->node = NULL;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100470 list_del_init(&ns->nodesub_list);
Per Liden4323add2006-01-18 00:38:21 +0100471 tipc_k_signal((Handler)ns->handle_node_down,
472 (unsigned long)ns->usr_handle);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100473 }
Allan Stephens5a68d5e2010-08-17 11:00:16 +0000474
475 /* Prevent re-contact with node until all cleanup is done */
476
477 n_ptr->cleanup_required = 1;
478 tipc_k_signal((Handler)node_cleanup_finished, n_ptr->addr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100479}
480
481/**
Per Liden4323add2006-01-18 00:38:21 +0100482 * tipc_node_select_next_hop - find the next-hop node for a message
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900483 *
Per Lidenb97bf3f2006-01-02 19:04:38 +0100484 * Called by when cluster local lookup has failed.
485 */
486
David S. Miller6c000552008-09-02 23:38:32 -0700487struct tipc_node *tipc_node_select_next_hop(u32 addr, u32 selector)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100488{
David S. Miller6c000552008-09-02 23:38:32 -0700489 struct tipc_node *n_ptr;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100490 u32 router_addr;
491
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900492 if (!tipc_addr_domain_valid(addr))
493 return NULL;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100494
495 /* Look for direct link to destination processsor */
Per Liden4323add2006-01-18 00:38:21 +0100496 n_ptr = tipc_node_find(addr);
497 if (n_ptr && tipc_node_has_active_links(n_ptr))
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900498 return n_ptr;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100499
500 /* Cluster local system nodes *must* have direct links */
501 if (!is_slave(addr) && in_own_cluster(addr))
Sam Ravnborg1fc54d82006-03-20 22:36:47 -0800502 return NULL;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100503
504 /* Look for cluster local router with direct link to node */
Per Liden4323add2006-01-18 00:38:21 +0100505 router_addr = tipc_node_select_router(n_ptr, selector);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900506 if (router_addr)
507 return tipc_node_select(router_addr, selector);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100508
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900509 /* Slave nodes can only be accessed within own cluster via a
Per Lidenb97bf3f2006-01-02 19:04:38 +0100510 known router with direct link -- if no router was found,give up */
511 if (is_slave(addr))
Sam Ravnborg1fc54d82006-03-20 22:36:47 -0800512 return NULL;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100513
514 /* Inter zone/cluster -- find any direct link to remote cluster */
515 addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0);
Per Liden4323add2006-01-18 00:38:21 +0100516 n_ptr = tipc_net_select_remote_node(addr, selector);
517 if (n_ptr && tipc_node_has_active_links(n_ptr))
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900518 return n_ptr;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100519
520 /* Last resort -- look for any router to anywhere in remote zone */
Per Liden4323add2006-01-18 00:38:21 +0100521 router_addr = tipc_net_select_router(addr, selector);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900522 if (router_addr)
523 return tipc_node_select(router_addr, selector);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100524
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900525 return NULL;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100526}
527
528/**
Per Liden4323add2006-01-18 00:38:21 +0100529 * tipc_node_select_router - select router to reach specified node
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900530 *
531 * Uses a deterministic and fair algorithm for selecting router node.
Per Lidenb97bf3f2006-01-02 19:04:38 +0100532 */
533
David S. Miller6c000552008-09-02 23:38:32 -0700534u32 tipc_node_select_router(struct tipc_node *n_ptr, u32 ref)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100535{
536 u32 ulim;
537 u32 mask;
538 u32 start;
539 u32 r;
540
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900541 if (!n_ptr)
542 return 0;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100543
544 if (n_ptr->last_router < 0)
545 return 0;
546 ulim = ((n_ptr->last_router + 1) * 32) - 1;
547
548 /* Start entry must be random */
549 mask = tipc_max_nodes;
550 while (mask > ulim)
551 mask >>= 1;
552 start = ref & mask;
553 r = start;
554
555 /* Lookup upwards with wrap-around */
556 do {
557 if (((n_ptr->routers[r / 32]) >> (r % 32)) & 1)
558 break;
559 } while (++r <= ulim);
560 if (r > ulim) {
561 r = 1;
562 do {
563 if (((n_ptr->routers[r / 32]) >> (r % 32)) & 1)
564 break;
565 } while (++r < start);
566 assert(r != start);
567 }
568 assert(r && (r <= ulim));
569 return tipc_addr(own_zone(), own_cluster(), r);
570}
571
David S. Miller6c000552008-09-02 23:38:32 -0700572void tipc_node_add_router(struct tipc_node *n_ptr, u32 router)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100573{
574 u32 r_num = tipc_node(router);
575
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900576 n_ptr->routers[r_num / 32] =
Per Lidenb97bf3f2006-01-02 19:04:38 +0100577 ((1 << (r_num % 32)) | n_ptr->routers[r_num / 32]);
578 n_ptr->last_router = tipc_max_nodes / 32;
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900579 while ((--n_ptr->last_router >= 0) &&
Per Lidenb97bf3f2006-01-02 19:04:38 +0100580 !n_ptr->routers[n_ptr->last_router]);
581}
582
David S. Miller6c000552008-09-02 23:38:32 -0700583void tipc_node_remove_router(struct tipc_node *n_ptr, u32 router)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100584{
585 u32 r_num = tipc_node(router);
586
587 if (n_ptr->last_router < 0)
588 return; /* No routes */
589
590 n_ptr->routers[r_num / 32] =
591 ((~(1 << (r_num % 32))) & (n_ptr->routers[r_num / 32]));
592 n_ptr->last_router = tipc_max_nodes / 32;
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900593 while ((--n_ptr->last_router >= 0) &&
Per Lidenb97bf3f2006-01-02 19:04:38 +0100594 !n_ptr->routers[n_ptr->last_router]);
595
Per Liden4323add2006-01-18 00:38:21 +0100596 if (!tipc_node_is_up(n_ptr))
Per Lidenb97bf3f2006-01-02 19:04:38 +0100597 node_lost_contact(n_ptr);
598}
599
600#if 0
David S. Miller6c000552008-09-02 23:38:32 -0700601void node_print(struct print_buf *buf, struct tipc_node *n_ptr, char *str)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100602{
603 u32 i;
604
605 tipc_printf(buf, "\n\n%s", str);
606 for (i = 0; i < MAX_BEARERS; i++) {
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900607 if (!n_ptr->links[i])
Per Lidenb97bf3f2006-01-02 19:04:38 +0100608 continue;
609 tipc_printf(buf, "Links[%u]: %x, ", i, n_ptr->links[i]);
610 }
611 tipc_printf(buf, "Active links: [%x,%x]\n",
612 n_ptr->active_links[0], n_ptr->active_links[1]);
613}
614#endif
615
616u32 tipc_available_nodes(const u32 domain)
617{
David S. Miller6c000552008-09-02 23:38:32 -0700618 struct tipc_node *n_ptr;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100619 u32 cnt = 0;
620
Allan Stephens1aad72d2008-07-14 22:44:58 -0700621 read_lock_bh(&tipc_net_lock);
Per Liden4323add2006-01-18 00:38:21 +0100622 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
Allan Stephensc68ca7b2010-05-11 14:30:12 +0000623 if (!tipc_in_scope(domain, n_ptr->addr))
Per Lidenb97bf3f2006-01-02 19:04:38 +0100624 continue;
Per Liden4323add2006-01-18 00:38:21 +0100625 if (tipc_node_is_up(n_ptr))
Per Lidenb97bf3f2006-01-02 19:04:38 +0100626 cnt++;
627 }
Allan Stephens1aad72d2008-07-14 22:44:58 -0700628 read_unlock_bh(&tipc_net_lock);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100629 return cnt;
630}
631
Per Liden4323add2006-01-18 00:38:21 +0100632struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100633{
634 u32 domain;
635 struct sk_buff *buf;
David S. Miller6c000552008-09-02 23:38:32 -0700636 struct tipc_node *n_ptr;
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900637 struct tipc_node_info node_info;
Allan Stephensea138472006-06-29 12:33:20 -0700638 u32 payload_size;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100639
640 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
Per Liden4323add2006-01-18 00:38:21 +0100641 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100642
Al Viro3e6c8cd2006-11-08 00:19:09 -0800643 domain = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
Per Liden4323add2006-01-18 00:38:21 +0100644 if (!tipc_addr_domain_valid(domain))
645 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
646 " (network address)");
Per Lidenb97bf3f2006-01-02 19:04:38 +0100647
Allan Stephens1aad72d2008-07-14 22:44:58 -0700648 read_lock_bh(&tipc_net_lock);
649 if (!tipc_nodes) {
650 read_unlock_bh(&tipc_net_lock);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900651 return tipc_cfg_reply_none();
Allan Stephens1aad72d2008-07-14 22:44:58 -0700652 }
Per Lidenb97bf3f2006-01-02 19:04:38 +0100653
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900654 /* For now, get space for all other nodes
Per Lidenb97bf3f2006-01-02 19:04:38 +0100655 (will need to modify this when slave nodes are supported */
656
Allan Stephensea138472006-06-29 12:33:20 -0700657 payload_size = TLV_SPACE(sizeof(node_info)) * (tipc_max_nodes - 1);
Allan Stephens1aad72d2008-07-14 22:44:58 -0700658 if (payload_size > 32768u) {
659 read_unlock_bh(&tipc_net_lock);
Allan Stephensea138472006-06-29 12:33:20 -0700660 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
661 " (too many nodes)");
Allan Stephens1aad72d2008-07-14 22:44:58 -0700662 }
Allan Stephensea138472006-06-29 12:33:20 -0700663 buf = tipc_cfg_reply_alloc(payload_size);
Allan Stephens1aad72d2008-07-14 22:44:58 -0700664 if (!buf) {
665 read_unlock_bh(&tipc_net_lock);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100666 return NULL;
Allan Stephens1aad72d2008-07-14 22:44:58 -0700667 }
Per Lidenb97bf3f2006-01-02 19:04:38 +0100668
669 /* Add TLVs for all nodes in scope */
670
Per Liden4323add2006-01-18 00:38:21 +0100671 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
Allan Stephensc68ca7b2010-05-11 14:30:12 +0000672 if (!tipc_in_scope(domain, n_ptr->addr))
Per Lidenb97bf3f2006-01-02 19:04:38 +0100673 continue;
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900674 node_info.addr = htonl(n_ptr->addr);
675 node_info.up = htonl(tipc_node_is_up(n_ptr));
676 tipc_cfg_append_tlv(buf, TIPC_TLV_NODE_INFO,
Per Liden4323add2006-01-18 00:38:21 +0100677 &node_info, sizeof(node_info));
Per Lidenb97bf3f2006-01-02 19:04:38 +0100678 }
679
Allan Stephens1aad72d2008-07-14 22:44:58 -0700680 read_unlock_bh(&tipc_net_lock);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100681 return buf;
682}
683
Per Liden4323add2006-01-18 00:38:21 +0100684struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
Per Lidenb97bf3f2006-01-02 19:04:38 +0100685{
686 u32 domain;
687 struct sk_buff *buf;
David S. Miller6c000552008-09-02 23:38:32 -0700688 struct tipc_node *n_ptr;
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900689 struct tipc_link_info link_info;
Allan Stephensea138472006-06-29 12:33:20 -0700690 u32 payload_size;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100691
692 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
Per Liden4323add2006-01-18 00:38:21 +0100693 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100694
Al Viro3e6c8cd2006-11-08 00:19:09 -0800695 domain = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
Per Liden4323add2006-01-18 00:38:21 +0100696 if (!tipc_addr_domain_valid(domain))
697 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
698 " (network address)");
Per Lidenb97bf3f2006-01-02 19:04:38 +0100699
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900700 if (tipc_mode != TIPC_NET_MODE)
701 return tipc_cfg_reply_none();
702
Allan Stephens1aad72d2008-07-14 22:44:58 -0700703 read_lock_bh(&tipc_net_lock);
704
Allan Stephensea138472006-06-29 12:33:20 -0700705 /* Get space for all unicast links + multicast link */
Per Lidenb97bf3f2006-01-02 19:04:38 +0100706
Allan Stephensea138472006-06-29 12:33:20 -0700707 payload_size = TLV_SPACE(sizeof(link_info)) *
708 (tipc_net.zones[tipc_zone(tipc_own_addr)]->links + 1);
Allan Stephens1aad72d2008-07-14 22:44:58 -0700709 if (payload_size > 32768u) {
710 read_unlock_bh(&tipc_net_lock);
Allan Stephensea138472006-06-29 12:33:20 -0700711 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
712 " (too many links)");
Allan Stephens1aad72d2008-07-14 22:44:58 -0700713 }
Allan Stephensea138472006-06-29 12:33:20 -0700714 buf = tipc_cfg_reply_alloc(payload_size);
Allan Stephens1aad72d2008-07-14 22:44:58 -0700715 if (!buf) {
716 read_unlock_bh(&tipc_net_lock);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100717 return NULL;
Allan Stephens1aad72d2008-07-14 22:44:58 -0700718 }
Per Lidenb97bf3f2006-01-02 19:04:38 +0100719
720 /* Add TLV for broadcast link */
721
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900722 link_info.dest = htonl(tipc_own_addr & 0xfffff00);
723 link_info.up = htonl(1);
Stephen Hemminger4b704d52009-03-18 19:11:29 -0700724 strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME);
Per Liden4323add2006-01-18 00:38:21 +0100725 tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info));
Per Lidenb97bf3f2006-01-02 19:04:38 +0100726
727 /* Add TLVs for any other links in scope */
728
Per Liden4323add2006-01-18 00:38:21 +0100729 for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900730 u32 i;
Per Lidenb97bf3f2006-01-02 19:04:38 +0100731
Allan Stephensc68ca7b2010-05-11 14:30:12 +0000732 if (!tipc_in_scope(domain, n_ptr->addr))
Per Lidenb97bf3f2006-01-02 19:04:38 +0100733 continue;
Allan Stephens1aad72d2008-07-14 22:44:58 -0700734 tipc_node_lock(n_ptr);
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900735 for (i = 0; i < MAX_BEARERS; i++) {
736 if (!n_ptr->links[i])
737 continue;
738 link_info.dest = htonl(n_ptr->addr);
739 link_info.up = htonl(tipc_link_is_up(n_ptr->links[i]));
740 strcpy(link_info.str, n_ptr->links[i]->name);
741 tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO,
Per Liden4323add2006-01-18 00:38:21 +0100742 &link_info, sizeof(link_info));
YOSHIFUJI Hideakic4307282007-02-09 23:25:21 +0900743 }
Allan Stephens1aad72d2008-07-14 22:44:58 -0700744 tipc_node_unlock(n_ptr);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100745 }
746
Allan Stephens1aad72d2008-07-14 22:44:58 -0700747 read_unlock_bh(&tipc_net_lock);
Per Lidenb97bf3f2006-01-02 19:04:38 +0100748 return buf;
749}