2 * Copyright (C) 2003 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include "ospf6_proto.h"
32 #include "ospf6_lsa.h"
33 #include "ospf6_lsdb.h"
34 #include "ospf6_route.h"
35 #include "ospf6_top.h"
36 #include "ospf6_area.h"
37 #include "ospf6_interface.h"
39 #include "ospf6_zebra.h"
41 unsigned char conf_debug_ospf6_route
= 0;
43 static char *ospf6_route_table_name(struct ospf6_route_table
*table
)
46 switch (table
->scope_type
) {
47 case OSPF6_SCOPE_TYPE_GLOBAL
: {
48 switch (table
->table_type
) {
49 case OSPF6_TABLE_TYPE_ROUTES
:
50 snprintf(name
, sizeof(name
), "global route table");
52 case OSPF6_TABLE_TYPE_BORDER_ROUTERS
:
53 snprintf(name
, sizeof(name
), "global brouter table");
55 case OSPF6_TABLE_TYPE_EXTERNAL_ROUTES
:
56 snprintf(name
, sizeof(name
), "global external table");
59 snprintf(name
, sizeof(name
), "global unknown table");
64 case OSPF6_SCOPE_TYPE_AREA
: {
65 struct ospf6_area
*oa
= (struct ospf6_area
*)table
->scope
;
66 switch (table
->table_type
) {
67 case OSPF6_TABLE_TYPE_SPF_RESULTS
:
68 snprintf(name
, sizeof(name
), "area %s spf table",
71 case OSPF6_TABLE_TYPE_ROUTES
:
72 snprintf(name
, sizeof(name
), "area %s route table",
75 case OSPF6_TABLE_TYPE_PREFIX_RANGES
:
76 snprintf(name
, sizeof(name
), "area %s range table",
79 case OSPF6_TABLE_TYPE_SUMMARY_PREFIXES
:
80 snprintf(name
, sizeof(name
),
81 "area %s summary prefix table", oa
->name
);
83 case OSPF6_TABLE_TYPE_SUMMARY_ROUTERS
:
84 snprintf(name
, sizeof(name
),
85 "area %s summary router table", oa
->name
);
88 snprintf(name
, sizeof(name
), "area %s unknown table",
94 case OSPF6_SCOPE_TYPE_INTERFACE
: {
95 struct ospf6_interface
*oi
=
96 (struct ospf6_interface
*)table
->scope
;
97 switch (table
->table_type
) {
98 case OSPF6_TABLE_TYPE_CONNECTED_ROUTES
:
99 snprintf(name
, sizeof(name
),
100 "interface %s connected table",
101 oi
->interface
->name
);
104 snprintf(name
, sizeof(name
),
105 "interface %s unknown table",
106 oi
->interface
->name
);
112 switch (table
->table_type
) {
113 case OSPF6_TABLE_TYPE_SPF_RESULTS
:
114 snprintf(name
, sizeof(name
), "temporary spf table");
117 snprintf(name
, sizeof(name
), "temporary unknown table");
125 void ospf6_linkstate_prefix(uint32_t adv_router
, uint32_t id
,
126 struct prefix
*prefix
)
128 memset(prefix
, 0, sizeof(struct prefix
));
129 prefix
->family
= AF_INET6
;
130 prefix
->prefixlen
= 64;
131 memcpy(&prefix
->u
.prefix6
.s6_addr
[0], &adv_router
, 4);
132 memcpy(&prefix
->u
.prefix6
.s6_addr
[4], &id
, 4);
135 void ospf6_linkstate_prefix2str(struct prefix
*prefix
, char *buf
, int size
)
137 uint32_t adv_router
, id
;
138 char adv_router_str
[16], id_str
[16];
139 memcpy(&adv_router
, &prefix
->u
.prefix6
.s6_addr
[0], 4);
140 memcpy(&id
, &prefix
->u
.prefix6
.s6_addr
[4], 4);
141 inet_ntop(AF_INET
, &adv_router
, adv_router_str
, sizeof(adv_router_str
));
142 inet_ntop(AF_INET
, &id
, id_str
, sizeof(id_str
));
144 snprintf(buf
, size
, "%s Net-ID: %s", adv_router_str
, id_str
);
146 snprintf(buf
, size
, "%s", adv_router_str
);
149 /* Global strings for logging */
150 const char *const ospf6_dest_type_str
[OSPF6_DEST_TYPE_MAX
] = {
151 "Unknown", "Router", "Network", "Discard", "Linkstate", "AddressRange",
154 const char *const ospf6_dest_type_substr
[OSPF6_DEST_TYPE_MAX
] = {
155 "?", "R", "N", "D", "L", "A",
158 const char *const ospf6_path_type_str
[OSPF6_PATH_TYPE_MAX
] = {
159 "Unknown", "Intra-Area", "Inter-Area", "External-1", "External-2",
162 const char *const ospf6_path_type_substr
[OSPF6_PATH_TYPE_MAX
] = {
163 "??", "IA", "IE", "E1", "E2",
167 struct ospf6_nexthop
*ospf6_nexthop_create(void)
169 struct ospf6_nexthop
*nh
;
171 nh
= XCALLOC(MTYPE_OSPF6_NEXTHOP
, sizeof(struct ospf6_nexthop
));
175 void ospf6_nexthop_delete(struct ospf6_nexthop
*nh
)
177 XFREE(MTYPE_OSPF6_NEXTHOP
, nh
);
180 void ospf6_clear_nexthops(struct list
*nh_list
)
182 struct listnode
*node
;
183 struct ospf6_nexthop
*nh
;
186 for (ALL_LIST_ELEMENTS_RO(nh_list
, node
, nh
))
187 ospf6_nexthop_clear(nh
);
191 static struct ospf6_nexthop
*
192 ospf6_route_find_nexthop(struct list
*nh_list
, struct ospf6_nexthop
*nh_match
)
194 struct listnode
*node
;
195 struct ospf6_nexthop
*nh
;
197 if (nh_list
&& nh_match
) {
198 for (ALL_LIST_ELEMENTS_RO(nh_list
, node
, nh
)) {
199 if (ospf6_nexthop_is_same(nh
, nh_match
))
207 void ospf6_copy_nexthops(struct list
*dst
, struct list
*src
)
209 struct ospf6_nexthop
*nh_new
, *nh
;
210 struct listnode
*node
;
213 for (ALL_LIST_ELEMENTS_RO(src
, node
, nh
)) {
214 if (ospf6_nexthop_is_set(nh
)) {
215 nh_new
= ospf6_nexthop_create();
216 ospf6_nexthop_copy(nh_new
, nh
);
217 listnode_add_sort(dst
, nh_new
);
223 void ospf6_merge_nexthops(struct list
*dst
, struct list
*src
)
225 struct listnode
*node
;
226 struct ospf6_nexthop
*nh
, *nh_new
;
229 for (ALL_LIST_ELEMENTS_RO(src
, node
, nh
)) {
230 if (!ospf6_route_find_nexthop(dst
, nh
)) {
231 nh_new
= ospf6_nexthop_create();
232 ospf6_nexthop_copy(nh_new
, nh
);
233 listnode_add_sort(dst
, nh_new
);
239 int ospf6_route_cmp_nexthops(struct ospf6_route
*a
, struct ospf6_route
*b
)
241 struct listnode
*anode
, *bnode
;
242 struct ospf6_nexthop
*anh
, *bnh
;
243 bool identical
= false;
246 if (listcount(a
->nh_list
) == listcount(b
->nh_list
)) {
247 for (ALL_LIST_ELEMENTS_RO(a
->nh_list
, anode
, anh
)) {
249 for (ALL_LIST_ELEMENTS_RO(b
->nh_list
, bnode
,
251 if (ospf6_nexthop_is_same(anh
, bnh
))
254 /* Currnet List A element not found List B
255 * Non-Identical lists return */
256 if (identical
== false)
263 /* One of the routes doesn't exist ? */
267 int ospf6_num_nexthops(struct list
*nh_list
)
269 return (listcount(nh_list
));
272 void ospf6_add_nexthop(struct list
*nh_list
, int ifindex
, struct in6_addr
*addr
)
274 struct ospf6_nexthop
*nh
;
275 struct ospf6_nexthop nh_match
;
278 nh_match
.ifindex
= ifindex
;
280 memcpy(&nh_match
.address
, addr
,
281 sizeof(struct in6_addr
));
283 memset(&nh_match
.address
, 0, sizeof(struct in6_addr
));
285 if (!ospf6_route_find_nexthop(nh_list
, &nh_match
)) {
286 nh
= ospf6_nexthop_create();
287 ospf6_nexthop_copy(nh
, &nh_match
);
288 listnode_add(nh_list
, nh
);
293 void ospf6_route_zebra_copy_nexthops(struct ospf6_route
*route
,
294 struct zapi_nexthop nexthops
[],
297 struct ospf6_nexthop
*nh
;
298 struct listnode
*node
;
299 struct interface
*ifp
;
305 for (ALL_LIST_ELEMENTS_RO(route
->nh_list
, node
, nh
)) {
306 ifp
= if_lookup_by_index_all_vrf(nh
->ifindex
);
307 if (IS_OSPF6_DEBUG_ZEBRA(SEND
)) {
308 inet_ntop(AF_INET6
, &nh
->address
, buf
,
310 zlog_debug(" nexthop: %s%%%.*s(%d)", buf
,
311 IFNAMSIZ
, ifp
->name
, nh
->ifindex
);
316 nexthops
[i
].vrf_id
= ifp
->vrf_id
;
317 nexthops
[i
].ifindex
= nh
->ifindex
;
318 if (!IN6_IS_ADDR_UNSPECIFIED(&nh
->address
)) {
319 nexthops
[i
].gate
.ipv6
= nh
->address
;
320 nexthops
[i
].type
= NEXTHOP_TYPE_IPV6_IFINDEX
;
322 nexthops
[i
].type
= NEXTHOP_TYPE_IFINDEX
;
328 int ospf6_route_get_first_nh_index(struct ospf6_route
*route
)
330 struct ospf6_nexthop
*nh
;
333 nh
= listnode_head(route
->nh_list
);
341 int ospf6_nexthop_cmp(struct ospf6_nexthop
*a
, struct ospf6_nexthop
*b
)
343 if (a
->ifindex
< b
->ifindex
)
345 else if (a
->ifindex
> b
->ifindex
)
348 return memcmp(&a
->address
, &b
->address
,
349 sizeof(struct in6_addr
));
354 static int ospf6_path_cmp(struct ospf6_path
*a
, struct ospf6_path
*b
)
356 if (a
->origin
.adv_router
< b
->origin
.adv_router
)
358 else if (a
->origin
.adv_router
> b
->origin
.adv_router
)
364 void ospf6_path_free(struct ospf6_path
*op
)
367 list_delete(&op
->nh_list
);
368 XFREE(MTYPE_OSPF6_PATH
, op
);
371 struct ospf6_path
*ospf6_path_dup(struct ospf6_path
*path
)
373 struct ospf6_path
*new;
375 new = XCALLOC(MTYPE_OSPF6_PATH
, sizeof(struct ospf6_path
));
376 memcpy(new, path
, sizeof(struct ospf6_path
));
377 new->nh_list
= list_new();
378 new->nh_list
->cmp
= (int (*)(void *, void *))ospf6_nexthop_cmp
;
379 new->nh_list
->del
= (void (*)(void *))ospf6_nexthop_delete
;
384 void ospf6_copy_paths(struct list
*dst
, struct list
*src
)
386 struct ospf6_path
*path_new
, *path
;
387 struct listnode
*node
;
390 for (ALL_LIST_ELEMENTS_RO(src
, node
, path
)) {
391 path_new
= ospf6_path_dup(path
);
392 ospf6_copy_nexthops(path_new
->nh_list
, path
->nh_list
);
393 listnode_add_sort(dst
, path_new
);
398 struct ospf6_route
*ospf6_route_create(void)
400 struct ospf6_route
*route
;
401 route
= XCALLOC(MTYPE_OSPF6_ROUTE
, sizeof(struct ospf6_route
));
402 route
->nh_list
= list_new();
403 route
->nh_list
->cmp
= (int (*)(void *, void *))ospf6_nexthop_cmp
;
404 route
->nh_list
->del
= (void (*)(void *))ospf6_nexthop_delete
;
405 route
->paths
= list_new();
406 route
->paths
->cmp
= (int (*)(void *, void *))ospf6_path_cmp
;
407 route
->paths
->del
= (void (*)(void *))ospf6_path_free
;
411 void ospf6_route_delete(struct ospf6_route
*route
)
415 list_delete(&route
->nh_list
);
417 list_delete(&route
->paths
);
418 XFREE(MTYPE_OSPF6_ROUTE
, route
);
422 struct ospf6_route
*ospf6_route_copy(struct ospf6_route
*route
)
424 struct ospf6_route
*new;
426 new = ospf6_route_create();
427 new->type
= route
->type
;
428 memcpy(&new->prefix
, &route
->prefix
, sizeof(struct prefix
));
429 new->installed
= route
->installed
;
430 new->changed
= route
->changed
;
431 new->flag
= route
->flag
;
432 new->route_option
= route
->route_option
;
433 new->linkstate_id
= route
->linkstate_id
;
434 new->path
= route
->path
;
435 ospf6_copy_nexthops(new->nh_list
, route
->nh_list
);
436 ospf6_copy_paths(new->paths
, route
->paths
);
445 void ospf6_route_lock(struct ospf6_route
*route
)
450 void ospf6_route_unlock(struct ospf6_route
*route
)
452 assert(route
->lock
> 0);
454 if (route
->lock
== 0) {
455 /* Can't detach from the table until here
456 because ospf6_route_next () will use
457 the 'route->table' pointer for logging */
459 ospf6_route_delete(route
);
463 /* Route compare function. If ra is more preferred, it returns
464 less than 0. If rb is more preferred returns greater than 0.
465 Otherwise (neither one is preferred), returns 0 */
466 int ospf6_route_cmp(struct ospf6_route
*ra
, struct ospf6_route
*rb
)
468 assert(ospf6_route_is_same(ra
, rb
));
469 assert(OSPF6_PATH_TYPE_NONE
< ra
->path
.type
470 && ra
->path
.type
< OSPF6_PATH_TYPE_MAX
);
471 assert(OSPF6_PATH_TYPE_NONE
< rb
->path
.type
472 && rb
->path
.type
< OSPF6_PATH_TYPE_MAX
);
474 if (ra
->type
!= rb
->type
)
475 return (ra
->type
- rb
->type
);
477 if (ra
->path
.type
!= rb
->path
.type
)
478 return (ra
->path
.type
- rb
->path
.type
);
480 if (ra
->path
.type
== OSPF6_PATH_TYPE_EXTERNAL2
) {
481 if (ra
->path
.u
.cost_e2
!= rb
->path
.u
.cost_e2
)
482 return (ra
->path
.u
.cost_e2
- rb
->path
.u
.cost_e2
);
484 return (ra
->path
.cost
- rb
->path
.cost
);
486 if (ra
->path
.cost
!= rb
->path
.cost
)
487 return (ra
->path
.cost
- rb
->path
.cost
);
490 if (ra
->path
.area_id
!= rb
->path
.area_id
)
491 return (ntohl(ra
->path
.area_id
) - ntohl(rb
->path
.area_id
));
496 struct ospf6_route
*ospf6_route_lookup(struct prefix
*prefix
,
497 struct ospf6_route_table
*table
)
499 struct route_node
*node
;
500 struct ospf6_route
*route
;
502 node
= route_node_lookup(table
->table
, prefix
);
506 route
= (struct ospf6_route
*)node
->info
;
507 route_unlock_node(node
); /* to free the lookup lock */
512 ospf6_route_lookup_identical(struct ospf6_route
*route
,
513 struct ospf6_route_table
*table
)
515 struct ospf6_route
*target
;
517 for (target
= ospf6_route_lookup(&route
->prefix
, table
); target
;
518 target
= target
->next
) {
519 if (target
->type
== route
->type
520 && (memcmp(&target
->prefix
, &route
->prefix
,
521 sizeof(struct prefix
))
523 && target
->path
.type
== route
->path
.type
524 && target
->path
.cost
== route
->path
.cost
525 && target
->path
.u
.cost_e2
== route
->path
.u
.cost_e2
526 && ospf6_route_cmp_nexthops(target
, route
) == 0)
533 ospf6_route_lookup_bestmatch(struct prefix
*prefix
,
534 struct ospf6_route_table
*table
)
536 struct route_node
*node
;
537 struct ospf6_route
*route
;
539 node
= route_node_match(table
->table
, prefix
);
542 route_unlock_node(node
);
544 route
= (struct ospf6_route
*)node
->info
;
549 static void route_table_assert(struct ospf6_route_table
*table
)
551 struct ospf6_route
*prev
, *r
, *next
;
552 unsigned int link_error
= 0, num
= 0;
554 r
= ospf6_route_head(table
);
560 next
= ospf6_route_next(r
);
569 for (r
= ospf6_route_head(table
); r
; r
= ospf6_route_next(r
))
572 if (link_error
== 0 && num
== table
->count
)
575 flog_err(EC_LIB_DEVELOPMENT
, "PANIC !!");
576 flog_err(EC_LIB_DEVELOPMENT
,
577 "Something has gone wrong with ospf6_route_table[%p]", table
);
578 zlog_debug("table count = %d, real number = %d", table
->count
, num
);
579 zlog_debug("DUMP START");
580 for (r
= ospf6_route_head(table
); r
; r
= ospf6_route_next(r
))
581 zlog_info("%p<-[%p]->%p : %pFX", r
->prev
, r
, r
->next
,
583 zlog_debug("DUMP END");
585 assert(link_error
== 0 && num
== table
->count
);
587 #define ospf6_route_table_assert(t) (route_table_assert (t))
589 #define ospf6_route_table_assert(t) ((void) 0)
592 struct ospf6_route
*ospf6_route_add(struct ospf6_route
*route
,
593 struct ospf6_route_table
*table
,
596 struct route_node
*node
, *nextnode
, *prevnode
;
597 struct ospf6_route
*current
= NULL
;
598 struct ospf6_route
*prev
= NULL
, *old
= NULL
, *next
= NULL
;
599 char buf
[PREFIX2STR_BUFFER
];
602 assert(route
->rnode
== NULL
);
603 assert(route
->lock
== 0);
604 assert(route
->next
== NULL
);
605 assert(route
->prev
== NULL
);
607 if (route
->type
== OSPF6_DEST_TYPE_LINKSTATE
)
608 ospf6_linkstate_prefix2str(&route
->prefix
, buf
, sizeof(buf
));
610 prefix2str(&route
->prefix
, buf
, sizeof(buf
));
612 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
613 zlog_debug("%s %p: route add %p: %s paths %u nh %u",
614 ospf6_route_table_name(table
), (void *)table
,
615 (void *)route
, buf
, listcount(route
->paths
),
616 listcount(route
->nh_list
));
617 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
618 zlog_debug("%s: route add: %s", ospf6_route_table_name(table
),
623 node
= route_node_get(table
->table
, &route
->prefix
);
626 /* find place to insert */
627 for (current
= node
->info
; current
; current
= current
->next
) {
628 if (!ospf6_route_is_same(current
, route
))
630 else if (current
->type
!= route
->type
)
632 else if (ospf6_route_is_same_origin(current
, route
))
634 else if (ospf6_route_cmp(current
, route
) > 0)
644 /* if route does not actually change, return unchanged */
645 if (ospf6_route_is_identical(old
, route
)) {
646 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
648 "%s %p: route add %p: needless update of %p old cost %u",
649 ospf6_route_table_name(table
),
650 (void *)table
, (void *)route
,
651 (void *)old
, old
->path
.cost
);
652 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
653 zlog_debug("%s: route add: needless update",
654 ospf6_route_table_name(table
));
656 ospf6_route_delete(route
);
657 SET_FLAG(old
->flag
, OSPF6_ROUTE_ADD
);
658 ospf6_route_table_assert(table
);
660 /* to free the lookup lock */
661 route_unlock_node(node
);
665 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
667 "%s %p: route add %p cost %u paths %u nh %u: update of %p cost %u paths %u nh %u",
668 ospf6_route_table_name(table
), (void *)table
,
669 (void *)route
, route
->path
.cost
,
670 listcount(route
->paths
),
671 listcount(route
->nh_list
), (void *)old
,
672 old
->path
.cost
, listcount(old
->paths
),
673 listcount(old
->nh_list
));
674 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
675 zlog_debug("%s: route add: update",
676 ospf6_route_table_name(table
));
678 /* replace old one if exists */
679 if (node
->info
== old
) {
681 SET_FLAG(route
->flag
, OSPF6_ROUTE_BEST
);
685 old
->prev
->next
= route
;
686 route
->prev
= old
->prev
;
688 old
->next
->prev
= route
;
689 route
->next
= old
->next
;
691 route
->installed
= old
->installed
;
692 route
->changed
= now
;
693 assert(route
->table
== NULL
);
694 route
->table
= table
;
696 ospf6_route_unlock(old
); /* will be deleted later */
697 ospf6_route_lock(route
);
699 SET_FLAG(route
->flag
, OSPF6_ROUTE_CHANGE
);
700 ospf6_route_table_assert(table
);
703 (*table
->hook_add
)(route
, ospf6
);
708 /* insert if previous or next node found */
710 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
712 "%s %p: route add %p cost %u: another path: prev %p, next %p node ref %u",
713 ospf6_route_table_name(table
), (void *)table
,
714 (void *)route
, route
->path
.cost
, (void *)prev
,
715 (void *)next
, route_node_get_lock_count(node
));
716 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
717 zlog_debug("%s: route add cost %u: another path found",
718 ospf6_route_table_name(table
),
733 if (node
->info
== next
) {
734 assert(next
&& next
->rnode
== node
);
736 UNSET_FLAG(next
->flag
, OSPF6_ROUTE_BEST
);
737 SET_FLAG(route
->flag
, OSPF6_ROUTE_BEST
);
738 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
740 "%s %p: route add %p cost %u: replacing previous best: %p cost %u",
741 ospf6_route_table_name(table
),
742 (void *)table
, (void *)route
,
744 (void *)next
, next
->path
.cost
);
747 route
->installed
= now
;
748 route
->changed
= now
;
749 assert(route
->table
== NULL
);
750 route
->table
= table
;
752 ospf6_route_lock(route
);
754 ospf6_route_table_assert(table
);
756 SET_FLAG(route
->flag
, OSPF6_ROUTE_ADD
);
758 (*table
->hook_add
)(route
, ospf6
);
763 /* Else, this is the brand new route regarding to the prefix */
764 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
765 zlog_debug("%s %p: route add %p %s cost %u: brand new route",
766 ospf6_route_table_name(table
), (void *)table
,
767 (void *)route
, buf
, route
->path
.cost
);
768 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
769 zlog_debug("%s: route add: brand new route",
770 ospf6_route_table_name(table
));
772 assert(node
->info
== NULL
);
774 SET_FLAG(route
->flag
, OSPF6_ROUTE_BEST
);
775 ospf6_route_lock(route
);
776 route
->installed
= now
;
777 route
->changed
= now
;
778 assert(route
->table
== NULL
);
779 route
->table
= table
;
781 /* lookup real existing next route */
783 route_lock_node(nextnode
);
785 nextnode
= route_next(nextnode
);
786 } while (nextnode
&& nextnode
->info
== NULL
);
789 if (nextnode
== NULL
)
792 route_unlock_node(nextnode
);
794 next
= nextnode
->info
;
799 /* lookup real existing prev route */
801 route_lock_node(prevnode
);
803 prevnode
= route_prev(prevnode
);
804 } while (prevnode
&& prevnode
->info
== NULL
);
807 if (prevnode
== NULL
)
810 route_unlock_node(prevnode
);
812 prev
= prevnode
->info
;
813 while (prev
->next
&& ospf6_route_is_same(prev
, prev
->next
))
820 ospf6_route_table_assert(table
);
822 SET_FLAG(route
->flag
, OSPF6_ROUTE_ADD
);
824 (*table
->hook_add
)(route
, ospf6
);
829 void ospf6_route_remove(struct ospf6_route
*route
,
830 struct ospf6_route_table
*table
, struct ospf6
*ospf6
)
832 struct route_node
*node
;
833 struct ospf6_route
*current
;
834 char buf
[PREFIX2STR_BUFFER
];
836 if (route
->type
== OSPF6_DEST_TYPE_LINKSTATE
)
837 ospf6_linkstate_prefix2str(&route
->prefix
, buf
, sizeof(buf
));
839 prefix2str(&route
->prefix
, buf
, sizeof(buf
));
841 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
842 zlog_debug("%s %p: route remove %p: %s cost %u refcount %u",
843 ospf6_route_table_name(table
), (void *)table
,
844 (void *)route
, buf
, route
->path
.cost
, route
->lock
);
845 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
846 zlog_debug("%s: route remove: %s",
847 ospf6_route_table_name(table
), buf
);
849 node
= route_node_lookup(table
->table
, &route
->prefix
);
852 /* find the route to remove, making sure that the route pointer
853 is from the route table. */
854 current
= node
->info
;
855 while (current
&& current
!= route
)
856 current
= current
->next
;
858 assert(current
== route
);
860 /* adjust doubly linked list */
862 route
->prev
->next
= route
->next
;
864 route
->next
->prev
= route
->prev
;
866 if (node
->info
== route
) {
867 if (route
->next
&& route
->next
->rnode
== node
) {
868 node
->info
= route
->next
;
869 SET_FLAG(route
->next
->flag
, OSPF6_ROUTE_BEST
);
873 route_unlock_node(node
); /* to free the original lock */
877 route_unlock_node(node
); /* to free the lookup lock */
879 ospf6_route_table_assert(table
);
881 SET_FLAG(route
->flag
, OSPF6_ROUTE_WAS_REMOVED
);
883 /* Note hook_remove may call ospf6_route_remove */
884 if (table
->hook_remove
)
885 (*table
->hook_remove
)(route
, ospf6
);
887 ospf6_route_unlock(route
);
890 struct ospf6_route
*ospf6_route_head(struct ospf6_route_table
*table
)
892 struct route_node
*node
;
893 struct ospf6_route
*route
;
895 node
= route_top(table
->table
);
899 /* skip to the real existing entry */
900 while (node
&& node
->info
== NULL
)
901 node
= route_next(node
);
905 route_unlock_node(node
);
908 route
= (struct ospf6_route
*)node
->info
;
909 assert(route
->prev
== NULL
);
910 assert(route
->table
== table
);
911 ospf6_route_lock(route
);
913 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
914 zlog_info("%s %p: route head: %p<-[%p]->%p",
915 ospf6_route_table_name(table
), (void *)table
,
916 (void *)route
->prev
, (void *)route
,
917 (void *)route
->next
);
922 struct ospf6_route
*ospf6_route_next(struct ospf6_route
*route
)
924 struct ospf6_route
*next
= route
->next
;
926 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
927 zlog_info("%s %p: route next: %p<-[%p]->%p , route ref count %u",
928 ospf6_route_table_name(route
->table
),
929 (void *)route
->table
, (void *)route
->prev
,
930 (void *)route
, (void *)route
->next
,
933 ospf6_route_unlock(route
);
935 ospf6_route_lock(next
);
940 struct ospf6_route
*ospf6_route_best_next(struct ospf6_route
*route
)
942 struct route_node
*rnode
;
943 struct ospf6_route
*next
;
945 ospf6_route_unlock(route
);
947 rnode
= route
->rnode
;
948 route_lock_node(rnode
);
949 rnode
= route_next(rnode
);
950 while (rnode
&& rnode
->info
== NULL
)
951 rnode
= route_next(rnode
);
954 route_unlock_node(rnode
);
957 next
= (struct ospf6_route
*)rnode
->info
;
958 ospf6_route_lock(next
);
962 struct ospf6_route
*ospf6_route_match_head(struct prefix
*prefix
,
963 struct ospf6_route_table
*table
)
965 struct route_node
*node
;
966 struct ospf6_route
*route
;
968 /* Walk down tree. */
969 node
= table
->table
->top
;
970 while (node
&& node
->p
.prefixlen
< prefix
->prefixlen
971 && prefix_match(&node
->p
, prefix
))
972 node
= node
->link
[prefix_bit(&prefix
->u
.prefix
,
976 route_lock_node(node
);
977 while (node
&& node
->info
== NULL
)
978 node
= route_next(node
);
981 route_unlock_node(node
);
983 if (!prefix_match(prefix
, &node
->p
))
987 ospf6_route_lock(route
);
991 struct ospf6_route
*ospf6_route_match_next(struct prefix
*prefix
,
992 struct ospf6_route
*route
)
994 struct ospf6_route
*next
;
996 next
= ospf6_route_next(route
);
997 if (next
&& !prefix_match(prefix
, &next
->prefix
)) {
998 ospf6_route_unlock(next
);
1005 void ospf6_route_remove_all(struct ospf6_route_table
*table
,
1006 struct ospf6
*ospf6
)
1008 struct ospf6_route
*route
;
1009 for (route
= ospf6_route_head(table
); route
;
1010 route
= ospf6_route_next(route
))
1011 ospf6_route_remove(route
, table
, ospf6
);
1014 struct ospf6_route_table
*ospf6_route_table_create(int s
, int t
)
1016 struct ospf6_route_table
*new;
1017 new = XCALLOC(MTYPE_OSPF6_ROUTE
, sizeof(struct ospf6_route_table
));
1018 new->table
= route_table_init();
1019 new->scope_type
= s
;
1020 new->table_type
= t
;
1024 void ospf6_route_table_delete(struct ospf6_route_table
*table
,
1025 struct ospf6
*ospf6
)
1027 ospf6_route_remove_all(table
, ospf6
);
1028 bf_free(table
->idspace
);
1029 route_table_finish(table
->table
);
1030 XFREE(MTYPE_OSPF6_ROUTE
, table
);
1035 void ospf6_route_show(struct vty
*vty
, struct ospf6_route
*route
)
1038 char destination
[PREFIX2STR_BUFFER
], nexthop
[64];
1040 struct timeval now
, res
;
1041 struct listnode
*node
;
1042 struct ospf6_nexthop
*nh
;
1044 if (om6
->ospf6
== NULL
) {
1045 vty_out(vty
, "OSPFv3 is not running\n");
1050 timersub(&now
, &route
->changed
, &res
);
1051 timerstring(&res
, duration
, sizeof(duration
));
1054 if (route
->type
== OSPF6_DEST_TYPE_LINKSTATE
)
1055 ospf6_linkstate_prefix2str(&route
->prefix
, destination
,
1056 sizeof(destination
));
1057 else if (route
->type
== OSPF6_DEST_TYPE_ROUTER
)
1058 inet_ntop(route
->prefix
.family
, &route
->prefix
.u
.prefix
,
1059 destination
, sizeof(destination
));
1061 prefix2str(&route
->prefix
, destination
, sizeof(destination
));
1064 for (ALL_LIST_ELEMENTS_RO(route
->nh_list
, node
, nh
)) {
1065 struct interface
*ifp
;
1067 inet_ntop(AF_INET6
, &nh
->address
, nexthop
, sizeof(nexthop
));
1068 ifp
= if_lookup_by_index_all_vrf(nh
->ifindex
);
1070 vty_out(vty
, "%c%1s %2s %-30s %-25s %6.*s %s\n",
1071 (ospf6_route_is_best(route
) ? '*' : ' '),
1072 OSPF6_DEST_TYPE_SUBSTR(route
->type
),
1073 OSPF6_PATH_TYPE_SUBSTR(route
->path
.type
),
1074 destination
, nexthop
, IFNAMSIZ
, ifp
->name
,
1078 vty_out(vty
, "%c%1s %2s %-30s %-25s %6.*s %s\n", ' ',
1079 "", "", "", nexthop
, IFNAMSIZ
, ifp
->name
, "");
1083 void ospf6_route_show_detail(struct vty
*vty
, struct ospf6_route
*route
)
1085 char destination
[PREFIX2STR_BUFFER
];
1086 char area_id
[16], id
[16], adv_router
[16], capa
[16], options
[16];
1087 struct timeval now
, res
;
1089 struct listnode
*node
;
1090 struct ospf6_nexthop
*nh
;
1092 if (om6
->ospf6
== NULL
) {
1093 vty_out(vty
, "OSPFv3 is not running\n");
1100 if (route
->type
== OSPF6_DEST_TYPE_LINKSTATE
)
1101 ospf6_linkstate_prefix2str(&route
->prefix
, destination
,
1102 sizeof(destination
));
1103 else if (route
->type
== OSPF6_DEST_TYPE_ROUTER
)
1104 inet_ntop(route
->prefix
.family
, &route
->prefix
.u
.prefix
,
1105 destination
, sizeof(destination
));
1107 prefix2str(&route
->prefix
, destination
, sizeof(destination
));
1108 vty_out(vty
, "Destination: %s\n", destination
);
1110 /* destination type */
1111 vty_out(vty
, "Destination type: %s\n",
1112 OSPF6_DEST_TYPE_NAME(route
->type
));
1115 timersub(&now
, &route
->installed
, &res
);
1116 timerstring(&res
, duration
, sizeof(duration
));
1117 vty_out(vty
, "Installed Time: %s ago\n", duration
);
1119 timersub(&now
, &route
->changed
, &res
);
1120 timerstring(&res
, duration
, sizeof(duration
));
1121 vty_out(vty
, " Changed Time: %s ago\n", duration
);
1123 /* Debugging info */
1124 vty_out(vty
, "Lock: %d Flags: %s%s%s%s\n", route
->lock
,
1125 (CHECK_FLAG(route
->flag
, OSPF6_ROUTE_BEST
) ? "B" : "-"),
1126 (CHECK_FLAG(route
->flag
, OSPF6_ROUTE_ADD
) ? "A" : "-"),
1127 (CHECK_FLAG(route
->flag
, OSPF6_ROUTE_REMOVE
) ? "R" : "-"),
1128 (CHECK_FLAG(route
->flag
, OSPF6_ROUTE_CHANGE
) ? "C" : "-"));
1129 vty_out(vty
, "Memory: prev: %p this: %p next: %p\n",
1130 (void *)route
->prev
, (void *)route
, (void *)route
->next
);
1135 inet_ntop(AF_INET
, &route
->path
.area_id
, area_id
, sizeof(area_id
));
1136 vty_out(vty
, "Associated Area: %s\n", area_id
);
1139 vty_out(vty
, "Path Type: %s\n", OSPF6_PATH_TYPE_NAME(route
->path
.type
));
1142 inet_ntop(AF_INET
, &route
->path
.origin
.id
, id
, sizeof(id
));
1143 inet_ntop(AF_INET
, &route
->path
.origin
.adv_router
, adv_router
,
1144 sizeof(adv_router
));
1145 vty_out(vty
, "LS Origin: %s Id: %s Adv: %s\n",
1146 ospf6_lstype_name(route
->path
.origin
.type
), id
, adv_router
);
1149 ospf6_options_printbuf(route
->path
.options
, options
, sizeof(options
));
1150 vty_out(vty
, "Options: %s\n", options
);
1153 ospf6_capability_printbuf(route
->path
.router_bits
, capa
, sizeof(capa
));
1154 vty_out(vty
, "Router Bits: %s\n", capa
);
1156 /* Prefix Options */
1157 vty_out(vty
, "Prefix Options: xxx\n");
1160 vty_out(vty
, "Metric Type: %d\n", route
->path
.metric_type
);
1161 vty_out(vty
, "Metric: %d (%d)\n", route
->path
.cost
,
1162 route
->path
.u
.cost_e2
);
1164 vty_out(vty
, "Paths count: %u\n", route
->paths
->count
);
1165 vty_out(vty
, "Nexthop count: %u\n", route
->nh_list
->count
);
1167 vty_out(vty
, "Nexthop:\n");
1168 for (ALL_LIST_ELEMENTS_RO(route
->nh_list
, node
, nh
)) {
1169 struct interface
*ifp
;
1172 ifp
= if_lookup_by_index_all_vrf(nh
->ifindex
);
1173 vty_out(vty
, " %pI6 %.*s\n", &nh
->address
, IFNAMSIZ
, ifp
->name
);
1178 static void ospf6_route_show_table_summary(struct vty
*vty
,
1179 struct ospf6_route_table
*table
)
1181 struct ospf6_route
*route
, *prev
= NULL
;
1182 int i
, pathtype
[OSPF6_PATH_TYPE_MAX
];
1183 unsigned int number
= 0;
1184 int nh_count
= 0, nhinval
= 0, ecmp
= 0;
1185 int alternative
= 0, destination
= 0;
1187 for (i
= 0; i
< OSPF6_PATH_TYPE_MAX
; i
++)
1190 for (route
= ospf6_route_head(table
); route
;
1191 route
= ospf6_route_next(route
)) {
1192 if (prev
== NULL
|| !ospf6_route_is_same(prev
, route
))
1196 nh_count
= ospf6_num_nexthops(route
->nh_list
);
1199 else if (nh_count
> 1)
1201 pathtype
[route
->path
.type
]++;
1207 assert(number
== table
->count
);
1209 vty_out(vty
, "Number of OSPFv3 routes: %d\n", number
);
1210 vty_out(vty
, "Number of Destination: %d\n", destination
);
1211 vty_out(vty
, "Number of Alternative routes: %d\n", alternative
);
1212 vty_out(vty
, "Number of Equal Cost Multi Path: %d\n", ecmp
);
1213 for (i
= OSPF6_PATH_TYPE_INTRA
; i
<= OSPF6_PATH_TYPE_EXTERNAL2
; i
++) {
1214 vty_out(vty
, "Number of %s routes: %d\n",
1215 OSPF6_PATH_TYPE_NAME(i
), pathtype
[i
]);
1219 static void ospf6_route_show_table_prefix(struct vty
*vty
,
1220 struct prefix
*prefix
,
1221 struct ospf6_route_table
*table
)
1223 struct ospf6_route
*route
;
1225 route
= ospf6_route_lookup(prefix
, table
);
1229 ospf6_route_lock(route
);
1230 while (route
&& ospf6_route_is_prefix(prefix
, route
)) {
1231 /* Specifying a prefix will always display details */
1232 ospf6_route_show_detail(vty
, route
);
1233 route
= ospf6_route_next(route
);
1236 ospf6_route_unlock(route
);
1239 static void ospf6_route_show_table_address(struct vty
*vty
,
1240 struct prefix
*prefix
,
1241 struct ospf6_route_table
*table
)
1243 struct ospf6_route
*route
;
1245 route
= ospf6_route_lookup_bestmatch(prefix
, table
);
1249 prefix
= &route
->prefix
;
1250 ospf6_route_lock(route
);
1251 while (route
&& ospf6_route_is_prefix(prefix
, route
)) {
1252 /* Specifying a prefix will always display details */
1253 ospf6_route_show_detail(vty
, route
);
1254 route
= ospf6_route_next(route
);
1257 ospf6_route_unlock(route
);
1260 static void ospf6_route_show_table_match(struct vty
*vty
, int detail
,
1261 struct prefix
*prefix
,
1262 struct ospf6_route_table
*table
)
1264 struct ospf6_route
*route
;
1265 assert(prefix
->family
);
1267 route
= ospf6_route_match_head(prefix
, table
);
1270 ospf6_route_show_detail(vty
, route
);
1272 ospf6_route_show(vty
, route
);
1273 route
= ospf6_route_match_next(prefix
, route
);
1277 static void ospf6_route_show_table_type(struct vty
*vty
, int detail
,
1279 struct ospf6_route_table
*table
)
1281 struct ospf6_route
*route
;
1283 route
= ospf6_route_head(table
);
1285 if (route
->path
.type
== type
) {
1287 ospf6_route_show_detail(vty
, route
);
1289 ospf6_route_show(vty
, route
);
1291 route
= ospf6_route_next(route
);
1295 static void ospf6_route_show_table(struct vty
*vty
, int detail
,
1296 struct ospf6_route_table
*table
)
1298 struct ospf6_route
*route
;
1300 route
= ospf6_route_head(table
);
1303 ospf6_route_show_detail(vty
, route
);
1305 ospf6_route_show(vty
, route
);
1306 route
= ospf6_route_next(route
);
1310 int ospf6_route_table_show(struct vty
*vty
, int argc_start
, int argc
,
1311 struct cmd_token
**argv
,
1312 struct ospf6_route_table
*table
)
1320 struct prefix prefix
;
1323 memset(&prefix
, 0, sizeof(struct prefix
));
1325 for (i
= argc_start
; i
< argc
; i
++) {
1326 if (strmatch(argv
[i
]->text
, "summary")) {
1331 if (strmatch(argv
[i
]->text
, "intra-area")) {
1332 type
= OSPF6_PATH_TYPE_INTRA
;
1336 if (strmatch(argv
[i
]->text
, "inter-area")) {
1337 type
= OSPF6_PATH_TYPE_INTER
;
1341 if (strmatch(argv
[i
]->text
, "external-1")) {
1342 type
= OSPF6_PATH_TYPE_EXTERNAL1
;
1346 if (strmatch(argv
[i
]->text
, "external-2")) {
1347 type
= OSPF6_PATH_TYPE_EXTERNAL2
;
1351 if (strmatch(argv
[i
]->text
, "detail")) {
1356 if (strmatch(argv
[i
]->text
, "match")) {
1361 ret
= str2prefix(argv
[i
]->arg
, &prefix
);
1362 if (ret
== 1 && prefix
.family
== AF_INET6
) {
1364 if (strchr(argv
[i
]->arg
, '/'))
1369 vty_out(vty
, "Malformed argument: %s\n", argv
[i
]->arg
);
1373 /* Give summary of this route table */
1375 ospf6_route_show_table_summary(vty
, table
);
1379 /* Give exact prefix-match route */
1380 if (isprefix
&& !match
) {
1381 /* If exact address, give best matching route */
1383 ospf6_route_show_table_address(vty
, &prefix
, table
);
1385 ospf6_route_show_table_prefix(vty
, &prefix
, table
);
1391 ospf6_route_show_table_match(vty
, detail
, &prefix
, table
);
1393 ospf6_route_show_table_type(vty
, detail
, type
, table
);
1395 ospf6_route_show_table(vty
, detail
, table
);
1400 static void ospf6_linkstate_show_header(struct vty
*vty
)
1402 vty_out(vty
, "%-7s %-15s %-15s %-8s %-14s %s\n", "Type", "Router-ID",
1403 "Net-ID", "Rtr-Bits", "Options", "Cost");
1406 static void ospf6_linkstate_show(struct vty
*vty
, struct ospf6_route
*route
)
1408 uint32_t router
, id
;
1409 char routername
[16], idname
[16], rbits
[16], options
[16];
1411 router
= ospf6_linkstate_prefix_adv_router(&route
->prefix
);
1412 inet_ntop(AF_INET
, &router
, routername
, sizeof(routername
));
1413 id
= ospf6_linkstate_prefix_id(&route
->prefix
);
1414 inet_ntop(AF_INET
, &id
, idname
, sizeof(idname
));
1416 ospf6_capability_printbuf(route
->path
.router_bits
, rbits
,
1418 ospf6_options_printbuf(route
->path
.options
, options
, sizeof(options
));
1421 vty_out(vty
, "%-7s %-15s %-15s %-8s %-14s %lu\n", "Network",
1422 routername
, idname
, rbits
, options
,
1423 (unsigned long)route
->path
.cost
);
1425 vty_out(vty
, "%-7s %-15s %-15s %-8s %-14s %lu\n", "Router",
1426 routername
, idname
, rbits
, options
,
1427 (unsigned long)route
->path
.cost
);
1431 static void ospf6_linkstate_show_table_exact(struct vty
*vty
,
1432 struct prefix
*prefix
,
1433 struct ospf6_route_table
*table
)
1435 struct ospf6_route
*route
;
1437 route
= ospf6_route_lookup(prefix
, table
);
1441 ospf6_route_lock(route
);
1442 while (route
&& ospf6_route_is_prefix(prefix
, route
)) {
1443 /* Specifying a prefix will always display details */
1444 ospf6_route_show_detail(vty
, route
);
1445 route
= ospf6_route_next(route
);
1448 ospf6_route_unlock(route
);
1451 static void ospf6_linkstate_show_table(struct vty
*vty
, int detail
,
1452 struct ospf6_route_table
*table
)
1454 struct ospf6_route
*route
;
1457 ospf6_linkstate_show_header(vty
);
1459 route
= ospf6_route_head(table
);
1462 ospf6_route_show_detail(vty
, route
);
1464 ospf6_linkstate_show(vty
, route
);
1465 route
= ospf6_route_next(route
);
1469 int ospf6_linkstate_table_show(struct vty
*vty
, int idx_ipv4
, int argc
,
1470 struct cmd_token
**argv
,
1471 struct ospf6_route_table
*table
)
1477 struct prefix router
, id
, prefix
;
1479 memset(&router
, 0, sizeof(struct prefix
));
1480 memset(&id
, 0, sizeof(struct prefix
));
1481 memset(&prefix
, 0, sizeof(struct prefix
));
1483 for (i
= idx_ipv4
; i
< argc
; i
++) {
1484 if (strmatch(argv
[i
]->text
, "detail")) {
1490 ret
= str2prefix(argv
[i
]->arg
, &router
);
1491 if (ret
== 1 && router
.family
== AF_INET
) {
1495 vty_out(vty
, "Malformed argument: %s\n", argv
[i
]->arg
);
1500 ret
= str2prefix(argv
[i
]->arg
, &id
);
1501 if (ret
== 1 && id
.family
== AF_INET
) {
1505 vty_out(vty
, "Malformed argument: %s\n", argv
[i
]->arg
);
1509 vty_out(vty
, "Malformed argument: %s\n", argv
[i
]->arg
);
1514 ospf6_linkstate_prefix(router
.u
.prefix4
.s_addr
,
1515 id
.u
.prefix4
.s_addr
, &prefix
);
1518 ospf6_linkstate_show_table_exact(vty
, &prefix
, table
);
1520 ospf6_linkstate_show_table(vty
, detail
, table
);
1526 void ospf6_brouter_show_header(struct vty
*vty
)
1528 vty_out(vty
, "%-15s %-8s %-14s %-10s %-15s\n", "Router-ID", "Rtr-Bits",
1529 "Options", "Path-Type", "Area");
1532 void ospf6_brouter_show(struct vty
*vty
, struct ospf6_route
*route
)
1534 uint32_t adv_router
;
1535 char adv
[16], rbits
[16], options
[16], area
[16];
1537 adv_router
= ospf6_linkstate_prefix_adv_router(&route
->prefix
);
1538 inet_ntop(AF_INET
, &adv_router
, adv
, sizeof(adv
));
1539 ospf6_capability_printbuf(route
->path
.router_bits
, rbits
,
1541 ospf6_options_printbuf(route
->path
.options
, options
, sizeof(options
));
1542 inet_ntop(AF_INET
, &route
->path
.area_id
, area
, sizeof(area
));
1544 /* vty_out (vty, "%-15s %-8s %-14s %-10s %-15s\n",
1545 "Router-ID", "Rtr-Bits", "Options", "Path-Type", "Area"); */
1546 vty_out(vty
, "%-15s %-8s %-14s %-10s %-15s\n", adv
, rbits
, options
,
1547 OSPF6_PATH_TYPE_NAME(route
->path
.type
), area
);
1550 DEFUN (debug_ospf6_route
,
1551 debug_ospf6_route_cmd
,
1552 "debug ospf6 route <table|intra-area|inter-area|memory>",
1556 "Debug route table calculation\n"
1557 "Debug intra-area route calculation\n"
1558 "Debug inter-area route calculation\n"
1559 "Debug route memory use\n"
1563 unsigned char level
= 0;
1565 if (!strcmp(argv
[idx_type
]->text
, "table"))
1566 level
= OSPF6_DEBUG_ROUTE_TABLE
;
1567 else if (!strcmp(argv
[idx_type
]->text
, "intra-area"))
1568 level
= OSPF6_DEBUG_ROUTE_INTRA
;
1569 else if (!strcmp(argv
[idx_type
]->text
, "inter-area"))
1570 level
= OSPF6_DEBUG_ROUTE_INTER
;
1571 else if (!strcmp(argv
[idx_type
]->text
, "memory"))
1572 level
= OSPF6_DEBUG_ROUTE_MEMORY
;
1573 OSPF6_DEBUG_ROUTE_ON(level
);
1577 DEFUN (no_debug_ospf6_route
,
1578 no_debug_ospf6_route_cmd
,
1579 "no debug ospf6 route <table|intra-area|inter-area|memory>",
1584 "Debug route table calculation\n"
1585 "Debug intra-area route calculation\n"
1586 "Debug inter-area route calculation\n"
1587 "Debug route memory use\n")
1590 unsigned char level
= 0;
1592 if (!strcmp(argv
[idx_type
]->text
, "table"))
1593 level
= OSPF6_DEBUG_ROUTE_TABLE
;
1594 else if (!strcmp(argv
[idx_type
]->text
, "intra-area"))
1595 level
= OSPF6_DEBUG_ROUTE_INTRA
;
1596 else if (!strcmp(argv
[idx_type
]->text
, "inter-area"))
1597 level
= OSPF6_DEBUG_ROUTE_INTER
;
1598 else if (!strcmp(argv
[idx_type
]->text
, "memory"))
1599 level
= OSPF6_DEBUG_ROUTE_MEMORY
;
1600 OSPF6_DEBUG_ROUTE_OFF(level
);
1604 int config_write_ospf6_debug_route(struct vty
*vty
)
1606 if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
1607 vty_out(vty
, "debug ospf6 route table\n");
1608 if (IS_OSPF6_DEBUG_ROUTE(INTRA
))
1609 vty_out(vty
, "debug ospf6 route intra-area\n");
1610 if (IS_OSPF6_DEBUG_ROUTE(INTER
))
1611 vty_out(vty
, "debug ospf6 route inter-area\n");
1612 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
1613 vty_out(vty
, "debug ospf6 route memory\n");
1618 void install_element_ospf6_debug_route(void)
1620 install_element(ENABLE_NODE
, &debug_ospf6_route_cmd
);
1621 install_element(ENABLE_NODE
, &no_debug_ospf6_route_cmd
);
1622 install_element(CONFIG_NODE
, &debug_ospf6_route_cmd
);
1623 install_element(CONFIG_NODE
, &no_debug_ospf6_route_cmd
);