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
33 #include "ospf6_proto.h"
34 #include "ospf6_message.h"
35 #include "ospf6_lsa.h"
36 #include "ospf6_lsdb.h"
37 #include "ospf6_route.h"
38 #include "ospf6_zebra.h"
40 #include "ospf6_top.h"
41 #include "ospf6_area.h"
42 #include "ospf6_interface.h"
43 #include "ospf6_neighbor.h"
45 #include "ospf6_flood.h"
46 #include "ospf6_asbr.h"
47 #include "ospf6_abr.h"
48 #include "ospf6_intra.h"
49 #include "ospf6_spf.h"
52 DEFINE_QOBJ_TYPE(ospf6
)
54 /* global ospf6d variable */
56 static struct ospf6_master ospf6_master
;
57 struct ospf6_master
*om6
;
59 static void ospf6_disable(struct ospf6
*o
);
61 static void ospf6_top_lsdb_hook_add(struct ospf6_lsa
*lsa
)
63 switch (ntohs(lsa
->header
->type
)) {
64 case OSPF6_LSTYPE_AS_EXTERNAL
:
65 ospf6_asbr_lsa_add(lsa
);
73 static void ospf6_top_lsdb_hook_remove(struct ospf6_lsa
*lsa
)
75 switch (ntohs(lsa
->header
->type
)) {
76 case OSPF6_LSTYPE_AS_EXTERNAL
:
77 ospf6_asbr_lsa_remove(lsa
, NULL
);
85 static void ospf6_top_route_hook_add(struct ospf6_route
*route
)
87 ospf6_abr_originate_summary(route
);
88 ospf6_zebra_route_update_add(route
);
91 static void ospf6_top_route_hook_remove(struct ospf6_route
*route
)
93 route
->flag
|= OSPF6_ROUTE_REMOVE
;
94 ospf6_abr_originate_summary(route
);
95 ospf6_zebra_route_update_remove(route
);
98 static void ospf6_top_brouter_hook_add(struct ospf6_route
*route
)
100 if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL
)) {
102 char brouter_name
[16];
104 brouter_id
= ADV_ROUTER_IN_PREFIX(&route
->prefix
);
105 inet_ntop(AF_INET
, &brouter_id
, brouter_name
,
106 sizeof(brouter_name
));
107 zlog_debug("%s: brouter %s add with adv router %x nh count %u",
108 __PRETTY_FUNCTION__
, brouter_name
,
109 route
->path
.origin
.adv_router
,
110 listcount(route
->nh_list
));
112 ospf6_abr_examin_brouter(ADV_ROUTER_IN_PREFIX(&route
->prefix
));
113 ospf6_asbr_lsentry_add(route
);
114 ospf6_abr_originate_summary(route
);
117 static void ospf6_top_brouter_hook_remove(struct ospf6_route
*route
)
119 if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL
)) {
121 char brouter_name
[16];
123 brouter_id
= ADV_ROUTER_IN_PREFIX(&route
->prefix
);
124 inet_ntop(AF_INET
, &brouter_id
, brouter_name
,
125 sizeof(brouter_name
));
126 zlog_debug("%s: brouter %s del with nh count %u",
127 __PRETTY_FUNCTION__
, brouter_name
,
128 listcount(route
->nh_list
));
130 route
->flag
|= OSPF6_ROUTE_REMOVE
;
131 ospf6_abr_examin_brouter(ADV_ROUTER_IN_PREFIX(&route
->prefix
));
132 ospf6_asbr_lsentry_remove(route
);
133 ospf6_abr_originate_summary(route
);
136 static struct ospf6
*ospf6_create(void)
140 o
= XCALLOC(MTYPE_OSPF6_TOP
, sizeof(struct ospf6
));
143 monotime(&o
->starttime
);
144 o
->area_list
= list_new();
145 o
->area_list
->cmp
= ospf6_area_cmp
;
146 o
->lsdb
= ospf6_lsdb_create(o
);
147 o
->lsdb_self
= ospf6_lsdb_create(o
);
148 o
->lsdb
->hook_add
= ospf6_top_lsdb_hook_add
;
149 o
->lsdb
->hook_remove
= ospf6_top_lsdb_hook_remove
;
151 o
->spf_delay
= OSPF_SPF_DELAY_DEFAULT
;
152 o
->spf_holdtime
= OSPF_SPF_HOLDTIME_DEFAULT
;
153 o
->spf_max_holdtime
= OSPF_SPF_MAX_HOLDTIME_DEFAULT
;
154 o
->spf_hold_multiplier
= 1;
156 /* LSA timers value init */
157 o
->lsa_minarrival
= OSPF_MIN_LS_ARRIVAL
;
159 o
->route_table
= OSPF6_ROUTE_TABLE_CREATE(GLOBAL
, ROUTES
);
160 o
->route_table
->scope
= o
;
161 o
->route_table
->hook_add
= ospf6_top_route_hook_add
;
162 o
->route_table
->hook_remove
= ospf6_top_route_hook_remove
;
164 o
->brouter_table
= OSPF6_ROUTE_TABLE_CREATE(GLOBAL
, BORDER_ROUTERS
);
165 o
->brouter_table
->scope
= o
;
166 o
->brouter_table
->hook_add
= ospf6_top_brouter_hook_add
;
167 o
->brouter_table
->hook_remove
= ospf6_top_brouter_hook_remove
;
169 o
->external_table
= OSPF6_ROUTE_TABLE_CREATE(GLOBAL
, EXTERNAL_ROUTES
);
170 o
->external_table
->scope
= o
;
172 o
->external_id_table
= route_table_init();
174 o
->ref_bandwidth
= OSPF6_REFERENCE_BANDWIDTH
;
176 o
->distance_table
= route_table_init();
178 /* Enable "log-adjacency-changes" */
179 #if DFLT_OSPF6_LOG_ADJACENCY_CHANGES
180 SET_FLAG(o
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
188 void ospf6_delete(struct ospf6
*o
)
190 struct listnode
*node
, *nnode
;
191 struct ospf6_area
*oa
;
195 ospf6_flush_self_originated_lsas_now();
196 ospf6_disable(ospf6
);
198 for (ALL_LIST_ELEMENTS(o
->area_list
, node
, nnode
, oa
))
199 ospf6_area_delete(oa
);
202 list_delete_and_null(&o
->area_list
);
204 ospf6_lsdb_delete(o
->lsdb
);
205 ospf6_lsdb_delete(o
->lsdb_self
);
207 ospf6_route_table_delete(o
->route_table
);
208 ospf6_route_table_delete(o
->brouter_table
);
210 ospf6_route_table_delete(o
->external_table
);
211 route_table_finish(o
->external_id_table
);
213 ospf6_distance_reset(o
);
214 route_table_finish(o
->distance_table
);
216 XFREE(MTYPE_OSPF6_TOP
, o
);
219 static void ospf6_disable(struct ospf6
*o
)
221 struct listnode
*node
, *nnode
;
222 struct ospf6_area
*oa
;
224 if (!CHECK_FLAG(o
->flag
, OSPF6_DISABLED
)) {
225 SET_FLAG(o
->flag
, OSPF6_DISABLED
);
227 for (ALL_LIST_ELEMENTS(o
->area_list
, node
, nnode
, oa
))
228 ospf6_area_disable(oa
);
230 /* XXX: This also changes persistent settings */
231 ospf6_asbr_redistribute_reset();
233 ospf6_lsdb_remove_all(o
->lsdb
);
234 ospf6_route_remove_all(o
->route_table
);
235 ospf6_route_remove_all(o
->brouter_table
);
237 THREAD_OFF(o
->maxage_remover
);
238 THREAD_OFF(o
->t_spf_calc
);
239 THREAD_OFF(o
->t_ase_calc
);
240 THREAD_OFF(o
->t_distribute_update
);
244 void ospf6_master_init(void)
246 memset(&ospf6_master
, 0, sizeof(struct ospf6_master
));
251 static int ospf6_maxage_remover(struct thread
*thread
)
253 struct ospf6
*o
= (struct ospf6
*)THREAD_ARG(thread
);
254 struct ospf6_area
*oa
;
255 struct ospf6_interface
*oi
;
256 struct ospf6_neighbor
*on
;
257 struct listnode
*i
, *j
, *k
;
260 o
->maxage_remover
= (struct thread
*)NULL
;
262 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
263 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
)) {
264 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, k
, on
)) {
265 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
266 && on
->state
!= OSPF6_NEIGHBOR_LOADING
)
269 ospf6_maxage_remove(o
);
275 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
276 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
)) {
277 if (ospf6_lsdb_maxage_remover(oi
->lsdb
)) {
282 if (ospf6_lsdb_maxage_remover(oa
->lsdb
)) {
287 if (ospf6_lsdb_maxage_remover(o
->lsdb
)) {
292 ospf6_maxage_remove(o
);
298 void ospf6_maxage_remove(struct ospf6
*o
)
301 thread_add_timer(master
, ospf6_maxage_remover
, o
,
302 OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT
,
306 void ospf6_router_id_update(void)
311 if (ospf6
->router_id_static
!= 0)
312 ospf6
->router_id
= ospf6
->router_id_static
;
314 ospf6
->router_id
= om6
->zebra_router_id
;
318 DEFUN_NOSH (router_ospf6
,
325 ospf6
= ospf6_create();
326 if (ospf6
->router_id
== 0)
327 ospf6_router_id_update();
329 /* set current ospf point. */
330 VTY_PUSH_CONTEXT(OSPF6_NODE
, ospf6
);
336 DEFUN (no_router_ospf6
,
344 vty_out(vty
, "OSPFv3 is not configured\n");
350 /* return to config node . */
351 VTY_PUSH_CONTEXT_NULL(CONFIG_NODE
);
356 /* change Router_ID commands. */
357 DEFUN(ospf6_router_id
,
359 "ospf6 router-id A.B.C.D",
361 "Configure OSPF6 Router-ID\n"
364 VTY_DECLVAR_CONTEXT(ospf6
, o
);
367 const char *router_id_str
;
369 struct ospf6_area
*oa
;
370 struct listnode
*node
;
372 argv_find(argv
, argc
, "A.B.C.D", &idx
);
373 router_id_str
= argv
[idx
]->arg
;
375 ret
= inet_pton(AF_INET
, router_id_str
, &router_id
);
377 vty_out(vty
, "malformed OSPF Router-ID: %s\n", router_id_str
);
381 o
->router_id_static
= router_id
;
383 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, node
, oa
)) {
386 "For this router-id change to take effect,"
387 " save config and restart ospf6d\n");
392 o
->router_id
= router_id
;
397 DEFUN(no_ospf6_router_id
,
398 no_ospf6_router_id_cmd
,
399 "no ospf6 router-id [A.B.C.D]",
401 "Configure OSPF6 Router-ID\n"
404 VTY_DECLVAR_CONTEXT(ospf6
, o
);
405 struct ospf6_area
*oa
;
406 struct listnode
*node
;
408 o
->router_id_static
= 0;
410 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, node
, oa
)) {
413 "For this router-id change to take effect,"
414 " save config and restart ospf6d\n");
419 if (o
->router_id_zebra
.s_addr
)
420 o
->router_id
= (uint32_t)o
->router_id_zebra
.s_addr
;
425 #if defined(VERSION_TYPE_DEV) && CONFDATE > 20180828
426 CPP_NOTICE("ospf6: `router-id A.B.C.D` deprecated 2017/08/28")
428 ALIAS_HIDDEN(ospf6_router_id
, ospf6_router_id_hdn_cmd
, "router-id A.B.C.D",
429 "Configure OSPF6 Router-ID\n" V4NOTATION_STR
)
431 #if defined(VERSION_TYPE_DEV) && CONFDATE > 20180828
432 CPP_NOTICE("ospf6: `no router-id A.B.C.D` deprecated 2017/08/28")
434 ALIAS_HIDDEN(no_ospf6_router_id
, no_ospf6_router_id_hdn_cmd
,
435 "no router-id [A.B.C.D]",
436 NO_STR
"Configure OSPF6 Router-ID\n" V4NOTATION_STR
)
438 DEFUN (ospf6_log_adjacency_changes
,
439 ospf6_log_adjacency_changes_cmd
,
440 "log-adjacency-changes",
441 "Log changes in adjacency state\n")
443 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
445 SET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
446 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
450 DEFUN (ospf6_log_adjacency_changes_detail
,
451 ospf6_log_adjacency_changes_detail_cmd
,
452 "log-adjacency-changes detail",
453 "Log changes in adjacency state\n"
454 "Log all state changes\n")
456 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
458 SET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
459 SET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
463 DEFUN (no_ospf6_log_adjacency_changes
,
464 no_ospf6_log_adjacency_changes_cmd
,
465 "no log-adjacency-changes",
467 "Log changes in adjacency state\n")
469 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
471 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
472 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
476 DEFUN (no_ospf6_log_adjacency_changes_detail
,
477 no_ospf6_log_adjacency_changes_detail_cmd
,
478 "no log-adjacency-changes detail",
480 "Log changes in adjacency state\n"
481 "Log all state changes\n")
483 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
485 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
489 DEFUN (ospf6_timers_lsa
,
490 ospf6_timers_lsa_cmd
,
491 "timers lsa min-arrival (0-600000)",
492 "Adjust routing timers\n"
494 "Minimum delay in receiving new version of a LSA\n"
495 "Delay in milliseconds\n")
497 VTY_DECLVAR_CONTEXT(ospf6
, ospf
);
499 unsigned int minarrival
;
501 minarrival
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
502 ospf
->lsa_minarrival
= minarrival
;
507 DEFUN (no_ospf6_timers_lsa
,
508 no_ospf6_timers_lsa_cmd
,
509 "no timers lsa min-arrival [(0-600000)]",
511 "Adjust routing timers\n"
513 "Minimum delay in receiving new version of a LSA\n"
514 "Delay in milliseconds\n")
516 VTY_DECLVAR_CONTEXT(ospf6
, ospf
);
518 unsigned int minarrival
;
521 minarrival
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
523 if (ospf
->lsa_minarrival
!= minarrival
524 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
528 ospf
->lsa_minarrival
= OSPF_MIN_LS_ARRIVAL
;
534 DEFUN (ospf6_distance
,
537 "Administrative distance\n"
538 "OSPF6 Administrative distance\n")
540 VTY_DECLVAR_CONTEXT(ospf6
, o
);
542 o
->distance_all
= atoi(argv
[1]->arg
);
547 DEFUN (no_ospf6_distance
,
548 no_ospf6_distance_cmd
,
549 "no distance (1-255)",
551 "Administrative distance\n"
552 "OSPF6 Administrative distance\n")
554 VTY_DECLVAR_CONTEXT(ospf6
, o
);
561 DEFUN (ospf6_distance_ospf6
,
562 ospf6_distance_ospf6_cmd
,
563 "distance ospf6 {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
564 "Administrative distance\n"
565 "OSPF6 administrative distance\n"
566 "Intra-area routes\n"
567 "Distance for intra-area routes\n"
568 "Inter-area routes\n"
569 "Distance for inter-area routes\n"
571 "Distance for external routes\n")
573 VTY_DECLVAR_CONTEXT(ospf6
, o
);
576 o
->distance_intra
= 0;
577 o
->distance_inter
= 0;
578 o
->distance_external
= 0;
580 if (argv_find(argv
, argc
, "intra-area", &idx
))
581 o
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
583 if (argv_find(argv
, argc
, "inter-area", &idx
))
584 o
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
586 if (argv_find(argv
, argc
, "external", &idx
))
587 o
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
592 DEFUN (no_ospf6_distance_ospf6
,
593 no_ospf6_distance_ospf6_cmd
,
594 "no distance ospf6 [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
596 "Administrative distance\n"
598 "Intra-area routes\n"
599 "Distance for intra-area routes\n"
600 "Inter-area routes\n"
601 "Distance for inter-area routes\n"
603 "Distance for external routes\n")
605 VTY_DECLVAR_CONTEXT(ospf6
, o
);
608 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
609 idx
= o
->distance_intra
= 0;
610 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
611 idx
= o
->distance_inter
= 0;
612 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
613 o
->distance_external
= 0;
619 DEFUN (ospf6_distance_source
,
620 ospf6_distance_source_cmd
,
621 "distance (1-255) X:X::X:X/M [WORD]",
622 "Administrative distance\n"
625 "Access list name\n")
627 VTY_DECLVAR_CONTEXT(ospf6
, o
);
628 char *alname
= (argc
== 4) ? argv
[3]->arg
: NULL
;
629 ospf6_distance_set (vty
, o
, argv
[1]->arg
, argv
[2]->arg
, alname
);
634 DEFUN (no_ospf6_distance_source
,
635 no_ospf6_distance_source_cmd
,
636 "no distance (1-255) X:X::X:X/M [WORD]",
638 "Administrative distance\n"
641 "Access list name\n")
643 VTY_DECLVAR_CONTEXT(ospf6
, o
);
644 char *alname
= (argc
== 5) ? argv
[4]->arg
: NULL
;
645 ospf6_distance_unset (vty
, o
, argv
[2]->arg
, argv
[3]->arg
, alname
);
651 DEFUN (ospf6_interface_area
,
652 ospf6_interface_area_cmd
,
653 "interface IFNAME area A.B.C.D",
654 "Enable routing on an IPv6 interface\n"
656 "Specify the OSPF6 area ID\n"
657 "OSPF6 area ID in IPv4 address notation\n"
660 VTY_DECLVAR_CONTEXT(ospf6
, o
);
663 struct ospf6_area
*oa
;
664 struct ospf6_interface
*oi
;
665 struct interface
*ifp
;
668 /* find/create ospf6 interface */
669 ifp
= if_get_by_name(argv
[idx_ifname
]->arg
, VRF_DEFAULT
, 0);
670 oi
= (struct ospf6_interface
*)ifp
->info
;
672 oi
= ospf6_interface_create(ifp
);
674 vty_out(vty
, "%s already attached to Area %s\n",
675 oi
->interface
->name
, oi
->area
->name
);
680 if (inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &area_id
) != 1) {
681 vty_out(vty
, "Invalid Area-ID: %s\n", argv
[idx_ipv4
]->arg
);
685 /* find/create ospf6 area */
686 oa
= ospf6_area_lookup(area_id
, o
);
688 oa
= ospf6_area_create(area_id
, o
, OSPF6_AREA_FMT_DOTTEDQUAD
);
690 /* attach interface to area */
691 listnode_add(oa
->if_list
, oi
); /* sort ?? */
694 SET_FLAG(oa
->flag
, OSPF6_AREA_ENABLE
);
696 /* ospf6 process is currently disabled, not much more to do */
697 if (CHECK_FLAG(o
->flag
, OSPF6_DISABLED
))
701 ospf6_interface_enable(oi
);
703 /* If the router is ABR, originate summary routes */
704 if (ospf6_is_router_abr(o
))
705 ospf6_abr_enable_area(oa
);
710 DEFUN (no_ospf6_interface_area
,
711 no_ospf6_interface_area_cmd
,
712 "no interface IFNAME area A.B.C.D",
714 "Disable routing on an IPv6 interface\n"
716 "Specify the OSPF6 area ID\n"
717 "OSPF6 area ID in IPv4 address notation\n"
722 struct ospf6_interface
*oi
;
723 struct ospf6_area
*oa
;
724 struct interface
*ifp
;
727 ifp
= if_lookup_by_name(argv
[idx_ifname
]->arg
, VRF_DEFAULT
);
729 vty_out(vty
, "No such interface %s\n", argv
[idx_ifname
]->arg
);
733 oi
= (struct ospf6_interface
*)ifp
->info
;
735 vty_out(vty
, "Interface %s not enabled\n", ifp
->name
);
740 if (inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &area_id
) != 1) {
741 vty_out(vty
, "Invalid Area-ID: %s\n", argv
[idx_ipv4
]->arg
);
746 if (oi
->area
== NULL
) {
747 vty_out(vty
, "No such Area-ID: %s\n", argv
[idx_ipv4
]->arg
);
751 if (oi
->area
->area_id
!= area_id
) {
752 vty_out(vty
, "Wrong Area-ID: %s is attached to area %s\n",
753 oi
->interface
->name
, oi
->area
->name
);
757 thread_execute(master
, interface_down
, oi
, 0);
760 listnode_delete(oi
->area
->if_list
, oi
);
761 oi
->area
= (struct ospf6_area
*)NULL
;
763 /* Withdraw inter-area routes from this area, if necessary */
764 if (oa
->if_list
->count
== 0) {
765 UNSET_FLAG(oa
->flag
, OSPF6_AREA_ENABLE
);
766 ospf6_abr_disable_area(oa
);
772 DEFUN (ospf6_stub_router_admin
,
773 ospf6_stub_router_admin_cmd
,
774 "stub-router administrative",
775 "Make router a stub router\n"
776 "Administratively applied, for an indefinite period\n")
778 struct listnode
*node
;
779 struct ospf6_area
*oa
;
781 if (!CHECK_FLAG(ospf6
->flag
, OSPF6_STUB_ROUTER
)) {
782 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
783 OSPF6_OPT_CLEAR(oa
->options
, OSPF6_OPT_V6
);
784 OSPF6_OPT_CLEAR(oa
->options
, OSPF6_OPT_R
);
785 OSPF6_ROUTER_LSA_SCHEDULE(oa
);
787 SET_FLAG(ospf6
->flag
, OSPF6_STUB_ROUTER
);
793 DEFUN (no_ospf6_stub_router_admin
,
794 no_ospf6_stub_router_admin_cmd
,
795 "no stub-router administrative",
797 "Make router a stub router\n"
798 "Administratively applied, for an indefinite period\n")
800 struct listnode
*node
;
801 struct ospf6_area
*oa
;
803 if (CHECK_FLAG(ospf6
->flag
, OSPF6_STUB_ROUTER
)) {
804 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
805 OSPF6_OPT_SET(oa
->options
, OSPF6_OPT_V6
);
806 OSPF6_OPT_SET(oa
->options
, OSPF6_OPT_R
);
807 OSPF6_ROUTER_LSA_SCHEDULE(oa
);
809 UNSET_FLAG(ospf6
->flag
, OSPF6_STUB_ROUTER
);
816 DEFUN (ospf6_stub_router_startup
,
817 ospf6_stub_router_startup_cmd
,
818 "stub-router on-startup (5-86400)",
819 "Make router a stub router\n"
820 "Advertise inability to be a transit router\n"
821 "Automatically advertise as stub-router on startup of OSPF6\n"
822 "Time (seconds) to advertise self as stub-router\n")
827 DEFUN (no_ospf6_stub_router_startup
,
828 no_ospf6_stub_router_startup_cmd
,
829 "no stub-router on-startup",
831 "Make router a stub router\n"
832 "Advertise inability to be a transit router\n"
833 "Automatically advertise as stub-router on startup of OSPF6\n"
834 "Time (seconds) to advertise self as stub-router\n")
839 DEFUN (ospf6_stub_router_shutdown
,
840 ospf6_stub_router_shutdown_cmd
,
841 "stub-router on-shutdown (5-86400)",
842 "Make router a stub router\n"
843 "Advertise inability to be a transit router\n"
844 "Automatically advertise as stub-router before shutdown\n"
845 "Time (seconds) to advertise self as stub-router\n")
850 DEFUN (no_ospf6_stub_router_shutdown
,
851 no_ospf6_stub_router_shutdown_cmd
,
852 "no stub-router on-shutdown",
854 "Make router a stub router\n"
855 "Advertise inability to be a transit router\n"
856 "Automatically advertise as stub-router before shutdown\n"
857 "Time (seconds) to advertise self as stub-router\n")
863 static void ospf6_show(struct vty
*vty
, struct ospf6
*o
)
866 struct ospf6_area
*oa
;
867 char router_id
[16], duration
[32];
868 struct timeval now
, running
, result
;
869 char buf
[32], rbuf
[32];
871 /* process id, router id */
872 inet_ntop(AF_INET
, &o
->router_id
, router_id
, sizeof(router_id
));
873 vty_out(vty
, " OSPFv3 Routing Process (0) with Router-ID %s\n",
878 timersub(&now
, &o
->starttime
, &running
);
879 timerstring(&running
, duration
, sizeof(duration
));
880 vty_out(vty
, " Running %s\n", duration
);
882 /* Redistribute configuration */
885 vty_out(vty
, " LSA minimum arrival %d msecs\n", o
->lsa_minarrival
);
887 /* Show SPF parameters */
889 " Initial SPF scheduling delay %d millisec(s)\n"
890 " Minimum hold time between consecutive SPFs %d millsecond(s)\n"
891 " Maximum hold time between consecutive SPFs %d millsecond(s)\n"
892 " Hold time multiplier is currently %d\n",
893 o
->spf_delay
, o
->spf_holdtime
, o
->spf_max_holdtime
,
894 o
->spf_hold_multiplier
);
896 vty_out(vty
, " SPF algorithm ");
897 if (o
->ts_spf
.tv_sec
|| o
->ts_spf
.tv_usec
) {
898 timersub(&now
, &o
->ts_spf
, &result
);
899 timerstring(&result
, buf
, sizeof(buf
));
900 ospf6_spf_reason_string(o
->last_spf_reason
, rbuf
, sizeof(rbuf
));
901 vty_out(vty
, "last executed %s ago, reason %s\n", buf
, rbuf
);
902 vty_out(vty
, " Last SPF duration %lld sec %lld usec\n",
903 (long long)o
->ts_spf_duration
.tv_sec
,
904 (long long)o
->ts_spf_duration
.tv_usec
);
906 vty_out(vty
, "has not been run\n");
907 threadtimer_string(now
, o
->t_spf_calc
, buf
, sizeof(buf
));
908 vty_out(vty
, " SPF timer %s%s\n", (o
->t_spf_calc
? "due in " : "is "),
911 if (CHECK_FLAG(o
->flag
, OSPF6_STUB_ROUTER
))
912 vty_out(vty
, " Router Is Stub Router\n");
915 vty_out(vty
, " Number of AS scoped LSAs is %u\n", o
->lsdb
->count
);
918 vty_out(vty
, " Number of areas in this router is %u\n",
919 listcount(o
->area_list
));
921 if (CHECK_FLAG(o
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
)) {
922 if (CHECK_FLAG(o
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
))
923 vty_out(vty
, " All adjacency changes are logged\n");
925 vty_out(vty
, " Adjacency changes are logged\n");
930 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, n
, oa
))
931 ospf6_area_show(vty
, oa
);
934 /* show top level structures */
935 DEFUN (show_ipv6_ospf6
,
942 OSPF6_CMD_CHECK_RUNNING();
944 ospf6_show(vty
, ospf6
);
948 DEFUN (show_ipv6_ospf6_route
,
949 show_ipv6_ospf6_route_cmd
,
950 "show ipv6 ospf6 route [<intra-area|inter-area|external-1|external-2|X:X::X:X|X:X::X:X/M|detail|summary>]",
955 "Display Intra-Area routes\n"
956 "Display Inter-Area routes\n"
957 "Display Type-1 External routes\n"
958 "Display Type-2 External routes\n"
959 "Specify IPv6 address\n"
960 "Specify IPv6 prefix\n"
961 "Detailed information\n"
962 "Summary of route table\n")
964 OSPF6_CMD_CHECK_RUNNING();
966 ospf6_route_table_show(vty
, 4, argc
, argv
, ospf6
->route_table
);
970 DEFUN (show_ipv6_ospf6_route_match
,
971 show_ipv6_ospf6_route_match_cmd
,
972 "show ipv6 ospf6 route X:X::X:X/M <match|longer>",
977 "Specify IPv6 prefix\n"
978 "Display routes which match the specified route\n"
979 "Display routes longer than the specified route\n")
981 OSPF6_CMD_CHECK_RUNNING();
983 ospf6_route_table_show(vty
, 4, argc
, argv
, ospf6
->route_table
);
987 DEFUN (show_ipv6_ospf6_route_match_detail
,
988 show_ipv6_ospf6_route_match_detail_cmd
,
989 "show ipv6 ospf6 route X:X::X:X/M match detail",
994 "Specify IPv6 prefix\n"
995 "Display routes which match the specified route\n"
996 "Detailed information\n"
999 OSPF6_CMD_CHECK_RUNNING();
1001 ospf6_route_table_show(vty
, 4, argc
, argv
, ospf6
->route_table
);
1006 DEFUN (show_ipv6_ospf6_route_type_detail
,
1007 show_ipv6_ospf6_route_type_detail_cmd
,
1008 "show ipv6 ospf6 route <intra-area|inter-area|external-1|external-2> detail",
1013 "Display Intra-Area routes\n"
1014 "Display Inter-Area routes\n"
1015 "Display Type-1 External routes\n"
1016 "Display Type-2 External routes\n"
1017 "Detailed information\n"
1020 OSPF6_CMD_CHECK_RUNNING();
1022 ospf6_route_table_show(vty
, 4, argc
, argv
, ospf6
->route_table
);
1026 static void ospf6_stub_router_config_write(struct vty
*vty
)
1028 if (CHECK_FLAG(ospf6
->flag
, OSPF6_STUB_ROUTER
)) {
1029 vty_out(vty
, " stub-router administrative\n");
1034 static int ospf6_distance_config_write(struct vty
*vty
)
1036 struct route_node
*rn
;
1037 struct ospf6_distance
*odistance
;
1039 if (ospf6
->distance_all
)
1040 vty_out(vty
, " distance %u\n", ospf6
->distance_all
);
1042 if (ospf6
->distance_intra
|| ospf6
->distance_inter
1043 || ospf6
->distance_external
) {
1044 vty_out(vty
, " distance ospf6");
1046 if (ospf6
->distance_intra
)
1047 vty_out(vty
, " intra-area %u", ospf6
->distance_intra
);
1048 if (ospf6
->distance_inter
)
1049 vty_out(vty
, " inter-area %u", ospf6
->distance_inter
);
1050 if (ospf6
->distance_external
)
1051 vty_out(vty
, " external %u", ospf6
->distance_external
);
1056 for (rn
= route_top(ospf6
->distance_table
); rn
; rn
= route_next(rn
))
1057 if ((odistance
= rn
->info
) != NULL
) {
1058 char buf
[PREFIX_STRLEN
];
1060 vty_out(vty
, " distance %u %s %s\n",
1061 odistance
->distance
,
1062 prefix2str(&rn
->p
, buf
, sizeof(buf
)),
1063 odistance
->access_list
? odistance
->access_list
1069 /* OSPF configuration write function. */
1070 static int config_write_ospf6(struct vty
*vty
)
1073 struct listnode
*j
, *k
;
1074 struct ospf6_area
*oa
;
1075 struct ospf6_interface
*oi
;
1077 /* OSPFv3 configuration. */
1081 inet_ntop(AF_INET
, &ospf6
->router_id_static
, router_id
,
1083 vty_out(vty
, "router ospf6\n");
1084 if (ospf6
->router_id_static
!= 0)
1085 vty_out(vty
, " ospf6 router-id %s\n", router_id
);
1087 /* log-adjacency-changes flag print. */
1088 if (CHECK_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
)) {
1089 if (CHECK_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
))
1090 vty_out(vty
, " log-adjacency-changes detail\n");
1091 else if (!DFLT_OSPF6_LOG_ADJACENCY_CHANGES
)
1092 vty_out(vty
, " log-adjacency-changes\n");
1093 } else if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES
) {
1094 vty_out(vty
, " no log-adjacency-changes\n");
1097 if (ospf6
->ref_bandwidth
!= OSPF6_REFERENCE_BANDWIDTH
)
1098 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
1099 ospf6
->ref_bandwidth
);
1101 /* LSA timers print. */
1102 if (ospf6
->lsa_minarrival
!= OSPF_MIN_LS_ARRIVAL
)
1103 vty_out(vty
, " timers lsa min-arrival %d\n",
1104 ospf6
->lsa_minarrival
);
1106 ospf6_stub_router_config_write(vty
);
1107 ospf6_redistribute_config_write(vty
);
1108 ospf6_area_config_write(vty
);
1109 ospf6_spf_config_write(vty
);
1110 ospf6_distance_config_write(vty
);
1112 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, j
, oa
)) {
1113 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, k
, oi
))
1114 vty_out(vty
, " interface %s area %s\n",
1115 oi
->interface
->name
, oa
->name
);
1117 vty_out(vty
, "!\n");
1121 /* OSPF6 node structure. */
1122 static struct cmd_node ospf6_node
= {
1123 OSPF6_NODE
, "%s(config-ospf6)# ", 1 /* VTYSH */
1126 /* Install ospf related commands. */
1127 void ospf6_top_init(void)
1129 /* Install ospf6 top node. */
1130 install_node(&ospf6_node
, config_write_ospf6
);
1132 install_element(VIEW_NODE
, &show_ipv6_ospf6_cmd
);
1133 install_element(CONFIG_NODE
, &router_ospf6_cmd
);
1134 install_element(CONFIG_NODE
, &no_router_ospf6_cmd
);
1136 install_element(VIEW_NODE
, &show_ipv6_ospf6_route_cmd
);
1137 install_element(VIEW_NODE
, &show_ipv6_ospf6_route_match_cmd
);
1138 install_element(VIEW_NODE
, &show_ipv6_ospf6_route_match_detail_cmd
);
1139 install_element(VIEW_NODE
, &show_ipv6_ospf6_route_type_detail_cmd
);
1141 install_default(OSPF6_NODE
);
1142 install_element(OSPF6_NODE
, &ospf6_router_id_cmd
);
1143 install_element(OSPF6_NODE
, &no_ospf6_router_id_cmd
);
1144 install_element(OSPF6_NODE
, &ospf6_router_id_hdn_cmd
);
1145 install_element(OSPF6_NODE
, &no_ospf6_router_id_hdn_cmd
);
1146 install_element(OSPF6_NODE
, &ospf6_log_adjacency_changes_cmd
);
1147 install_element(OSPF6_NODE
, &ospf6_log_adjacency_changes_detail_cmd
);
1148 install_element(OSPF6_NODE
, &no_ospf6_log_adjacency_changes_cmd
);
1149 install_element(OSPF6_NODE
, &no_ospf6_log_adjacency_changes_detail_cmd
);
1151 /* LSA timers commands */
1152 install_element(OSPF6_NODE
, &ospf6_timers_lsa_cmd
);
1153 install_element(OSPF6_NODE
, &no_ospf6_timers_lsa_cmd
);
1155 install_element(OSPF6_NODE
, &ospf6_interface_area_cmd
);
1156 install_element(OSPF6_NODE
, &no_ospf6_interface_area_cmd
);
1157 install_element(OSPF6_NODE
, &ospf6_stub_router_admin_cmd
);
1158 install_element(OSPF6_NODE
, &no_ospf6_stub_router_admin_cmd
);
1159 /* For a later time */
1161 install_element (OSPF6_NODE
, &ospf6_stub_router_startup_cmd
);
1162 install_element (OSPF6_NODE
, &no_ospf6_stub_router_startup_cmd
);
1163 install_element (OSPF6_NODE
, &ospf6_stub_router_shutdown_cmd
);
1164 install_element (OSPF6_NODE
, &no_ospf6_stub_router_shutdown_cmd
);
1167 install_element(OSPF6_NODE
, &ospf6_distance_cmd
);
1168 install_element(OSPF6_NODE
, &no_ospf6_distance_cmd
);
1169 install_element(OSPF6_NODE
, &ospf6_distance_ospf6_cmd
);
1170 install_element(OSPF6_NODE
, &no_ospf6_distance_ospf6_cmd
);
1172 install_element (OSPF6_NODE
, &ospf6_distance_source_cmd
);
1173 install_element (OSPF6_NODE
, &no_ospf6_distance_source_cmd
);