[TIPC] License header update
[pandora-kernel.git] / net / tipc / node.c
1 /*
2  * net/tipc/node.c: TIPC node management routines
3  * 
4  * Copyright (c) 2003-2005, Ericsson Research Canada
5  * Copyright (c) 2005, Wind River Systems
6  * Copyright (c) 2005-2006, Ericsson AB
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. Neither the names of the copyright holders nor the names of its
18  *    contributors may be used to endorse or promote products derived from
19  *    this software without specific prior written permission.
20  *
21  * Alternatively, this software may be distributed under the terms of the
22  * GNU General Public License ("GPL") version 2 as published by the Free
23  * Software Foundation.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  */
37
38 #include "core.h"
39 #include "config.h"
40 #include "node.h"
41 #include "cluster.h"
42 #include "net.h"
43 #include "addr.h"
44 #include "node_subscr.h"
45 #include "link.h"
46 #include "port.h"
47 #include "bearer.h"
48 #include "name_distr.h"
49 #include "net.h"
50
51 void node_print(struct print_buf *buf, struct node *n_ptr, char *str);
52 static void node_lost_contact(struct node *n_ptr);
53 static void node_established_contact(struct node *n_ptr);
54
55 struct node *nodes = NULL;      /* sorted list of nodes within cluster */
56
57 u32 tipc_own_tag = 0;
58
59 struct node *node_create(u32 addr)
60 {
61         struct cluster *c_ptr;
62         struct node *n_ptr;
63         struct node **curr_node;
64
65         n_ptr = kmalloc(sizeof(*n_ptr),GFP_ATOMIC);
66         if (n_ptr != NULL) {
67                 memset(n_ptr, 0, sizeof(*n_ptr));
68                 n_ptr->addr = addr;
69                 n_ptr->lock =  SPIN_LOCK_UNLOCKED;      
70                 INIT_LIST_HEAD(&n_ptr->nsub);
71         
72                 c_ptr = cluster_find(addr);
73                 if (c_ptr == NULL)
74                         c_ptr = cluster_create(addr);
75                 if (c_ptr != NULL) {
76                         n_ptr->owner = c_ptr;
77                         cluster_attach_node(c_ptr, n_ptr);
78                         n_ptr->last_router = -1;
79
80                         /* Insert node into ordered list */
81                         for (curr_node = &nodes; *curr_node; 
82                              curr_node = &(*curr_node)->next) {
83                                 if (addr < (*curr_node)->addr) {
84                                         n_ptr->next = *curr_node;
85                                         break;
86                                 }
87                         }
88                         (*curr_node) = n_ptr;
89                 } else {
90                         kfree(n_ptr);
91                         n_ptr = NULL;
92                 }
93         }
94         return n_ptr;
95 }
96
97 void node_delete(struct node *n_ptr)
98 {
99         if (!n_ptr)
100                 return;
101
102 #if 0
103         /* Not needed because links are already deleted via bearer_stop() */
104
105         u32 l_num;
106
107         for (l_num = 0; l_num < MAX_BEARERS; l_num++) {
108                 link_delete(n_ptr->links[l_num]);
109         }
110 #endif
111
112         dbg("node %x deleted\n", n_ptr->addr);
113         kfree(n_ptr);
114 }
115
116
117 /**
118  * node_link_up - handle addition of link
119  * 
120  * Link becomes active (alone or shared) or standby, depending on its priority.
121  */
122
123 void node_link_up(struct node *n_ptr, struct link *l_ptr)
124 {
125         struct link **active = &n_ptr->active_links[0];
126
127         info("Established link <%s> on network plane %c\n",
128              l_ptr->name, l_ptr->b_ptr->net_plane);
129         
130         if (!active[0]) {
131                 dbg(" link %x into %x/%x\n", l_ptr, &active[0], &active[1]);
132                 active[0] = active[1] = l_ptr;
133                 node_established_contact(n_ptr);
134                 return;
135         }
136         if (l_ptr->priority < active[0]->priority) { 
137                 info("Link is standby\n");
138                 return;
139         }
140         link_send_duplicate(active[0], l_ptr);
141         if (l_ptr->priority == active[0]->priority) { 
142                 active[0] = l_ptr;
143                 return;
144         }
145         info("Link <%s> on network plane %c becomes standby\n",
146              active[0]->name, active[0]->b_ptr->net_plane);
147         active[0] = active[1] = l_ptr;
148 }
149
150 /**
151  * node_select_active_links - select active link
152  */
153
154 static void node_select_active_links(struct node *n_ptr)
155 {
156         struct link **active = &n_ptr->active_links[0];
157         u32 i;
158         u32 highest_prio = 0;
159
160         active[0] = active[1] = 0;
161
162         for (i = 0; i < MAX_BEARERS; i++) {
163                 struct link *l_ptr = n_ptr->links[i];
164
165                 if (!l_ptr || !link_is_up(l_ptr) ||
166                     (l_ptr->priority < highest_prio))
167                         continue;
168
169                 if (l_ptr->priority > highest_prio) {
170                         highest_prio = l_ptr->priority;
171                         active[0] = active[1] = l_ptr;
172                 } else {
173                         active[1] = l_ptr;
174                 }
175         }
176 }
177
178 /**
179  * node_link_down - handle loss of link
180  */
181
182 void node_link_down(struct node *n_ptr, struct link *l_ptr)
183 {
184         struct link **active;
185
186         if (!link_is_active(l_ptr)) {
187                 info("Lost standby link <%s> on network plane %c\n",
188                      l_ptr->name, l_ptr->b_ptr->net_plane);
189                 return;
190         }
191         info("Lost link <%s> on network plane %c\n",
192                 l_ptr->name, l_ptr->b_ptr->net_plane);
193
194         active = &n_ptr->active_links[0];
195         if (active[0] == l_ptr)
196                 active[0] = active[1];
197         if (active[1] == l_ptr)
198                 active[1] = active[0];
199         if (active[0] == l_ptr)
200                 node_select_active_links(n_ptr);
201         if (node_is_up(n_ptr)) 
202                 link_changeover(l_ptr);
203         else 
204                 node_lost_contact(n_ptr);
205 }
206
207 int node_has_active_links(struct node *n_ptr)
208 {
209         return (n_ptr && 
210                 ((n_ptr->active_links[0]) || (n_ptr->active_links[1])));
211 }
212
213 int node_has_redundant_links(struct node *n_ptr)
214 {
215         return (node_has_active_links(n_ptr) &&
216                 (n_ptr->active_links[0] != n_ptr->active_links[1]));
217 }
218
219 int node_has_active_routes(struct node *n_ptr)
220 {
221         return (n_ptr && (n_ptr->last_router >= 0));
222 }
223
224 int node_is_up(struct node *n_ptr)
225 {
226         return (node_has_active_links(n_ptr) || node_has_active_routes(n_ptr));
227 }
228
229 struct node *node_attach_link(struct link *l_ptr)
230 {
231         struct node *n_ptr = node_find(l_ptr->addr);
232
233         if (!n_ptr)
234                 n_ptr = node_create(l_ptr->addr);
235         if (n_ptr) {
236                 u32 bearer_id = l_ptr->b_ptr->identity;
237                 char addr_string[16];
238
239                 assert(bearer_id < MAX_BEARERS);
240                 if (n_ptr->link_cnt >= 2) {
241                         char addr_string[16];
242
243                         err("Attempt to create third link to %s\n",
244                             addr_string_fill(addr_string, n_ptr->addr));
245                         return 0;
246                 }
247
248                 if (!n_ptr->links[bearer_id]) {
249                         n_ptr->links[bearer_id] = l_ptr;
250                         net.zones[tipc_zone(l_ptr->addr)]->links++;
251                         n_ptr->link_cnt++;
252                         return n_ptr;
253                 }
254                 err("Attempt to establish second link on <%s> to <%s> \n",
255                     l_ptr->b_ptr->publ.name, 
256                     addr_string_fill(addr_string, l_ptr->addr));
257         }
258         return 0;
259 }
260
261 void node_detach_link(struct node *n_ptr, struct link *l_ptr)
262 {
263         n_ptr->links[l_ptr->b_ptr->identity] = 0;
264         net.zones[tipc_zone(l_ptr->addr)]->links--;
265         n_ptr->link_cnt--;
266 }
267
268 /*
269  * Routing table management - five cases to handle:
270  *
271  * 1: A link towards a zone/cluster external node comes up.
272  *    => Send a multicast message updating routing tables of all 
273  *    system nodes within own cluster that the new destination 
274  *    can be reached via this node. 
275  *    (node.establishedContact()=>cluster.multicastNewRoute())
276  *
277  * 2: A link towards a slave node comes up.
278  *    => Send a multicast message updating routing tables of all 
279  *    system nodes within own cluster that the new destination 
280  *    can be reached via this node. 
281  *    (node.establishedContact()=>cluster.multicastNewRoute())
282  *    => Send a  message to the slave node about existence 
283  *    of all system nodes within cluster:
284  *    (node.establishedContact()=>cluster.sendLocalRoutes())
285  *
286  * 3: A new cluster local system node becomes available.
287  *    => Send message(s) to this particular node containing
288  *    information about all cluster external and slave
289  *     nodes which can be reached via this node.
290  *    (node.establishedContact()==>network.sendExternalRoutes())
291  *    (node.establishedContact()==>network.sendSlaveRoutes())
292  *    => Send messages to all directly connected slave nodes 
293  *    containing information about the existence of the new node
294  *    (node.establishedContact()=>cluster.multicastNewRoute())
295  *    
296  * 4: The link towards a zone/cluster external node or slave
297  *    node goes down.
298  *    => Send a multcast message updating routing tables of all 
299  *    nodes within cluster that the new destination can not any
300  *    longer be reached via this node.
301  *    (node.lostAllLinks()=>cluster.bcastLostRoute())
302  *
303  * 5: A cluster local system node becomes unavailable.
304  *    => Remove all references to this node from the local
305  *    routing tables. Note: This is a completely node
306  *    local operation.
307  *    (node.lostAllLinks()=>network.removeAsRouter())
308  *    => Send messages to all directly connected slave nodes 
309  *    containing information about loss of the node
310  *    (node.establishedContact()=>cluster.multicastLostRoute())
311  *
312  */
313
314 static void node_established_contact(struct node *n_ptr)
315 {
316         struct cluster *c_ptr;
317
318         dbg("node_established_contact:-> %x\n", n_ptr->addr);
319         if (!node_has_active_routes(n_ptr)) { 
320                 k_signal((Handler)named_node_up, n_ptr->addr);
321         }
322
323         /* Syncronize broadcast acks */
324         n_ptr->bclink.acked = bclink_get_last_sent();
325
326         if (is_slave(tipc_own_addr))
327                 return;
328         if (!in_own_cluster(n_ptr->addr)) {
329                 /* Usage case 1 (see above) */
330                 c_ptr = cluster_find(tipc_own_addr);
331                 if (!c_ptr)
332                         c_ptr = cluster_create(tipc_own_addr);
333                 if (c_ptr)
334                         cluster_bcast_new_route(c_ptr, n_ptr->addr, 1, 
335                                                 tipc_max_nodes);
336                 return;
337         } 
338
339         c_ptr = n_ptr->owner;
340         if (is_slave(n_ptr->addr)) {
341                 /* Usage case 2 (see above) */
342                 cluster_bcast_new_route(c_ptr, n_ptr->addr, 1, tipc_max_nodes);
343                 cluster_send_local_routes(c_ptr, n_ptr->addr);
344                 return;
345         }
346
347         if (n_ptr->bclink.supported) {
348                 nmap_add(&cluster_bcast_nodes, n_ptr->addr);
349                 if (n_ptr->addr < tipc_own_addr)
350                         tipc_own_tag++;
351         }
352
353         /* Case 3 (see above) */
354         net_send_external_routes(n_ptr->addr);
355         cluster_send_slave_routes(c_ptr, n_ptr->addr);
356         cluster_bcast_new_route(c_ptr, n_ptr->addr, LOWEST_SLAVE,
357                                 highest_allowed_slave);
358 }
359
360 static void node_lost_contact(struct node *n_ptr)
361 {
362         struct cluster *c_ptr;
363         struct node_subscr *ns, *tns;
364         char addr_string[16];
365         u32 i;
366
367         /* Clean up broadcast reception remains */
368         n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = 0;
369         while (n_ptr->bclink.deferred_head) {
370                 struct sk_buff* buf = n_ptr->bclink.deferred_head;
371                 n_ptr->bclink.deferred_head = buf->next;
372                 buf_discard(buf);
373         }
374         if (n_ptr->bclink.defragm) {
375                 buf_discard(n_ptr->bclink.defragm);  
376                 n_ptr->bclink.defragm = NULL;
377         }            
378         if (in_own_cluster(n_ptr->addr) && n_ptr->bclink.supported) { 
379                 bclink_acknowledge(n_ptr, mod(n_ptr->bclink.acked + 10000));
380         }
381
382         /* Update routing tables */
383         if (is_slave(tipc_own_addr)) {
384                 net_remove_as_router(n_ptr->addr);
385         } else {
386                 if (!in_own_cluster(n_ptr->addr)) { 
387                         /* Case 4 (see above) */
388                         c_ptr = cluster_find(tipc_own_addr);
389                         cluster_bcast_lost_route(c_ptr, n_ptr->addr, 1,
390                                                  tipc_max_nodes);
391                 } else {
392                         /* Case 5 (see above) */
393                         c_ptr = cluster_find(n_ptr->addr);
394                         if (is_slave(n_ptr->addr)) {
395                                 cluster_bcast_lost_route(c_ptr, n_ptr->addr, 1,
396                                                          tipc_max_nodes);
397                         } else {
398                                 if (n_ptr->bclink.supported) {
399                                         nmap_remove(&cluster_bcast_nodes, 
400                                                     n_ptr->addr);
401                                         if (n_ptr->addr < tipc_own_addr)
402                                                 tipc_own_tag--;
403                                 }
404                                 net_remove_as_router(n_ptr->addr);
405                                 cluster_bcast_lost_route(c_ptr, n_ptr->addr,
406                                                          LOWEST_SLAVE,
407                                                          highest_allowed_slave);
408                         }
409                 }
410         }
411         if (node_has_active_routes(n_ptr))
412                 return;
413
414         info("Lost contact with %s\n", 
415              addr_string_fill(addr_string, n_ptr->addr));
416
417         /* Abort link changeover */
418         for (i = 0; i < MAX_BEARERS; i++) {
419                 struct link *l_ptr = n_ptr->links[i];
420                 if (!l_ptr) 
421                         continue;
422                 l_ptr->reset_checkpoint = l_ptr->next_in_no;
423                 l_ptr->exp_msg_count = 0;
424                 link_reset_fragments(l_ptr);
425         }
426
427         /* Notify subscribers */
428         list_for_each_entry_safe(ns, tns, &n_ptr->nsub, nodesub_list) {
429                 ns->node = 0;
430                 list_del_init(&ns->nodesub_list);
431                 k_signal((Handler)ns->handle_node_down,
432                          (unsigned long)ns->usr_handle);
433         }
434 }
435
436 /**
437  * node_select_next_hop - find the next-hop node for a message
438  * 
439  * Called by when cluster local lookup has failed.
440  */
441
442 struct node *node_select_next_hop(u32 addr, u32 selector)
443 {
444         struct node *n_ptr;
445         u32 router_addr;
446
447         if (!addr_domain_valid(addr))
448                 return 0;
449
450         /* Look for direct link to destination processsor */
451         n_ptr = node_find(addr);
452         if (n_ptr && node_has_active_links(n_ptr))
453                 return n_ptr;
454
455         /* Cluster local system nodes *must* have direct links */
456         if (!is_slave(addr) && in_own_cluster(addr))
457                 return 0;
458
459         /* Look for cluster local router with direct link to node */
460         router_addr = node_select_router(n_ptr, selector);
461         if (router_addr) 
462                 return node_select(router_addr, selector);
463
464         /* Slave nodes can only be accessed within own cluster via a 
465            known router with direct link -- if no router was found,give up */
466         if (is_slave(addr))
467                 return 0;
468
469         /* Inter zone/cluster -- find any direct link to remote cluster */
470         addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0);
471         n_ptr = net_select_remote_node(addr, selector);
472         if (n_ptr && node_has_active_links(n_ptr))
473                 return n_ptr;
474
475         /* Last resort -- look for any router to anywhere in remote zone */
476         router_addr =  net_select_router(addr, selector);
477         if (router_addr) 
478                 return node_select(router_addr, selector);
479
480         return 0;
481 }
482
483 /**
484  * node_select_router - select router to reach specified node
485  * 
486  * Uses a deterministic and fair algorithm for selecting router node. 
487  */
488
489 u32 node_select_router(struct node *n_ptr, u32 ref)
490 {
491         u32 ulim;
492         u32 mask;
493         u32 start;
494         u32 r;
495
496         if (!n_ptr)
497                 return 0;
498
499         if (n_ptr->last_router < 0)
500                 return 0;
501         ulim = ((n_ptr->last_router + 1) * 32) - 1;
502
503         /* Start entry must be random */
504         mask = tipc_max_nodes;
505         while (mask > ulim)
506                 mask >>= 1;
507         start = ref & mask;
508         r = start;
509
510         /* Lookup upwards with wrap-around */
511         do {
512                 if (((n_ptr->routers[r / 32]) >> (r % 32)) & 1)
513                         break;
514         } while (++r <= ulim);
515         if (r > ulim) {
516                 r = 1;
517                 do {
518                         if (((n_ptr->routers[r / 32]) >> (r % 32)) & 1)
519                                 break;
520                 } while (++r < start);
521                 assert(r != start);
522         }
523         assert(r && (r <= ulim));
524         return tipc_addr(own_zone(), own_cluster(), r);
525 }
526
527 void node_add_router(struct node *n_ptr, u32 router)
528 {
529         u32 r_num = tipc_node(router);
530
531         n_ptr->routers[r_num / 32] = 
532                 ((1 << (r_num % 32)) | n_ptr->routers[r_num / 32]);
533         n_ptr->last_router = tipc_max_nodes / 32;
534         while ((--n_ptr->last_router >= 0) && 
535                !n_ptr->routers[n_ptr->last_router]);
536 }
537
538 void node_remove_router(struct node *n_ptr, u32 router)
539 {
540         u32 r_num = tipc_node(router);
541
542         if (n_ptr->last_router < 0)
543                 return;         /* No routes */
544
545         n_ptr->routers[r_num / 32] =
546                 ((~(1 << (r_num % 32))) & (n_ptr->routers[r_num / 32]));
547         n_ptr->last_router = tipc_max_nodes / 32;
548         while ((--n_ptr->last_router >= 0) && 
549                !n_ptr->routers[n_ptr->last_router]);
550
551         if (!node_is_up(n_ptr))
552                 node_lost_contact(n_ptr);
553 }
554
555 #if 0
556 void node_print(struct print_buf *buf, struct node *n_ptr, char *str)
557 {
558         u32 i;
559
560         tipc_printf(buf, "\n\n%s", str);
561         for (i = 0; i < MAX_BEARERS; i++) {
562                 if (!n_ptr->links[i]) 
563                         continue;
564                 tipc_printf(buf, "Links[%u]: %x, ", i, n_ptr->links[i]);
565         }
566         tipc_printf(buf, "Active links: [%x,%x]\n",
567                     n_ptr->active_links[0], n_ptr->active_links[1]);
568 }
569 #endif
570
571 u32 tipc_available_nodes(const u32 domain)
572 {
573         struct node *n_ptr;
574         u32 cnt = 0;
575
576         for (n_ptr = nodes; n_ptr; n_ptr = n_ptr->next) {
577                 if (!in_scope(domain, n_ptr->addr))
578                         continue;
579                 if (node_is_up(n_ptr))
580                         cnt++;
581         }
582         return cnt;
583 }
584
585 struct sk_buff *node_get_nodes(const void *req_tlv_area, int req_tlv_space)
586 {
587         u32 domain;
588         struct sk_buff *buf;
589         struct node *n_ptr;
590         struct tipc_node_info node_info;
591
592         if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
593                 return cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
594
595         domain = *(u32 *)TLV_DATA(req_tlv_area);
596         domain = ntohl(domain);
597         if (!addr_domain_valid(domain))
598                 return cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
599                                               " (network address)");
600
601         if (!nodes)
602                 return cfg_reply_none();
603
604         /* For now, get space for all other nodes 
605            (will need to modify this when slave nodes are supported */
606
607         buf = cfg_reply_alloc(TLV_SPACE(sizeof(node_info)) *
608                             (tipc_max_nodes - 1));
609         if (!buf)
610                 return NULL;
611
612         /* Add TLVs for all nodes in scope */
613
614         for (n_ptr = nodes; n_ptr; n_ptr = n_ptr->next) {
615                 if (!in_scope(domain, n_ptr->addr))
616                         continue;
617                 node_info.addr = htonl(n_ptr->addr);
618                 node_info.up = htonl(node_is_up(n_ptr));
619                 cfg_append_tlv(buf, TIPC_TLV_NODE_INFO, 
620                                &node_info, sizeof(node_info));
621         }
622
623         return buf;
624 }
625
626 struct sk_buff *node_get_links(const void *req_tlv_area, int req_tlv_space)
627 {
628         u32 domain;
629         struct sk_buff *buf;
630         struct node *n_ptr;
631         struct tipc_link_info link_info;
632
633         if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
634                 return cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
635
636         domain = *(u32 *)TLV_DATA(req_tlv_area);
637         domain = ntohl(domain);
638         if (!addr_domain_valid(domain))
639                 return cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
640                                               " (network address)");
641
642         if (!nodes)
643                 return cfg_reply_none();
644
645         /* For now, get space for 2 links to all other nodes + bcast link 
646            (will need to modify this when slave nodes are supported */
647
648         buf = cfg_reply_alloc(TLV_SPACE(sizeof(link_info)) *
649                             (2 * (tipc_max_nodes - 1) + 1));
650         if (!buf)
651                 return NULL;
652
653         /* Add TLV for broadcast link */
654
655         link_info.dest = tipc_own_addr & 0xfffff00;
656         link_info.dest = htonl(link_info.dest);
657         link_info.up = htonl(1);
658         sprintf(link_info.str, bc_link_name);
659         cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info));
660
661         /* Add TLVs for any other links in scope */
662
663         for (n_ptr = nodes; n_ptr; n_ptr = n_ptr->next) {
664                 u32 i;
665
666                 if (!in_scope(domain, n_ptr->addr))
667                         continue;
668                 for (i = 0; i < MAX_BEARERS; i++) {
669                         if (!n_ptr->links[i]) 
670                                 continue;
671                         link_info.dest = htonl(n_ptr->addr);
672                         link_info.up = htonl(link_is_up(n_ptr->links[i]));
673                         strcpy(link_info.str, n_ptr->links[i]->name);
674                         cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, 
675                                        &link_info, sizeof(link_info));
676                 }
677         }
678
679         return buf;
680 }