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
;
304 for (ALL_LIST_ELEMENTS_RO(route
->nh_list
, node
, nh
)) {
305 if (IS_OSPF6_DEBUG_ZEBRA(SEND
)) {
307 inet_ntop(AF_INET6
, &nh
->address
, buf
,
309 ifname
= ifindex2ifname(nh
->ifindex
,
311 zlog_debug(" nexthop: %s%%%.*s(%d)", buf
,
312 IFNAMSIZ
, ifname
, nh
->ifindex
);
317 nexthops
[i
].vrf_id
= ospf6
->vrf_id
;
318 nexthops
[i
].ifindex
= nh
->ifindex
;
319 if (!IN6_IS_ADDR_UNSPECIFIED(&nh
->address
)) {
320 nexthops
[i
].gate
.ipv6
= nh
->address
;
321 nexthops
[i
].type
= NEXTHOP_TYPE_IPV6_IFINDEX
;
323 nexthops
[i
].type
= NEXTHOP_TYPE_IFINDEX
;
329 int ospf6_route_get_first_nh_index(struct ospf6_route
*route
)
331 struct ospf6_nexthop
*nh
;
334 nh
= listnode_head(route
->nh_list
);
342 int ospf6_nexthop_cmp(struct ospf6_nexthop
*a
, struct ospf6_nexthop
*b
)
344 if (a
->ifindex
< b
->ifindex
)
346 else if (a
->ifindex
> b
->ifindex
)
349 return memcmp(&a
->address
, &b
->address
,
350 sizeof(struct in6_addr
));
355 static int ospf6_path_cmp(struct ospf6_path
*a
, struct ospf6_path
*b
)
357 if (a
->origin
.adv_router
< b
->origin
.adv_router
)
359 else if (a
->origin
.adv_router
> b
->origin
.adv_router
)
365 void ospf6_path_free(struct ospf6_path
*op
)
368 list_delete(&op
->nh_list
);
369 XFREE(MTYPE_OSPF6_PATH
, op
);
372 struct ospf6_path
*ospf6_path_dup(struct ospf6_path
*path
)
374 struct ospf6_path
*new;
376 new = XCALLOC(MTYPE_OSPF6_PATH
, sizeof(struct ospf6_path
));
377 memcpy(new, path
, sizeof(struct ospf6_path
));
378 new->nh_list
= list_new();
379 new->nh_list
->cmp
= (int (*)(void *, void *))ospf6_nexthop_cmp
;
380 new->nh_list
->del
= (void (*)(void *))ospf6_nexthop_delete
;
385 void ospf6_copy_paths(struct list
*dst
, struct list
*src
)
387 struct ospf6_path
*path_new
, *path
;
388 struct listnode
*node
;
391 for (ALL_LIST_ELEMENTS_RO(src
, node
, path
)) {
392 path_new
= ospf6_path_dup(path
);
393 ospf6_copy_nexthops(path_new
->nh_list
, path
->nh_list
);
394 listnode_add_sort(dst
, path_new
);
399 struct ospf6_route
*ospf6_route_create(void)
401 struct ospf6_route
*route
;
402 route
= XCALLOC(MTYPE_OSPF6_ROUTE
, sizeof(struct ospf6_route
));
403 route
->nh_list
= list_new();
404 route
->nh_list
->cmp
= (int (*)(void *, void *))ospf6_nexthop_cmp
;
405 route
->nh_list
->del
= (void (*)(void *))ospf6_nexthop_delete
;
406 route
->paths
= list_new();
407 route
->paths
->cmp
= (int (*)(void *, void *))ospf6_path_cmp
;
408 route
->paths
->del
= (void (*)(void *))ospf6_path_free
;
412 void ospf6_route_delete(struct ospf6_route
*route
)
416 list_delete(&route
->nh_list
);
418 list_delete(&route
->paths
);
419 XFREE(MTYPE_OSPF6_ROUTE
, route
);
423 struct ospf6_route
*ospf6_route_copy(struct ospf6_route
*route
)
425 struct ospf6_route
*new;
427 new = ospf6_route_create();
428 new->type
= route
->type
;
429 memcpy(&new->prefix
, &route
->prefix
, sizeof(struct prefix
));
430 new->installed
= route
->installed
;
431 new->changed
= route
->changed
;
432 new->flag
= route
->flag
;
433 new->route_option
= route
->route_option
;
434 new->linkstate_id
= route
->linkstate_id
;
435 new->path
= route
->path
;
436 ospf6_copy_nexthops(new->nh_list
, route
->nh_list
);
437 ospf6_copy_paths(new->paths
, route
->paths
);
446 void ospf6_route_lock(struct ospf6_route
*route
)
451 void ospf6_route_unlock(struct ospf6_route
*route
)
453 assert(route
->lock
> 0);
455 if (route
->lock
== 0) {
456 /* Can't detach from the table until here
457 because ospf6_route_next () will use
458 the 'route->table' pointer for logging */
460 ospf6_route_delete(route
);
464 /* Route compare function. If ra is more preferred, it returns
465 less than 0. If rb is more preferred returns greater than 0.
466 Otherwise (neither one is preferred), returns 0 */
467 int ospf6_route_cmp(struct ospf6_route
*ra
, struct ospf6_route
*rb
)
469 assert(ospf6_route_is_same(ra
, rb
));
470 assert(OSPF6_PATH_TYPE_NONE
< ra
->path
.type
471 && ra
->path
.type
< OSPF6_PATH_TYPE_MAX
);
472 assert(OSPF6_PATH_TYPE_NONE
< rb
->path
.type
473 && rb
->path
.type
< OSPF6_PATH_TYPE_MAX
);
475 if (ra
->type
!= rb
->type
)
476 return (ra
->type
- rb
->type
);
478 if (ra
->path
.type
!= rb
->path
.type
)
479 return (ra
->path
.type
- rb
->path
.type
);
481 if (ra
->path
.type
== OSPF6_PATH_TYPE_EXTERNAL2
) {
482 if (ra
->path
.u
.cost_e2
!= rb
->path
.u
.cost_e2
)
483 return (ra
->path
.u
.cost_e2
- rb
->path
.u
.cost_e2
);
485 return (ra
->path
.cost
- rb
->path
.cost
);
487 if (ra
->path
.cost
!= rb
->path
.cost
)
488 return (ra
->path
.cost
- rb
->path
.cost
);
491 if (ra
->path
.area_id
!= rb
->path
.area_id
)
492 return (ntohl(ra
->path
.area_id
) - ntohl(rb
->path
.area_id
));
497 struct ospf6_route
*ospf6_route_lookup(struct prefix
*prefix
,
498 struct ospf6_route_table
*table
)
500 struct route_node
*node
;
501 struct ospf6_route
*route
;
503 node
= route_node_lookup(table
->table
, prefix
);
507 route
= (struct ospf6_route
*)node
->info
;
508 route_unlock_node(node
); /* to free the lookup lock */
513 ospf6_route_lookup_identical(struct ospf6_route
*route
,
514 struct ospf6_route_table
*table
)
516 struct ospf6_route
*target
;
518 for (target
= ospf6_route_lookup(&route
->prefix
, table
); target
;
519 target
= target
->next
) {
520 if (target
->type
== route
->type
521 && (memcmp(&target
->prefix
, &route
->prefix
,
522 sizeof(struct prefix
))
524 && target
->path
.type
== route
->path
.type
525 && target
->path
.cost
== route
->path
.cost
526 && target
->path
.u
.cost_e2
== route
->path
.u
.cost_e2
527 && ospf6_route_cmp_nexthops(target
, route
) == 0)
534 ospf6_route_lookup_bestmatch(struct prefix
*prefix
,
535 struct ospf6_route_table
*table
)
537 struct route_node
*node
;
538 struct ospf6_route
*route
;
540 node
= route_node_match(table
->table
, prefix
);
543 route_unlock_node(node
);
545 route
= (struct ospf6_route
*)node
->info
;
550 static void route_table_assert(struct ospf6_route_table
*table
)
552 struct ospf6_route
*prev
, *r
, *next
;
553 char buf
[PREFIX2STR_BUFFER
];
554 unsigned int link_error
= 0, num
= 0;
556 r
= ospf6_route_head(table
);
562 next
= ospf6_route_next(r
);
571 for (r
= ospf6_route_head(table
); r
; r
= ospf6_route_next(r
))
574 if (link_error
== 0 && num
== table
->count
)
577 flog_err(EC_LIB_DEVELOPMENT
, "PANIC !!");
578 flog_err(EC_LIB_DEVELOPMENT
,
579 "Something has gone wrong with ospf6_route_table[%p]", table
);
580 zlog_debug("table count = %d, real number = %d", table
->count
, num
);
581 zlog_debug("DUMP START");
582 for (r
= ospf6_route_head(table
); r
; r
= ospf6_route_next(r
)) {
583 prefix2str(&r
->prefix
, buf
, sizeof(buf
));
584 zlog_info("%p<-[%p]->%p : %s", r
->prev
, r
, r
->next
, buf
);
586 zlog_debug("DUMP END");
588 assert(link_error
== 0 && num
== table
->count
);
590 #define ospf6_route_table_assert(t) (route_table_assert (t))
592 #define ospf6_route_table_assert(t) ((void) 0)
595 struct ospf6_route
*ospf6_route_add(struct ospf6_route
*route
,
596 struct ospf6_route_table
*table
)
598 struct route_node
*node
, *nextnode
, *prevnode
;
599 struct ospf6_route
*current
= NULL
;
600 struct ospf6_route
*prev
= NULL
, *old
= NULL
, *next
= NULL
;
601 char buf
[PREFIX2STR_BUFFER
];
604 assert(route
->rnode
== NULL
);
605 assert(route
->lock
== 0);
606 assert(route
->next
== NULL
);
607 assert(route
->prev
== NULL
);
609 if (route
->type
== OSPF6_DEST_TYPE_LINKSTATE
)
610 ospf6_linkstate_prefix2str(&route
->prefix
, buf
, sizeof(buf
));
612 prefix2str(&route
->prefix
, buf
, sizeof(buf
));
614 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
615 zlog_debug("%s %p: route add %p: %s paths %u nh %u",
616 ospf6_route_table_name(table
), (void *)table
,
617 (void *)route
, buf
, listcount(route
->paths
),
618 listcount(route
->nh_list
));
619 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
620 zlog_debug("%s: route add: %s", ospf6_route_table_name(table
),
625 node
= route_node_get(table
->table
, &route
->prefix
);
628 /* find place to insert */
629 for (current
= node
->info
; current
; current
= current
->next
) {
630 if (!ospf6_route_is_same(current
, route
))
632 else if (current
->type
!= route
->type
)
634 else if (ospf6_route_is_same_origin(current
, route
))
636 else if (ospf6_route_cmp(current
, route
) > 0)
646 /* if route does not actually change, return unchanged */
647 if (ospf6_route_is_identical(old
, route
)) {
648 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
650 "%s %p: route add %p: needless update of %p old cost %u",
651 ospf6_route_table_name(table
),
652 (void *)table
, (void *)route
,
653 (void *)old
, old
->path
.cost
);
654 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
655 zlog_debug("%s: route add: needless update",
656 ospf6_route_table_name(table
));
658 ospf6_route_delete(route
);
659 SET_FLAG(old
->flag
, OSPF6_ROUTE_ADD
);
660 ospf6_route_table_assert(table
);
662 /* to free the lookup lock */
663 route_unlock_node(node
);
667 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
669 "%s %p: route add %p cost %u paths %u nh %u: update of %p cost %u paths %u nh %u",
670 ospf6_route_table_name(table
), (void *)table
,
671 (void *)route
, route
->path
.cost
,
672 listcount(route
->paths
),
673 listcount(route
->nh_list
), (void *)old
,
674 old
->path
.cost
, listcount(old
->paths
),
675 listcount(old
->nh_list
));
676 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
677 zlog_debug("%s: route add: update",
678 ospf6_route_table_name(table
));
680 /* replace old one if exists */
681 if (node
->info
== old
) {
683 SET_FLAG(route
->flag
, OSPF6_ROUTE_BEST
);
687 old
->prev
->next
= route
;
688 route
->prev
= old
->prev
;
690 old
->next
->prev
= route
;
691 route
->next
= old
->next
;
693 route
->installed
= old
->installed
;
694 route
->changed
= now
;
695 assert(route
->table
== NULL
);
696 route
->table
= table
;
698 ospf6_route_unlock(old
); /* will be deleted later */
699 ospf6_route_lock(route
);
701 SET_FLAG(route
->flag
, OSPF6_ROUTE_CHANGE
);
702 ospf6_route_table_assert(table
);
705 (*table
->hook_add
)(route
);
710 /* insert if previous or next node found */
712 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
714 "%s %p: route add %p cost %u: another path: prev %p, next %p node ref %u",
715 ospf6_route_table_name(table
), (void *)table
,
716 (void *)route
, route
->path
.cost
, (void *)prev
,
717 (void *)next
, node
->lock
);
718 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
719 zlog_debug("%s: route add cost %u: another path found",
720 ospf6_route_table_name(table
),
735 if (node
->info
== next
) {
736 assert(next
&& next
->rnode
== node
);
738 UNSET_FLAG(next
->flag
, OSPF6_ROUTE_BEST
);
739 SET_FLAG(route
->flag
, OSPF6_ROUTE_BEST
);
740 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
742 "%s %p: route add %p cost %u: replacing previous best: %p cost %u",
743 ospf6_route_table_name(table
),
744 (void *)table
, (void *)route
,
746 (void *)next
, next
->path
.cost
);
749 route
->installed
= now
;
750 route
->changed
= now
;
751 assert(route
->table
== NULL
);
752 route
->table
= table
;
754 ospf6_route_lock(route
);
756 ospf6_route_table_assert(table
);
758 SET_FLAG(route
->flag
, OSPF6_ROUTE_ADD
);
760 (*table
->hook_add
)(route
);
765 /* Else, this is the brand new route regarding to the prefix */
766 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
767 zlog_debug("%s %p: route add %p %s cost %u: brand new route",
768 ospf6_route_table_name(table
), (void *)table
,
769 (void *)route
, buf
, route
->path
.cost
);
770 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
771 zlog_debug("%s: route add: brand new route",
772 ospf6_route_table_name(table
));
774 assert(node
->info
== NULL
);
776 SET_FLAG(route
->flag
, OSPF6_ROUTE_BEST
);
777 ospf6_route_lock(route
);
778 route
->installed
= now
;
779 route
->changed
= now
;
780 assert(route
->table
== NULL
);
781 route
->table
= table
;
783 /* lookup real existing next route */
785 route_lock_node(nextnode
);
787 nextnode
= route_next(nextnode
);
788 } while (nextnode
&& nextnode
->info
== NULL
);
791 if (nextnode
== NULL
)
794 route_unlock_node(nextnode
);
796 next
= nextnode
->info
;
801 /* lookup real existing prev route */
803 route_lock_node(prevnode
);
805 prevnode
= route_prev(prevnode
);
806 } while (prevnode
&& prevnode
->info
== NULL
);
809 if (prevnode
== NULL
)
812 route_unlock_node(prevnode
);
814 prev
= prevnode
->info
;
815 while (prev
->next
&& ospf6_route_is_same(prev
, prev
->next
))
822 ospf6_route_table_assert(table
);
824 SET_FLAG(route
->flag
, OSPF6_ROUTE_ADD
);
826 (*table
->hook_add
)(route
);
831 void ospf6_route_remove(struct ospf6_route
*route
,
832 struct ospf6_route_table
*table
)
834 struct route_node
*node
;
835 struct ospf6_route
*current
;
836 char buf
[PREFIX2STR_BUFFER
];
838 if (route
->type
== OSPF6_DEST_TYPE_LINKSTATE
)
839 ospf6_linkstate_prefix2str(&route
->prefix
, buf
, sizeof(buf
));
841 prefix2str(&route
->prefix
, buf
, sizeof(buf
));
843 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
844 zlog_debug("%s %p: route remove %p: %s cost %u refcount %u",
845 ospf6_route_table_name(table
), (void *)table
,
846 (void *)route
, buf
, route
->path
.cost
, route
->lock
);
847 else if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
848 zlog_debug("%s: route remove: %s",
849 ospf6_route_table_name(table
), buf
);
851 node
= route_node_lookup(table
->table
, &route
->prefix
);
854 /* find the route to remove, making sure that the route pointer
855 is from the route table. */
856 current
= node
->info
;
857 while (current
&& current
!= route
)
858 current
= current
->next
;
860 assert(current
== route
);
862 /* adjust doubly linked list */
864 route
->prev
->next
= route
->next
;
866 route
->next
->prev
= route
->prev
;
868 if (node
->info
== route
) {
869 if (route
->next
&& route
->next
->rnode
== node
) {
870 node
->info
= route
->next
;
871 SET_FLAG(route
->next
->flag
, OSPF6_ROUTE_BEST
);
875 route_unlock_node(node
); /* to free the original lock */
879 route_unlock_node(node
); /* to free the lookup lock */
881 ospf6_route_table_assert(table
);
883 SET_FLAG(route
->flag
, OSPF6_ROUTE_WAS_REMOVED
);
885 /* Note hook_remove may call ospf6_route_remove */
886 if (table
->hook_remove
)
887 (*table
->hook_remove
)(route
);
889 ospf6_route_unlock(route
);
892 struct ospf6_route
*ospf6_route_head(struct ospf6_route_table
*table
)
894 struct route_node
*node
;
895 struct ospf6_route
*route
;
897 node
= route_top(table
->table
);
901 /* skip to the real existing entry */
902 while (node
&& node
->info
== NULL
)
903 node
= route_next(node
);
907 route_unlock_node(node
);
910 route
= (struct ospf6_route
*)node
->info
;
911 assert(route
->prev
== NULL
);
912 assert(route
->table
== table
);
913 ospf6_route_lock(route
);
915 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
916 zlog_info("%s %p: route head: %p<-[%p]->%p",
917 ospf6_route_table_name(table
), (void *)table
,
918 (void *)route
->prev
, (void *)route
,
919 (void *)route
->next
);
924 struct ospf6_route
*ospf6_route_next(struct ospf6_route
*route
)
926 struct ospf6_route
*next
= route
->next
;
928 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
929 zlog_info("%s %p: route next: %p<-[%p]->%p , route ref count %u",
930 ospf6_route_table_name(route
->table
),
931 (void *)route
->table
, (void *)route
->prev
,
932 (void *)route
, (void *)route
->next
,
935 ospf6_route_unlock(route
);
937 ospf6_route_lock(next
);
942 struct ospf6_route
*ospf6_route_best_next(struct ospf6_route
*route
)
944 struct route_node
*rnode
;
945 struct ospf6_route
*next
;
947 ospf6_route_unlock(route
);
949 rnode
= route
->rnode
;
950 route_lock_node(rnode
);
951 rnode
= route_next(rnode
);
952 while (rnode
&& rnode
->info
== NULL
)
953 rnode
= route_next(rnode
);
956 route_unlock_node(rnode
);
959 next
= (struct ospf6_route
*)rnode
->info
;
960 ospf6_route_lock(next
);
964 struct ospf6_route
*ospf6_route_match_head(struct prefix
*prefix
,
965 struct ospf6_route_table
*table
)
967 struct route_node
*node
;
968 struct ospf6_route
*route
;
970 /* Walk down tree. */
971 node
= table
->table
->top
;
972 while (node
&& node
->p
.prefixlen
< prefix
->prefixlen
973 && prefix_match(&node
->p
, prefix
))
974 node
= node
->link
[prefix_bit(&prefix
->u
.prefix
,
978 route_lock_node(node
);
979 while (node
&& node
->info
== NULL
)
980 node
= route_next(node
);
983 route_unlock_node(node
);
985 if (!prefix_match(prefix
, &node
->p
))
989 ospf6_route_lock(route
);
993 struct ospf6_route
*ospf6_route_match_next(struct prefix
*prefix
,
994 struct ospf6_route
*route
)
996 struct ospf6_route
*next
;
998 next
= ospf6_route_next(route
);
999 if (next
&& !prefix_match(prefix
, &next
->prefix
)) {
1000 ospf6_route_unlock(next
);
1007 void ospf6_route_remove_all(struct ospf6_route_table
*table
)
1009 struct ospf6_route
*route
;
1010 for (route
= ospf6_route_head(table
); route
;
1011 route
= ospf6_route_next(route
))
1012 ospf6_route_remove(route
, table
);
1015 struct ospf6_route_table
*ospf6_route_table_create(int s
, int t
)
1017 struct ospf6_route_table
*new;
1018 new = XCALLOC(MTYPE_OSPF6_ROUTE
, sizeof(struct ospf6_route_table
));
1019 new->table
= route_table_init();
1020 new->scope_type
= s
;
1021 new->table_type
= t
;
1025 void ospf6_route_table_delete(struct ospf6_route_table
*table
)
1027 ospf6_route_remove_all(table
);
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];
1041 struct timeval now
, res
;
1042 struct listnode
*node
;
1043 struct ospf6_nexthop
*nh
;
1045 if (ospf6
== NULL
) {
1046 vty_out(vty
, "OSPFv3 is not running\n");
1051 timersub(&now
, &route
->changed
, &res
);
1052 timerstring(&res
, duration
, sizeof(duration
));
1055 if (route
->type
== OSPF6_DEST_TYPE_LINKSTATE
)
1056 ospf6_linkstate_prefix2str(&route
->prefix
, destination
,
1057 sizeof(destination
));
1058 else if (route
->type
== OSPF6_DEST_TYPE_ROUTER
)
1059 inet_ntop(route
->prefix
.family
, &route
->prefix
.u
.prefix
,
1060 destination
, sizeof(destination
));
1062 prefix2str(&route
->prefix
, destination
, sizeof(destination
));
1065 for (ALL_LIST_ELEMENTS_RO(route
->nh_list
, node
, nh
)) {
1067 inet_ntop(AF_INET6
, &nh
->address
, nexthop
, sizeof(nexthop
));
1068 ifname
= ifindex2ifname(nh
->ifindex
, ospf6
->vrf_id
);
1071 vty_out(vty
, "%c%1s %2s %-30s %-25s %6.*s %s\n",
1072 (ospf6_route_is_best(route
) ? '*' : ' '),
1073 OSPF6_DEST_TYPE_SUBSTR(route
->type
),
1074 OSPF6_PATH_TYPE_SUBSTR(route
->path
.type
),
1075 destination
, nexthop
, IFNAMSIZ
, ifname
,
1079 vty_out(vty
, "%c%1s %2s %-30s %-25s %6.*s %s\n", ' ',
1080 "", "", "", nexthop
, IFNAMSIZ
, ifname
, "");
1084 void ospf6_route_show_detail(struct vty
*vty
, struct ospf6_route
*route
)
1087 char destination
[PREFIX2STR_BUFFER
], nexthop
[64];
1088 char area_id
[16], id
[16], adv_router
[16], capa
[16], options
[16];
1089 struct timeval now
, res
;
1091 struct listnode
*node
;
1092 struct ospf6_nexthop
*nh
;
1094 if (ospf6
== NULL
) {
1095 vty_out(vty
, "OSPFv3 is not running\n");
1102 if (route
->type
== OSPF6_DEST_TYPE_LINKSTATE
)
1103 ospf6_linkstate_prefix2str(&route
->prefix
, destination
,
1104 sizeof(destination
));
1105 else if (route
->type
== OSPF6_DEST_TYPE_ROUTER
)
1106 inet_ntop(route
->prefix
.family
, &route
->prefix
.u
.prefix
,
1107 destination
, sizeof(destination
));
1109 prefix2str(&route
->prefix
, destination
, sizeof(destination
));
1110 vty_out(vty
, "Destination: %s\n", destination
);
1112 /* destination type */
1113 vty_out(vty
, "Destination type: %s\n",
1114 OSPF6_DEST_TYPE_NAME(route
->type
));
1117 timersub(&now
, &route
->installed
, &res
);
1118 timerstring(&res
, duration
, sizeof(duration
));
1119 vty_out(vty
, "Installed Time: %s ago\n", duration
);
1121 timersub(&now
, &route
->changed
, &res
);
1122 timerstring(&res
, duration
, sizeof(duration
));
1123 vty_out(vty
, " Changed Time: %s ago\n", duration
);
1125 /* Debugging info */
1126 vty_out(vty
, "Lock: %d Flags: %s%s%s%s\n", route
->lock
,
1127 (CHECK_FLAG(route
->flag
, OSPF6_ROUTE_BEST
) ? "B" : "-"),
1128 (CHECK_FLAG(route
->flag
, OSPF6_ROUTE_ADD
) ? "A" : "-"),
1129 (CHECK_FLAG(route
->flag
, OSPF6_ROUTE_REMOVE
) ? "R" : "-"),
1130 (CHECK_FLAG(route
->flag
, OSPF6_ROUTE_CHANGE
) ? "C" : "-"));
1131 vty_out(vty
, "Memory: prev: %p this: %p next: %p\n",
1132 (void *)route
->prev
, (void *)route
, (void *)route
->next
);
1137 inet_ntop(AF_INET
, &route
->path
.area_id
, area_id
, sizeof(area_id
));
1138 vty_out(vty
, "Associated Area: %s\n", area_id
);
1141 vty_out(vty
, "Path Type: %s\n", OSPF6_PATH_TYPE_NAME(route
->path
.type
));
1144 inet_ntop(AF_INET
, &route
->path
.origin
.id
, id
, sizeof(id
));
1145 inet_ntop(AF_INET
, &route
->path
.origin
.adv_router
, adv_router
,
1146 sizeof(adv_router
));
1147 vty_out(vty
, "LS Origin: %s Id: %s Adv: %s\n",
1148 ospf6_lstype_name(route
->path
.origin
.type
), id
, adv_router
);
1151 ospf6_options_printbuf(route
->path
.options
, options
, sizeof(options
));
1152 vty_out(vty
, "Options: %s\n", options
);
1155 ospf6_capability_printbuf(route
->path
.router_bits
, capa
, sizeof(capa
));
1156 vty_out(vty
, "Router Bits: %s\n", capa
);
1158 /* Prefix Options */
1159 vty_out(vty
, "Prefix Options: xxx\n");
1162 vty_out(vty
, "Metric Type: %d\n", route
->path
.metric_type
);
1163 vty_out(vty
, "Metric: %d (%d)\n", route
->path
.cost
,
1164 route
->path
.u
.cost_e2
);
1166 vty_out(vty
, "Paths count: %u\n", route
->paths
->count
);
1167 vty_out(vty
, "Nexthop count: %u\n", route
->nh_list
->count
);
1169 vty_out(vty
, "Nexthop:\n");
1170 for (ALL_LIST_ELEMENTS_RO(route
->nh_list
, node
, nh
)) {
1172 inet_ntop(AF_INET6
, &nh
->address
, nexthop
, sizeof(nexthop
));
1173 ifname
= ifindex2ifname(nh
->ifindex
, ospf6
->vrf_id
);
1174 vty_out(vty
, " %s %.*s\n", nexthop
, IFNAMSIZ
, ifname
);
1179 static void ospf6_route_show_table_summary(struct vty
*vty
,
1180 struct ospf6_route_table
*table
)
1182 struct ospf6_route
*route
, *prev
= NULL
;
1183 int i
, pathtype
[OSPF6_PATH_TYPE_MAX
];
1184 unsigned int number
= 0;
1185 int nh_count
= 0, nhinval
= 0, ecmp
= 0;
1186 int alternative
= 0, destination
= 0;
1188 for (i
= 0; i
< OSPF6_PATH_TYPE_MAX
; i
++)
1191 for (route
= ospf6_route_head(table
); route
;
1192 route
= ospf6_route_next(route
)) {
1193 if (prev
== NULL
|| !ospf6_route_is_same(prev
, route
))
1197 nh_count
= ospf6_num_nexthops(route
->nh_list
);
1200 else if (nh_count
> 1)
1202 pathtype
[route
->path
.type
]++;
1208 assert(number
== table
->count
);
1210 vty_out(vty
, "Number of OSPFv3 routes: %d\n", number
);
1211 vty_out(vty
, "Number of Destination: %d\n", destination
);
1212 vty_out(vty
, "Number of Alternative routes: %d\n", alternative
);
1213 vty_out(vty
, "Number of Equal Cost Multi Path: %d\n", ecmp
);
1214 for (i
= OSPF6_PATH_TYPE_INTRA
; i
<= OSPF6_PATH_TYPE_EXTERNAL2
; i
++) {
1215 vty_out(vty
, "Number of %s routes: %d\n",
1216 OSPF6_PATH_TYPE_NAME(i
), pathtype
[i
]);
1220 static void ospf6_route_show_table_prefix(struct vty
*vty
,
1221 struct prefix
*prefix
,
1222 struct ospf6_route_table
*table
)
1224 struct ospf6_route
*route
;
1226 route
= ospf6_route_lookup(prefix
, table
);
1230 ospf6_route_lock(route
);
1231 while (route
&& ospf6_route_is_prefix(prefix
, route
)) {
1232 /* Specifying a prefix will always display details */
1233 ospf6_route_show_detail(vty
, route
);
1234 route
= ospf6_route_next(route
);
1237 ospf6_route_unlock(route
);
1240 static void ospf6_route_show_table_address(struct vty
*vty
,
1241 struct prefix
*prefix
,
1242 struct ospf6_route_table
*table
)
1244 struct ospf6_route
*route
;
1246 route
= ospf6_route_lookup_bestmatch(prefix
, table
);
1250 prefix
= &route
->prefix
;
1251 ospf6_route_lock(route
);
1252 while (route
&& ospf6_route_is_prefix(prefix
, route
)) {
1253 /* Specifying a prefix will always display details */
1254 ospf6_route_show_detail(vty
, route
);
1255 route
= ospf6_route_next(route
);
1258 ospf6_route_unlock(route
);
1261 static void ospf6_route_show_table_match(struct vty
*vty
, int detail
,
1262 struct prefix
*prefix
,
1263 struct ospf6_route_table
*table
)
1265 struct ospf6_route
*route
;
1266 assert(prefix
->family
);
1268 route
= ospf6_route_match_head(prefix
, table
);
1271 ospf6_route_show_detail(vty
, route
);
1273 ospf6_route_show(vty
, route
);
1274 route
= ospf6_route_match_next(prefix
, route
);
1278 static void ospf6_route_show_table_type(struct vty
*vty
, int detail
,
1280 struct ospf6_route_table
*table
)
1282 struct ospf6_route
*route
;
1284 route
= ospf6_route_head(table
);
1286 if (route
->path
.type
== type
) {
1288 ospf6_route_show_detail(vty
, route
);
1290 ospf6_route_show(vty
, route
);
1292 route
= ospf6_route_next(route
);
1296 static void ospf6_route_show_table(struct vty
*vty
, int detail
,
1297 struct ospf6_route_table
*table
)
1299 struct ospf6_route
*route
;
1301 route
= ospf6_route_head(table
);
1304 ospf6_route_show_detail(vty
, route
);
1306 ospf6_route_show(vty
, route
);
1307 route
= ospf6_route_next(route
);
1311 int ospf6_route_table_show(struct vty
*vty
, int argc_start
, int argc
,
1312 struct cmd_token
**argv
,
1313 struct ospf6_route_table
*table
)
1321 struct prefix prefix
;
1324 memset(&prefix
, 0, sizeof(struct prefix
));
1326 for (i
= argc_start
; i
< argc
; i
++) {
1327 if (strmatch(argv
[i
]->text
, "summary")) {
1332 if (strmatch(argv
[i
]->text
, "intra-area")) {
1333 type
= OSPF6_PATH_TYPE_INTRA
;
1337 if (strmatch(argv
[i
]->text
, "inter-area")) {
1338 type
= OSPF6_PATH_TYPE_INTER
;
1342 if (strmatch(argv
[i
]->text
, "external-1")) {
1343 type
= OSPF6_PATH_TYPE_EXTERNAL1
;
1347 if (strmatch(argv
[i
]->text
, "external-2")) {
1348 type
= OSPF6_PATH_TYPE_EXTERNAL2
;
1352 if (strmatch(argv
[i
]->text
, "detail")) {
1357 if (strmatch(argv
[i
]->text
, "match")) {
1362 ret
= str2prefix(argv
[i
]->arg
, &prefix
);
1363 if (ret
== 1 && prefix
.family
== AF_INET6
) {
1365 if (strchr(argv
[i
]->arg
, '/'))
1370 vty_out(vty
, "Malformed argument: %s\n", argv
[i
]->arg
);
1374 /* Give summary of this route table */
1376 ospf6_route_show_table_summary(vty
, table
);
1380 /* Give exact prefix-match route */
1381 if (isprefix
&& !match
) {
1382 /* If exact address, give best matching route */
1384 ospf6_route_show_table_address(vty
, &prefix
, table
);
1386 ospf6_route_show_table_prefix(vty
, &prefix
, table
);
1392 ospf6_route_show_table_match(vty
, detail
, &prefix
, table
);
1394 ospf6_route_show_table_type(vty
, detail
, type
, table
);
1396 ospf6_route_show_table(vty
, detail
, table
);
1401 static void ospf6_linkstate_show_header(struct vty
*vty
)
1403 vty_out(vty
, "%-7s %-15s %-15s %-8s %-14s %s\n", "Type", "Router-ID",
1404 "Net-ID", "Rtr-Bits", "Options", "Cost");
1407 static void ospf6_linkstate_show(struct vty
*vty
, struct ospf6_route
*route
)
1409 uint32_t router
, id
;
1410 char routername
[16], idname
[16], rbits
[16], options
[16];
1412 router
= ospf6_linkstate_prefix_adv_router(&route
->prefix
);
1413 inet_ntop(AF_INET
, &router
, routername
, sizeof(routername
));
1414 id
= ospf6_linkstate_prefix_id(&route
->prefix
);
1415 inet_ntop(AF_INET
, &id
, idname
, sizeof(idname
));
1417 ospf6_capability_printbuf(route
->path
.router_bits
, rbits
,
1419 ospf6_options_printbuf(route
->path
.options
, options
, sizeof(options
));
1422 vty_out(vty
, "%-7s %-15s %-15s %-8s %-14s %lu\n", "Network",
1423 routername
, idname
, rbits
, options
,
1424 (unsigned long)route
->path
.cost
);
1426 vty_out(vty
, "%-7s %-15s %-15s %-8s %-14s %lu\n", "Router",
1427 routername
, idname
, rbits
, options
,
1428 (unsigned long)route
->path
.cost
);
1432 static void ospf6_linkstate_show_table_exact(struct vty
*vty
,
1433 struct prefix
*prefix
,
1434 struct ospf6_route_table
*table
)
1436 struct ospf6_route
*route
;
1438 route
= ospf6_route_lookup(prefix
, table
);
1442 ospf6_route_lock(route
);
1443 while (route
&& ospf6_route_is_prefix(prefix
, route
)) {
1444 /* Specifying a prefix will always display details */
1445 ospf6_route_show_detail(vty
, route
);
1446 route
= ospf6_route_next(route
);
1449 ospf6_route_unlock(route
);
1452 static void ospf6_linkstate_show_table(struct vty
*vty
, int detail
,
1453 struct ospf6_route_table
*table
)
1455 struct ospf6_route
*route
;
1458 ospf6_linkstate_show_header(vty
);
1460 route
= ospf6_route_head(table
);
1463 ospf6_route_show_detail(vty
, route
);
1465 ospf6_linkstate_show(vty
, route
);
1466 route
= ospf6_route_next(route
);
1470 int ospf6_linkstate_table_show(struct vty
*vty
, int idx_ipv4
, int argc
,
1471 struct cmd_token
**argv
,
1472 struct ospf6_route_table
*table
)
1478 struct prefix router
, id
, prefix
;
1480 memset(&router
, 0, sizeof(struct prefix
));
1481 memset(&id
, 0, sizeof(struct prefix
));
1482 memset(&prefix
, 0, sizeof(struct prefix
));
1484 for (i
= idx_ipv4
; i
< argc
; i
++) {
1485 if (strmatch(argv
[i
]->text
, "detail")) {
1491 ret
= str2prefix(argv
[i
]->arg
, &router
);
1492 if (ret
== 1 && router
.family
== AF_INET
) {
1496 vty_out(vty
, "Malformed argument: %s\n", argv
[i
]->arg
);
1501 ret
= str2prefix(argv
[i
]->arg
, &id
);
1502 if (ret
== 1 && id
.family
== AF_INET
) {
1506 vty_out(vty
, "Malformed argument: %s\n", argv
[i
]->arg
);
1510 vty_out(vty
, "Malformed argument: %s\n", argv
[i
]->arg
);
1515 ospf6_linkstate_prefix(router
.u
.prefix4
.s_addr
,
1516 id
.u
.prefix4
.s_addr
, &prefix
);
1519 ospf6_linkstate_show_table_exact(vty
, &prefix
, table
);
1521 ospf6_linkstate_show_table(vty
, detail
, table
);
1527 void ospf6_brouter_show_header(struct vty
*vty
)
1529 vty_out(vty
, "%-15s %-8s %-14s %-10s %-15s\n", "Router-ID", "Rtr-Bits",
1530 "Options", "Path-Type", "Area");
1533 void ospf6_brouter_show(struct vty
*vty
, struct ospf6_route
*route
)
1535 uint32_t adv_router
;
1536 char adv
[16], rbits
[16], options
[16], area
[16];
1538 adv_router
= ospf6_linkstate_prefix_adv_router(&route
->prefix
);
1539 inet_ntop(AF_INET
, &adv_router
, adv
, sizeof(adv
));
1540 ospf6_capability_printbuf(route
->path
.router_bits
, rbits
,
1542 ospf6_options_printbuf(route
->path
.options
, options
, sizeof(options
));
1543 inet_ntop(AF_INET
, &route
->path
.area_id
, area
, sizeof(area
));
1545 /* vty_out (vty, "%-15s %-8s %-14s %-10s %-15s\n",
1546 "Router-ID", "Rtr-Bits", "Options", "Path-Type", "Area"); */
1547 vty_out(vty
, "%-15s %-8s %-14s %-10s %-15s\n", adv
, rbits
, options
,
1548 OSPF6_PATH_TYPE_NAME(route
->path
.type
), area
);
1551 DEFUN (debug_ospf6_route
,
1552 debug_ospf6_route_cmd
,
1553 "debug ospf6 route <table|intra-area|inter-area|memory>",
1557 "Debug route table calculation\n"
1558 "Debug intra-area route calculation\n"
1559 "Debug inter-area route calculation\n"
1560 "Debug route memory use\n"
1564 unsigned char level
= 0;
1566 if (!strcmp(argv
[idx_type
]->text
, "table"))
1567 level
= OSPF6_DEBUG_ROUTE_TABLE
;
1568 else if (!strcmp(argv
[idx_type
]->text
, "intra-area"))
1569 level
= OSPF6_DEBUG_ROUTE_INTRA
;
1570 else if (!strcmp(argv
[idx_type
]->text
, "inter-area"))
1571 level
= OSPF6_DEBUG_ROUTE_INTER
;
1572 else if (!strcmp(argv
[idx_type
]->text
, "memory"))
1573 level
= OSPF6_DEBUG_ROUTE_MEMORY
;
1574 OSPF6_DEBUG_ROUTE_ON(level
);
1578 DEFUN (no_debug_ospf6_route
,
1579 no_debug_ospf6_route_cmd
,
1580 "no debug ospf6 route <table|intra-area|inter-area|memory>",
1585 "Debug route table calculation\n"
1586 "Debug intra-area route calculation\n"
1587 "Debug inter-area route calculation\n"
1588 "Debug route memory use\n")
1591 unsigned char level
= 0;
1593 if (!strcmp(argv
[idx_type
]->text
, "table"))
1594 level
= OSPF6_DEBUG_ROUTE_TABLE
;
1595 else if (!strcmp(argv
[idx_type
]->text
, "intra-area"))
1596 level
= OSPF6_DEBUG_ROUTE_INTRA
;
1597 else if (!strcmp(argv
[idx_type
]->text
, "inter-area"))
1598 level
= OSPF6_DEBUG_ROUTE_INTER
;
1599 else if (!strcmp(argv
[idx_type
]->text
, "memory"))
1600 level
= OSPF6_DEBUG_ROUTE_MEMORY
;
1601 OSPF6_DEBUG_ROUTE_OFF(level
);
1605 int config_write_ospf6_debug_route(struct vty
*vty
)
1607 if (IS_OSPF6_DEBUG_ROUTE(TABLE
))
1608 vty_out(vty
, "debug ospf6 route table\n");
1609 if (IS_OSPF6_DEBUG_ROUTE(INTRA
))
1610 vty_out(vty
, "debug ospf6 route intra-area\n");
1611 if (IS_OSPF6_DEBUG_ROUTE(INTER
))
1612 vty_out(vty
, "debug ospf6 route inter-area\n");
1613 if (IS_OSPF6_DEBUG_ROUTE(MEMORY
))
1614 vty_out(vty
, "debug ospf6 route memory\n");
1619 void install_element_ospf6_debug_route(void)
1621 install_element(ENABLE_NODE
, &debug_ospf6_route_cmd
);
1622 install_element(ENABLE_NODE
, &no_debug_ospf6_route_cmd
);
1623 install_element(CONFIG_NODE
, &debug_ospf6_route_cmd
);
1624 install_element(CONFIG_NODE
, &no_debug_ospf6_route_cmd
);