]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_abr.c
*.c: Change level of debug messages to LOG_DEBUG.
[mirror_frr.git] / ospf6d / ospf6_abr.c
1 /*
2 * Area Border Router function.
3 * Copyright (C) 2004 Yasuhiro Ohara
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
23 #include <zebra.h>
24
25 #include "log.h"
26 #include "prefix.h"
27 #include "table.h"
28 #include "vty.h"
29 #include "linklist.h"
30 #include "command.h"
31 #include "thread.h"
32
33 #include "ospf6_proto.h"
34 #include "ospf6_route.h"
35 #include "ospf6_lsa.h"
36 #include "ospf6_route.h"
37 #include "ospf6_lsdb.h"
38 #include "ospf6_message.h"
39
40 #include "ospf6_top.h"
41 #include "ospf6_area.h"
42 #include "ospf6_interface.h"
43 #include "ospf6_neighbor.h"
44
45 #include "ospf6_flood.h"
46 #include "ospf6_intra.h"
47 #include "ospf6_abr.h"
48 #include "ospf6d.h"
49
50 unsigned char conf_debug_ospf6_abr;
51
52 int
53 ospf6_is_router_abr (struct ospf6 *o)
54 {
55 struct listnode *node;
56 struct ospf6_area *oa;
57 int area_count = 0;
58
59 for (node = listhead (o->area_list); node; nextnode (node))
60 {
61 oa = OSPF6_AREA (getdata (node));
62 if (IS_AREA_ENABLED (oa))
63 area_count++;
64 }
65
66 if (area_count > 1)
67 return 1;
68 return 0;
69 }
70
71 void
72 ospf6_abr_enable_area (struct ospf6_area *area)
73 {
74 struct ospf6_area *oa;
75 struct ospf6_route *ro;
76 struct listnode *node;
77
78 for (node = listhead (area->ospf6->area_list); node; nextnode (node))
79 {
80 oa = OSPF6_AREA (getdata (node));
81
82 /* update B bit for each area */
83 OSPF6_ROUTER_LSA_SCHEDULE (oa);
84
85 /* install other area's configured address range */
86 if (oa != area)
87 {
88 for (ro = ospf6_route_head (oa->range_table); ro;
89 ro = ospf6_route_next (ro))
90 {
91 if (CHECK_FLAG (ro->flag, OSPF6_ROUTE_ACTIVE_SUMMARY))
92 ospf6_abr_originate_summary_to_area (ro, area);
93 }
94 }
95 }
96
97 /* install calculated routes to border routers */
98 for (ro = ospf6_route_head (area->ospf6->brouter_table); ro;
99 ro = ospf6_route_next (ro))
100 ospf6_abr_originate_summary_to_area (ro, area);
101
102 /* install calculated routes to network (may be rejected by ranges) */
103 for (ro = ospf6_route_head (area->ospf6->route_table); ro;
104 ro = ospf6_route_next (ro))
105 ospf6_abr_originate_summary_to_area (ro, area);
106 }
107
108 void
109 ospf6_abr_disable_area (struct ospf6_area *area)
110 {
111 struct ospf6_area *oa;
112 struct ospf6_route *ro;
113 struct ospf6_lsa *old;
114 struct listnode *node;
115
116 /* Withdraw all summary prefixes previously originated */
117 for (ro = ospf6_route_head (area->summary_prefix); ro;
118 ro = ospf6_route_next (ro))
119 {
120 old = ospf6_lsdb_lookup (ro->path.origin.type, ro->path.origin.id,
121 area->ospf6->router_id, area->lsdb);
122 if (old)
123 ospf6_lsa_purge (old);
124 ospf6_route_remove (ro, area->summary_prefix);
125 }
126
127 /* Withdraw all summary router-routes previously originated */
128 for (ro = ospf6_route_head (area->summary_router); ro;
129 ro = ospf6_route_next (ro))
130 {
131 old = ospf6_lsdb_lookup (ro->path.origin.type, ro->path.origin.id,
132 area->ospf6->router_id, area->lsdb);
133 if (old)
134 ospf6_lsa_purge (old);
135 ospf6_route_remove (ro, area->summary_router);
136 }
137
138 /* Schedule Router-LSA for each area (ABR status may change) */
139 for (node = listhead (area->ospf6->area_list); node; nextnode (node))
140 {
141 oa = OSPF6_AREA (getdata (node));
142
143 /* update B bit for each area */
144 OSPF6_ROUTER_LSA_SCHEDULE (oa);
145 }
146 }
147
148 /* RFC 2328 12.4.3. Summary-LSAs */
149 void
150 ospf6_abr_originate_summary_to_area (struct ospf6_route *route,
151 struct ospf6_area *area)
152 {
153 struct ospf6_lsa *lsa, *old = NULL;
154 struct ospf6_interface *oi;
155 struct ospf6_route *summary, *range = NULL;
156 struct ospf6_area *route_area;
157 char buffer[OSPF6_MAX_LSASIZE];
158 struct ospf6_lsa_header *lsa_header;
159 caddr_t p;
160 struct ospf6_inter_prefix_lsa *prefix_lsa;
161 struct ospf6_inter_router_lsa *router_lsa;
162 struct ospf6_route_table *summary_table = NULL;
163 u_int16_t type;
164 char buf[64];
165 int is_debug = 0;
166
167 if (route->type == OSPF6_DEST_TYPE_ROUTER)
168 {
169 if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_ORIGINATE (INTER_ROUTER))
170 {
171 is_debug++;
172 inet_ntop (AF_INET, &(ADV_ROUTER_IN_PREFIX (&route->prefix)),
173 buf, sizeof (buf));
174 zlog_debug ("Originating summary in area %s for ASBR %s",
175 area->name, buf);
176 }
177 summary_table = area->summary_router;
178 }
179 else
180 {
181 if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_ORIGINATE (INTER_PREFIX))
182 {
183 is_debug++;
184 prefix2str (&route->prefix, buf, sizeof (buf));
185 zlog_debug ("Originating summary in area %s for %s",
186 area->name, buf);
187 }
188 summary_table = area->summary_prefix;
189 }
190
191 summary = ospf6_route_lookup (&route->prefix, summary_table);
192 if (summary)
193 old = ospf6_lsdb_lookup (summary->path.origin.type,
194 summary->path.origin.id,
195 area->ospf6->router_id, area->lsdb);
196
197 /* if this route has just removed, remove corresponding LSA */
198 if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE))
199 {
200 if (is_debug)
201 zlog_debug ("The route has just removed, purge previous LSA");
202 if (summary)
203 ospf6_route_remove (summary, summary_table);
204 if (old)
205 ospf6_lsa_purge (old);
206 return;
207 }
208
209 /* Only destination type network, range or ASBR are considered */
210 if (route->type != OSPF6_DEST_TYPE_NETWORK &&
211 route->type != OSPF6_DEST_TYPE_RANGE &&
212 (route->type != OSPF6_DEST_TYPE_ROUTER ||
213 ! CHECK_FLAG (route->path.router_bits, OSPF6_ROUTER_BIT_E)))
214 {
215 if (is_debug)
216 zlog_debug ("Route type is none of network, range nor ASBR, withdraw");
217 if (summary)
218 ospf6_route_remove (summary, summary_table);
219 if (old)
220 ospf6_lsa_purge (old);
221 return;
222 }
223
224 /* AS External routes are never considered */
225 if (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1 ||
226 route->path.type == OSPF6_PATH_TYPE_EXTERNAL2)
227 {
228 if (is_debug)
229 zlog_debug ("Path type is external, withdraw");
230 if (summary)
231 ospf6_route_remove (summary, summary_table);
232 if (old)
233 ospf6_lsa_purge (old);
234 return;
235 }
236
237 /* do not generate if the path's area is the same as target area */
238 if (route->path.area_id == area->area_id)
239 {
240 if (is_debug)
241 zlog_debug ("The route is in the area itself, ignore");
242 if (summary)
243 ospf6_route_remove (summary, summary_table);
244 if (old)
245 ospf6_lsa_purge (old);
246 return;
247 }
248
249 /* do not generate if the nexthops belongs to the target area */
250 oi = ospf6_interface_lookup_by_ifindex (route->nexthop[0].ifindex);
251 if (oi && oi->area && oi->area == area)
252 {
253 if (is_debug)
254 zlog_debug ("The route's nexthop is in the same area, ignore");
255 if (summary)
256 ospf6_route_remove (summary, summary_table);
257 if (old)
258 ospf6_lsa_purge (old);
259 return;
260 }
261
262 /* do not generate if the route cost is greater or equal to LSInfinity */
263 if (route->path.cost >= LS_INFINITY)
264 {
265 if (is_debug)
266 zlog_debug ("The cost exceeds LSInfinity, withdraw");
267 if (summary)
268 ospf6_route_remove (summary, summary_table);
269 if (old)
270 ospf6_lsa_purge (old);
271 return;
272 }
273
274 /* if this is a route to ASBR */
275 if (route->type == OSPF6_DEST_TYPE_ROUTER)
276 {
277 /* Only the prefered best path is considered */
278 if (! CHECK_FLAG (route->flag, OSPF6_ROUTE_BEST))
279 {
280 if (is_debug)
281 zlog_debug ("This is the secondary path to the ASBR, ignore");
282 if (summary)
283 ospf6_route_remove (summary, summary_table);
284 if (old)
285 ospf6_lsa_purge (old);
286 return;
287 }
288
289 /* Do not generate if the area is stub */
290 /* XXX */
291 }
292
293 /* if this is an intra-area route, this may be suppressed by aggregation */
294 if (route->type == OSPF6_DEST_TYPE_NETWORK &&
295 route->path.type == OSPF6_PATH_TYPE_INTRA)
296 {
297 /* search for configured address range for the route's area */
298 route_area = ospf6_area_lookup (route->path.area_id, area->ospf6);
299 assert (route_area);
300 range = ospf6_route_lookup_bestmatch (&route->prefix,
301 route_area->range_table);
302
303 /* ranges are ignored when originate backbone routes to transit area.
304 Otherwise, if ranges are configured, the route is suppressed. */
305 if (range && ! CHECK_FLAG (range->flag, OSPF6_ROUTE_REMOVE) &&
306 (route->path.area_id != BACKBONE_AREA_ID ||
307 ! IS_AREA_TRANSIT (area)))
308 {
309 if (is_debug)
310 {
311 prefix2str (&range->prefix, buf, sizeof (buf));
312 zlog_debug ("Suppressed by range %s of area %s",
313 buf, route_area->name);
314 }
315
316 if (summary)
317 ospf6_route_remove (summary, summary_table);
318 if (old)
319 ospf6_lsa_purge (old);
320 return;
321 }
322 }
323
324 /* If this is a configured address range */
325 if (route->type == OSPF6_DEST_TYPE_RANGE)
326 {
327 /* If DoNotAdvertise is set */
328 if (CHECK_FLAG (route->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE))
329 {
330 if (is_debug)
331 zlog_debug ("This is the range with DoNotAdvertise set. ignore");
332 if (summary)
333 ospf6_route_remove (summary, summary_table);
334 if (old)
335 ospf6_lsa_purge (old);
336 return;
337 }
338
339 /* Whether the route have active longer prefix */
340 if (! CHECK_FLAG (route->flag, OSPF6_ROUTE_ACTIVE_SUMMARY))
341 {
342 if (is_debug)
343 zlog_debug ("The range is not active. withdraw");
344 if (summary)
345 ospf6_route_remove (summary, summary_table);
346 if (old)
347 ospf6_lsa_purge (old);
348 return;
349 }
350 }
351
352 /* the route is going to be originated. store it in area's summary_table */
353 if (summary == NULL)
354 {
355 summary = ospf6_route_copy (route);
356 if (route->type == OSPF6_DEST_TYPE_NETWORK ||
357 route->type == OSPF6_DEST_TYPE_RANGE)
358 summary->path.origin.type = htons (OSPF6_LSTYPE_INTER_PREFIX);
359 else
360 summary->path.origin.type = htons (OSPF6_LSTYPE_INTER_ROUTER);
361 summary->path.origin.adv_router = area->ospf6->router_id;
362 summary->path.origin.id =
363 ospf6_new_ls_id (summary->path.origin.type,
364 summary->path.origin.adv_router, area->lsdb);
365 summary = ospf6_route_add (summary, summary_table);
366 }
367 else
368 {
369 summary->type = route->type;
370 gettimeofday (&summary->changed, NULL);
371 }
372
373 summary->path.router_bits = route->path.router_bits;
374 summary->path.options[0] = route->path.options[0];
375 summary->path.options[1] = route->path.options[1];
376 summary->path.options[2] = route->path.options[2];
377 summary->path.prefix_options = route->path.prefix_options;
378 summary->path.area_id = area->area_id;
379 summary->path.type = OSPF6_PATH_TYPE_INTER;
380 summary->path.cost = route->path.cost;
381 summary->nexthop[0] = route->nexthop[0];
382
383 /* prepare buffer */
384 memset (buffer, 0, sizeof (buffer));
385 lsa_header = (struct ospf6_lsa_header *) buffer;
386
387 if (route->type == OSPF6_DEST_TYPE_ROUTER)
388 {
389 router_lsa = (struct ospf6_inter_router_lsa *)
390 ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header));
391 p = (caddr_t) router_lsa + sizeof (struct ospf6_inter_router_lsa);
392
393 /* Fill Inter-Area-Router-LSA */
394 router_lsa->options[0] = route->path.options[0];
395 router_lsa->options[1] = route->path.options[1];
396 router_lsa->options[2] = route->path.options[2];
397 OSPF6_ABR_SUMMARY_METRIC_SET (router_lsa, route->path.cost);
398 router_lsa->router_id = ADV_ROUTER_IN_PREFIX (&route->prefix);
399 type = htons (OSPF6_LSTYPE_INTER_ROUTER);
400 }
401 else
402 {
403 prefix_lsa = (struct ospf6_inter_prefix_lsa *)
404 ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header));
405 p = (caddr_t) prefix_lsa + sizeof (struct ospf6_inter_prefix_lsa);
406
407 /* Fill Inter-Area-Prefix-LSA */
408 OSPF6_ABR_SUMMARY_METRIC_SET (prefix_lsa, route->path.cost);
409 prefix_lsa->prefix.prefix_length = route->prefix.prefixlen;
410 prefix_lsa->prefix.prefix_options = route->path.prefix_options;
411
412 /* set Prefix */
413 memcpy (p, &route->prefix.u.prefix6,
414 OSPF6_PREFIX_SPACE (route->prefix.prefixlen));
415 ospf6_prefix_apply_mask (&prefix_lsa->prefix);
416 p += OSPF6_PREFIX_SPACE (route->prefix.prefixlen);
417 type = htons (OSPF6_LSTYPE_INTER_PREFIX);
418 }
419
420 /* Fill LSA Header */
421 lsa_header->age = 0;
422 lsa_header->type = type;
423 lsa_header->id = summary->path.origin.id;
424 lsa_header->adv_router = area->ospf6->router_id;
425 lsa_header->seqnum =
426 ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id,
427 lsa_header->adv_router, area->lsdb);
428 lsa_header->length = htons ((caddr_t) p - (caddr_t) lsa_header);
429
430 /* LSA checksum */
431 ospf6_lsa_checksum (lsa_header);
432
433 /* create LSA */
434 lsa = ospf6_lsa_create (lsa_header);
435
436 /* Originate */
437 ospf6_lsa_originate_area (lsa, area);
438 }
439
440 void
441 ospf6_abr_range_update (struct ospf6_route *range)
442 {
443 u_int32_t cost = 0;
444 struct ospf6_route *ro;
445
446 assert (range->type == OSPF6_DEST_TYPE_RANGE);
447
448 /* update range's cost and active flag */
449 for (ro = ospf6_route_match_head (&range->prefix, ospf6->route_table);
450 ro; ro = ospf6_route_match_next (&range->prefix, ro))
451 {
452 if (ro->path.area_id == range->path.area_id &&
453 ! CHECK_FLAG (ro->flag, OSPF6_ROUTE_REMOVE))
454 cost = MAX (cost, ro->path.cost);
455 }
456
457 if (range->path.cost != cost)
458 {
459 range->path.cost = cost;
460
461 if (range->path.cost)
462 SET_FLAG (range->flag, OSPF6_ROUTE_ACTIVE_SUMMARY);
463 else
464 UNSET_FLAG (range->flag, OSPF6_ROUTE_ACTIVE_SUMMARY);
465
466 ospf6_abr_originate_summary (range);
467 }
468 }
469
470 void
471 ospf6_abr_originate_summary (struct ospf6_route *route)
472 {
473 struct listnode *node;
474 struct ospf6_area *oa;
475 struct ospf6_route *range = NULL;
476
477 if (route->type == OSPF6_DEST_TYPE_NETWORK)
478 {
479 oa = ospf6_area_lookup (route->path.area_id, ospf6);
480 range = ospf6_route_lookup_bestmatch (&route->prefix, oa->range_table);
481 if (range)
482 ospf6_abr_range_update (range);
483 }
484
485 for (node = listhead (ospf6->area_list); node; nextnode (node))
486 {
487 oa = (struct ospf6_area *) getdata (node);
488 ospf6_abr_originate_summary_to_area (route, oa);
489 }
490 }
491
492 /* RFC 2328 16.2. Calculating the inter-area routes */
493 void
494 ospf6_abr_examin_summary (struct ospf6_lsa *lsa, struct ospf6_area *oa)
495 {
496 struct prefix prefix, abr_prefix;
497 struct ospf6_route_table *table = NULL;
498 struct ospf6_route *range, *route, *old = NULL;
499 struct ospf6_route *abr_entry;
500 u_char type = 0;
501 char options[3] = {0, 0, 0};
502 u_int8_t prefix_options = 0;
503 u_int32_t cost = 0;
504 u_char router_bits = 0;
505 int i;
506 char buf[64];
507 int is_debug = 0;
508
509 if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_PREFIX))
510 {
511 struct ospf6_inter_prefix_lsa *prefix_lsa;
512
513 if (IS_OSPF6_DEBUG_EXAMIN (INTER_PREFIX))
514 {
515 is_debug++;
516 zlog_debug ("Examin %s in area %s", lsa->name, oa->name);
517 }
518
519 prefix_lsa = (struct ospf6_inter_prefix_lsa *)
520 OSPF6_LSA_HEADER_END (lsa->header);
521 prefix.family = AF_INET6;
522 prefix.prefixlen = prefix_lsa->prefix.prefix_length;
523 ospf6_prefix_in6_addr (&prefix.u.prefix6, &prefix_lsa->prefix);
524 prefix2str (&prefix, buf, sizeof (buf));
525 table = oa->ospf6->route_table;
526 type = OSPF6_DEST_TYPE_NETWORK;
527 prefix_options = prefix_lsa->prefix.prefix_options;
528 cost = OSPF6_ABR_SUMMARY_METRIC (prefix_lsa);
529 }
530 else if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_ROUTER))
531 {
532 struct ospf6_inter_router_lsa *router_lsa;
533
534 if (IS_OSPF6_DEBUG_EXAMIN (INTER_ROUTER))
535 {
536 is_debug++;
537 zlog_debug ("Examin %s in area %s", lsa->name, oa->name);
538 }
539
540 router_lsa = (struct ospf6_inter_router_lsa *)
541 OSPF6_LSA_HEADER_END (lsa->header);
542 ospf6_linkstate_prefix (router_lsa->router_id, htonl (0), &prefix);
543 inet_ntop (AF_INET, &router_lsa->router_id, buf, sizeof (buf));
544 table = oa->ospf6->brouter_table;
545 type = OSPF6_DEST_TYPE_ROUTER;
546 options[0] = router_lsa->options[0];
547 options[1] = router_lsa->options[1];
548 options[2] = router_lsa->options[2];
549 cost = OSPF6_ABR_SUMMARY_METRIC (router_lsa);
550 SET_FLAG (router_bits, OSPF6_ROUTER_BIT_E);
551 }
552 else
553 assert (0);
554
555 /* Find existing route */
556 route = ospf6_route_lookup (&prefix, table);
557 if (route)
558 ospf6_route_lock (route);
559 while (route && ospf6_route_is_prefix (&prefix, route))
560 {
561 if (route->path.area_id == oa->area_id &&
562 route->path.origin.type == lsa->header->type &&
563 route->path.origin.id == lsa->header->id &&
564 route->path.origin.adv_router == lsa->header->adv_router)
565 old = route;
566 route = ospf6_route_next (route);
567 }
568
569 /* (1) if cost == LSInfinity or if the LSA is MaxAge */
570 if (cost == LS_INFINITY)
571 {
572 if (is_debug)
573 zlog_debug ("cost is LS_INFINITY, ignore");
574 if (old)
575 ospf6_route_remove (old, table);
576 return;
577 }
578 if (OSPF6_LSA_IS_MAXAGE (lsa))
579 {
580 if (is_debug)
581 zlog_debug ("LSA is MaxAge, ignore");
582 if (old)
583 ospf6_route_remove (old, table);
584 return;
585 }
586
587 /* (2) if the LSA is self-originated, ignore */
588 if (lsa->header->adv_router == oa->ospf6->router_id)
589 {
590 if (is_debug)
591 zlog_debug ("LSA is self-originated, ignore");
592 if (old)
593 ospf6_route_remove (old, table);
594 return;
595 }
596
597 /* (3) if the prefix is equal to an active configured address range */
598 if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_PREFIX))
599 {
600 range = ospf6_route_lookup (&prefix, oa->range_table);
601 if (range)
602 {
603 if (is_debug)
604 zlog_debug ("Prefix is equal to address range, ignore");
605 if (old)
606 ospf6_route_remove (old, table);
607 return;
608 }
609 }
610
611 /* (4) if the routing table entry for the ABR does not exist */
612 ospf6_linkstate_prefix (lsa->header->adv_router, htonl (0), &abr_prefix);
613 abr_entry = ospf6_route_lookup (&abr_prefix, oa->ospf6->brouter_table);
614 if (abr_entry == NULL || abr_entry->path.area_id != oa->area_id ||
615 CHECK_FLAG (abr_entry->flag, OSPF6_ROUTE_REMOVE) ||
616 ! CHECK_FLAG (abr_entry->path.router_bits, OSPF6_ROUTER_BIT_B))
617 {
618 if (is_debug)
619 zlog_debug ("ABR router entry does not exist, ignore");
620 if (old)
621 ospf6_route_remove (old, table);
622 return;
623 }
624
625 /* (5),(6),(7) the path preference is handled by the sorting
626 in the routing table. Always install the path by substituting
627 old route (if any). */
628 if (old)
629 route = ospf6_route_copy (old);
630 else
631 route = ospf6_route_create ();
632
633 route->type = type;
634 route->prefix = prefix;
635 route->path.origin.type = lsa->header->type;
636 route->path.origin.id = lsa->header->id;
637 route->path.origin.adv_router = lsa->header->adv_router;
638 route->path.router_bits = router_bits;
639 route->path.options[0] = options[0];
640 route->path.options[1] = options[1];
641 route->path.options[2] = options[2];
642 route->path.prefix_options = prefix_options;
643 route->path.area_id = oa->area_id;
644 route->path.type = OSPF6_PATH_TYPE_INTER;
645 route->path.cost = abr_entry->path.cost + cost;
646 for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++)
647 route->nexthop[i] = abr_entry->nexthop[i];
648
649 if (is_debug)
650 zlog_debug ("Install route: %s", buf);
651 ospf6_route_add (route, table);
652 }
653
654 void
655 ospf6_abr_examin_brouter (u_int32_t router_id)
656 {
657 struct ospf6_lsa *lsa;
658 struct ospf6_area *oa;
659 struct listnode *node;
660 u_int16_t type;
661
662 type = htons (OSPF6_LSTYPE_INTER_ROUTER);
663 for (node = listhead (ospf6->area_list); node; nextnode (node))
664 {
665 oa = OSPF6_AREA (getdata (node));
666 for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa;
667 lsa = ospf6_lsdb_type_router_next (type, router_id, lsa))
668 ospf6_abr_examin_summary (lsa, oa);
669 }
670
671 type = htons (OSPF6_LSTYPE_INTER_PREFIX);
672 for (node = listhead (ospf6->area_list); node; nextnode (node))
673 {
674 oa = OSPF6_AREA (getdata (node));
675 for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa;
676 lsa = ospf6_lsdb_type_router_next (type, router_id, lsa))
677 ospf6_abr_examin_summary (lsa, oa);
678 }
679 }
680
681 \f
682 /* Display functions */
683 int
684 ospf6_inter_area_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
685 {
686 struct ospf6_inter_prefix_lsa *prefix_lsa;
687 struct in6_addr in6;
688 char buf[64];
689
690 prefix_lsa = (struct ospf6_inter_prefix_lsa *)
691 OSPF6_LSA_HEADER_END (lsa->header);
692
693 vty_out (vty, " Metric: %lu%s",
694 (u_long) OSPF6_ABR_SUMMARY_METRIC (prefix_lsa), VNL);
695
696 ospf6_prefix_options_printbuf (prefix_lsa->prefix.prefix_options,
697 buf, sizeof (buf));
698 vty_out (vty, " Prefix Options: %s%s", buf, VNL);
699
700 ospf6_prefix_in6_addr (&in6, &prefix_lsa->prefix);
701 inet_ntop (AF_INET6, &in6, buf, sizeof (buf));
702 vty_out (vty, " Prefix: %s/%d%s", buf,
703 prefix_lsa->prefix.prefix_length, VNL);
704
705 return 0;
706 }
707
708 int
709 ospf6_inter_area_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa)
710 {
711 struct ospf6_inter_router_lsa *router_lsa;
712 char buf[64];
713
714 router_lsa = (struct ospf6_inter_router_lsa *)
715 OSPF6_LSA_HEADER_END (lsa->header);
716
717 ospf6_options_printbuf (router_lsa->options, buf, sizeof (buf));
718 vty_out (vty, " Options: %s%s", buf, VNL);
719 vty_out (vty, " Metric: %lu%s",
720 (u_long) OSPF6_ABR_SUMMARY_METRIC (router_lsa), VNL);
721 inet_ntop (AF_INET, &router_lsa->router_id, buf, sizeof (buf));
722 vty_out (vty, " Destination Router ID: %s%s", buf, VNL);
723
724 return 0;
725 }
726
727 /* Debug commands */
728 DEFUN (debug_ospf6_abr,
729 debug_ospf6_abr_cmd,
730 "debug ospf6 abr",
731 DEBUG_STR
732 OSPF6_STR
733 "Debug OSPFv3 ABR function\n"
734 )
735 {
736 OSPF6_DEBUG_ABR_ON ();
737 return CMD_SUCCESS;
738 }
739
740 DEFUN (no_debug_ospf6_abr,
741 no_debug_ospf6_abr_cmd,
742 "no debug ospf6 abr",
743 NO_STR
744 DEBUG_STR
745 OSPF6_STR
746 "Debug OSPFv3 ABR function\n"
747 )
748 {
749 OSPF6_DEBUG_ABR_OFF ();
750 return CMD_SUCCESS;
751 }
752
753 int
754 config_write_ospf6_debug_abr (struct vty *vty)
755 {
756 if (IS_OSPF6_DEBUG_ABR)
757 vty_out (vty, "debug ospf6 abr%s", VNL);
758 return 0;
759 }
760
761 void
762 install_element_ospf6_debug_abr ()
763 {
764 install_element (ENABLE_NODE, &debug_ospf6_abr_cmd);
765 install_element (ENABLE_NODE, &no_debug_ospf6_abr_cmd);
766 install_element (CONFIG_NODE, &debug_ospf6_abr_cmd);
767 install_element (CONFIG_NODE, &no_debug_ospf6_abr_cmd);
768 }
769
770 struct ospf6_lsa_handler inter_prefix_handler =
771 {
772 OSPF6_LSTYPE_INTER_PREFIX,
773 "Inter-Prefix",
774 ospf6_inter_area_prefix_lsa_show
775 };
776
777 struct ospf6_lsa_handler inter_router_handler =
778 {
779 OSPF6_LSTYPE_INTER_ROUTER,
780 "Inter-Router",
781 ospf6_inter_area_router_lsa_show
782 };
783
784 void
785 ospf6_abr_init ()
786 {
787 ospf6_install_lsa_handler (&inter_prefix_handler);
788 ospf6_install_lsa_handler (&inter_router_handler);
789 }
790
791