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 "lib_errors.h"
35 #include "ospf6_proto.h"
36 #include "ospf6_message.h"
37 #include "ospf6_lsa.h"
38 #include "ospf6_lsdb.h"
39 #include "ospf6_route.h"
40 #include "ospf6_zebra.h"
42 #include "ospf6_top.h"
43 #include "ospf6_area.h"
44 #include "ospf6_interface.h"
45 #include "ospf6_neighbor.h"
46 #include "ospf6_network.h"
48 #include "ospf6_flood.h"
49 #include "ospf6_asbr.h"
50 #include "ospf6_abr.h"
51 #include "ospf6_intra.h"
52 #include "ospf6_spf.h"
56 #include "ospf6_nssa.h"
57 #include "ospf6_auth_trailer.h"
59 DEFINE_MTYPE_STATIC(OSPF6D
, OSPF6_TOP
, "OSPF6 top");
61 DEFINE_QOBJ_TYPE(ospf6
);
63 FRR_CFG_DEFAULT_BOOL(OSPF6_LOG_ADJACENCY_CHANGES
,
64 { .val_bool
= true, .match_profile
= "datacenter", },
65 { .val_bool
= false },
68 #include "ospf6d/ospf6_top_clippy.c"
70 /* global ospf6d variable */
71 static struct ospf6_master ospf6_master
;
72 struct ospf6_master
*om6
;
74 static void ospf6_disable(struct ospf6
*o
);
76 static void ospf6_add(struct ospf6
*ospf6
)
78 listnode_add(om6
->ospf6
, ospf6
);
81 static void ospf6_del(struct ospf6
*ospf6
)
83 listnode_delete(om6
->ospf6
, ospf6
);
86 const char *ospf6_vrf_id_to_name(vrf_id_t vrf_id
)
88 struct vrf
*vrf
= vrf_lookup_by_id(vrf_id
);
90 return vrf
? vrf
->name
: "NIL";
93 /* Link OSPF instance to VRF. */
94 void ospf6_vrf_link(struct ospf6
*ospf6
, struct vrf
*vrf
)
96 ospf6
->vrf_id
= vrf
->vrf_id
;
97 if (vrf
->info
!= (void *)ospf6
)
98 vrf
->info
= (void *)ospf6
;
101 /* Unlink OSPF instance from VRF. */
102 void ospf6_vrf_unlink(struct ospf6
*ospf6
, struct vrf
*vrf
)
104 if (vrf
->info
== (void *)ospf6
)
106 ospf6
->vrf_id
= VRF_UNKNOWN
;
109 struct ospf6
*ospf6_lookup_by_vrf_id(vrf_id_t vrf_id
)
111 struct vrf
*vrf
= NULL
;
113 vrf
= vrf_lookup_by_id(vrf_id
);
116 return (vrf
->info
) ? (struct ospf6
*)vrf
->info
: NULL
;
119 struct ospf6
*ospf6_lookup_by_vrf_name(const char *name
)
121 struct ospf6
*o
= NULL
;
122 struct listnode
*node
, *nnode
;
124 for (ALL_LIST_ELEMENTS(om6
->ospf6
, node
, nnode
, o
)) {
125 if (((o
->name
== NULL
&& name
== NULL
)
126 || (o
->name
&& name
&& strcmp(o
->name
, name
) == 0)))
132 /* This is hook function for vrf create called as part of vrf_init */
133 static int ospf6_vrf_new(struct vrf
*vrf
)
138 /* This is hook function for vrf delete call as part of vrf_init */
139 static int ospf6_vrf_delete(struct vrf
*vrf
)
144 static void ospf6_set_redist_vrf_bitmaps(struct ospf6
*ospf6
, bool set
)
147 struct list
*red_list
;
149 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++) {
150 red_list
= ospf6
->redist
[type
];
153 if (IS_OSPF6_DEBUG_ZEBRA(RECV
))
155 "%s: setting redist vrf %d bitmap for type %d",
156 __func__
, ospf6
->vrf_id
, type
);
158 vrf_bitmap_set(zclient
->redist
[AFI_IP6
][type
],
161 vrf_bitmap_unset(zclient
->redist
[AFI_IP6
][type
],
165 red_list
= ospf6
->redist
[DEFAULT_ROUTE
];
168 vrf_bitmap_set(zclient
->default_information
[AFI_IP6
],
171 vrf_bitmap_unset(zclient
->default_information
[AFI_IP6
],
176 /* Disable OSPF6 VRF instance */
177 static int ospf6_vrf_disable(struct vrf
*vrf
)
179 struct ospf6
*ospf6
= NULL
;
181 if (vrf
->vrf_id
== VRF_DEFAULT
)
184 ospf6
= ospf6_lookup_by_vrf_name(vrf
->name
);
186 ospf6_zebra_vrf_deregister(ospf6
);
188 ospf6_set_redist_vrf_bitmaps(ospf6
, false);
190 /* We have instance configured, unlink
191 * from VRF and make it "down".
193 ospf6_vrf_unlink(ospf6
, vrf
);
194 thread_cancel(&ospf6
->t_ospf6_receive
);
199 /* Note: This is a callback, the VRF will be deleted by the caller. */
203 /* Enable OSPF6 VRF instance */
204 static int ospf6_vrf_enable(struct vrf
*vrf
)
206 struct ospf6
*ospf6
= NULL
;
210 ospf6
= ospf6_lookup_by_vrf_name(vrf
->name
);
212 old_vrf_id
= ospf6
->vrf_id
;
213 /* We have instance configured, link to VRF and make it "up". */
214 ospf6_vrf_link(ospf6
, vrf
);
216 if (old_vrf_id
!= ospf6
->vrf_id
) {
217 ospf6_set_redist_vrf_bitmaps(ospf6
, true);
219 /* start zebra redist to us for new vrf */
220 ospf6_zebra_vrf_register(ospf6
);
222 ret
= ospf6_serv_sock(ospf6
);
223 if (ret
< 0 || ospf6
->fd
<= 0)
225 thread_add_read(master
, ospf6_receive
, ospf6
, ospf6
->fd
,
226 &ospf6
->t_ospf6_receive
);
228 ospf6_router_id_update(ospf6
, true);
235 void ospf6_vrf_init(void)
237 vrf_init(ospf6_vrf_new
, ospf6_vrf_enable
, ospf6_vrf_disable
,
243 static void ospf6_top_lsdb_hook_add(struct ospf6_lsa
*lsa
)
245 switch (ntohs(lsa
->header
->type
)) {
246 case OSPF6_LSTYPE_AS_EXTERNAL
:
247 ospf6_asbr_lsa_add(lsa
);
255 static void ospf6_top_lsdb_hook_remove(struct ospf6_lsa
*lsa
)
257 switch (ntohs(lsa
->header
->type
)) {
258 case OSPF6_LSTYPE_AS_EXTERNAL
:
259 ospf6_asbr_lsa_remove(lsa
, NULL
);
267 static void ospf6_top_route_hook_add(struct ospf6_route
*route
)
269 struct ospf6
*ospf6
= NULL
;
270 struct ospf6_area
*oa
= NULL
;
272 if (route
->table
->scope_type
== OSPF6_SCOPE_TYPE_GLOBAL
)
273 ospf6
= route
->table
->scope
;
274 else if (route
->table
->scope_type
== OSPF6_SCOPE_TYPE_AREA
) {
275 oa
= (struct ospf6_area
*)route
->table
->scope
;
278 if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL
)
279 || IS_OSPF6_DEBUG_BROUTER
)
281 "%s: Route is not GLOBAL or scope is not of TYPE_AREA: %pFX",
282 __func__
, &route
->prefix
);
286 ospf6_abr_originate_summary(route
, ospf6
);
287 ospf6_zebra_route_update_add(route
, ospf6
);
290 static void ospf6_top_route_hook_remove(struct ospf6_route
*route
)
292 struct ospf6
*ospf6
= NULL
;
293 struct ospf6_area
*oa
= NULL
;
295 if (route
->table
->scope_type
== OSPF6_SCOPE_TYPE_GLOBAL
)
296 ospf6
= route
->table
->scope
;
297 else if (route
->table
->scope_type
== OSPF6_SCOPE_TYPE_AREA
) {
298 oa
= (struct ospf6_area
*)route
->table
->scope
;
301 if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL
)
302 || IS_OSPF6_DEBUG_BROUTER
)
304 "%s: Route is not GLOBAL or scope is not of TYPE_AREA: %pFX",
305 __func__
, &route
->prefix
);
309 route
->flag
|= OSPF6_ROUTE_REMOVE
;
310 ospf6_abr_originate_summary(route
, ospf6
);
311 ospf6_zebra_route_update_remove(route
, ospf6
);
314 static void ospf6_top_brouter_hook_add(struct ospf6_route
*route
)
316 struct ospf6
*ospf6
= route
->table
->scope
;
318 if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL
) ||
319 IS_OSPF6_DEBUG_BROUTER
) {
321 char brouter_name
[16];
323 brouter_id
= ADV_ROUTER_IN_PREFIX(&route
->prefix
);
324 inet_ntop(AF_INET
, &brouter_id
, brouter_name
,
325 sizeof(brouter_name
));
326 zlog_debug("%s: brouter %s add with adv router %x nh count %u",
327 __func__
, brouter_name
,
328 route
->path
.origin
.adv_router
,
329 listcount(route
->nh_list
));
331 ospf6_abr_examin_brouter(ADV_ROUTER_IN_PREFIX(&route
->prefix
), route
,
333 ospf6_asbr_lsentry_add(route
, ospf6
);
334 ospf6_abr_originate_summary(route
, ospf6
);
337 static void ospf6_top_brouter_hook_remove(struct ospf6_route
*route
)
339 struct ospf6
*ospf6
= route
->table
->scope
;
341 if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL
) ||
342 IS_OSPF6_DEBUG_BROUTER
) {
344 char brouter_name
[16];
346 brouter_id
= ADV_ROUTER_IN_PREFIX(&route
->prefix
);
347 inet_ntop(AF_INET
, &brouter_id
, brouter_name
,
348 sizeof(brouter_name
));
349 zlog_debug("%s: brouter %p %s del with adv router %x nh %u",
350 __func__
, (void *)route
, brouter_name
,
351 route
->path
.origin
.adv_router
,
352 listcount(route
->nh_list
));
354 route
->flag
|= OSPF6_ROUTE_REMOVE
;
355 ospf6_abr_examin_brouter(ADV_ROUTER_IN_PREFIX(&route
->prefix
), route
,
357 ospf6_asbr_lsentry_remove(route
, ospf6
);
358 ospf6_abr_originate_summary(route
, ospf6
);
361 static struct ospf6
*ospf6_create(const char *name
)
364 struct vrf
*vrf
= NULL
;
366 o
= XCALLOC(MTYPE_OSPF6_TOP
, sizeof(struct ospf6
));
368 vrf
= vrf_lookup_by_name(name
);
370 o
->vrf_id
= vrf
->vrf_id
;
372 o
->vrf_id
= VRF_UNKNOWN
;
374 /* Freed in ospf6_delete */
375 o
->name
= XSTRDUP(MTYPE_OSPF6_TOP
, name
);
377 ospf6_vrf_link(o
, vrf
);
379 ospf6_zebra_vrf_register(o
);
382 monotime(&o
->starttime
);
383 o
->area_list
= list_new();
384 o
->area_list
->cmp
= ospf6_area_cmp
;
385 o
->lsdb
= ospf6_lsdb_create(o
);
386 o
->lsdb_self
= ospf6_lsdb_create(o
);
387 o
->lsdb
->hook_add
= ospf6_top_lsdb_hook_add
;
388 o
->lsdb
->hook_remove
= ospf6_top_lsdb_hook_remove
;
390 o
->spf_delay
= OSPF_SPF_DELAY_DEFAULT
;
391 o
->spf_holdtime
= OSPF_SPF_HOLDTIME_DEFAULT
;
392 o
->spf_max_holdtime
= OSPF_SPF_MAX_HOLDTIME_DEFAULT
;
393 o
->spf_hold_multiplier
= 1;
395 o
->default_originate
= DEFAULT_ORIGINATE_NONE
;
397 /* LSA timers value init */
398 o
->lsa_minarrival
= OSPF_MIN_LS_ARRIVAL
;
400 o
->route_table
= OSPF6_ROUTE_TABLE_CREATE(GLOBAL
, ROUTES
);
401 o
->route_table
->scope
= o
;
402 o
->route_table
->hook_add
= ospf6_top_route_hook_add
;
403 o
->route_table
->hook_remove
= ospf6_top_route_hook_remove
;
405 o
->brouter_table
= OSPF6_ROUTE_TABLE_CREATE(GLOBAL
, BORDER_ROUTERS
);
406 o
->brouter_table
->scope
= o
;
407 o
->brouter_table
->hook_add
= ospf6_top_brouter_hook_add
;
408 o
->brouter_table
->hook_remove
= ospf6_top_brouter_hook_remove
;
410 o
->external_table
= OSPF6_ROUTE_TABLE_CREATE(GLOBAL
, EXTERNAL_ROUTES
);
411 o
->external_table
->scope
= o
;
412 /* Setting this to 1, so that the LS ID 0 can be considered as invalid
413 * for self originated external LSAs. This helps in differentiating if
414 * an LSA is originated for any route or not in the route data.
415 * rt->route_option->id is by default 0
416 * Consider a route having id as 0 and prefix as 1::1, an external LSA
417 * is originated with ID 0.0.0.0. Now consider another route 2::2
418 * and for this LSA was not originated because of some configuration
419 * but the ID field rt->route_option->id is still 0.Consider now this
420 * 2::2 is being deleted, it will search LSA with LS ID as 0 and it
421 * will find the LSA and hence delete it but the LSA belonged to prefix
422 * 1::1, this happened because of LS ID 0.
424 o
->external_id
= OSPF6_EXT_INIT_LS_ID
;
426 o
->write_oi_count
= OSPF6_WRITE_INTERFACE_COUNT_DEFAULT
;
427 o
->ref_bandwidth
= OSPF6_REFERENCE_BANDWIDTH
;
429 o
->distance_table
= route_table_init();
431 o
->rt_aggr_tbl
= route_table_init();
432 o
->aggr_delay_interval
= OSPF6_EXTL_AGGR_DEFAULT_DELAY
;
433 o
->aggr_action
= OSPF6_ROUTE_AGGR_NONE
;
437 o
->max_multipath
= MULTIPATH_NUM
;
439 o
->oi_write_q
= list_new();
441 ospf6_gr_helper_init(o
);
444 /* Make ospf protocol socket. */
447 /* If sequence number is stored in persistent storage, read it.
449 if (ospf6_auth_nvm_file_exist() == OSPF6_AUTH_FILE_EXIST
) {
450 ospf6_auth_seqno_nvm_read(o
);
451 o
->seqnum_h
= o
->seqnum_h
+ 1;
452 ospf6_auth_seqno_nvm_update(o
);
454 o
->seqnum_l
= o
->seqnum_h
= 0;
455 ospf6_auth_seqno_nvm_update(o
);
461 struct ospf6
*ospf6_instance_create(const char *name
)
465 struct interface
*ifp
;
467 ospf6
= ospf6_create(name
);
468 if (DFLT_OSPF6_LOG_ADJACENCY_CHANGES
)
469 SET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
470 if (ospf6
->router_id
== 0)
471 ospf6_router_id_update(ospf6
, true);
473 if (ospf6
->vrf_id
!= VRF_UNKNOWN
) {
474 vrf
= vrf_lookup_by_id(ospf6
->vrf_id
);
475 FOR_ALL_INTERFACES (vrf
, ifp
) {
477 ospf6_interface_start(ifp
->info
);
484 * Read from non-volatile memory whether this instance is performing a
485 * graceful restart or not.
487 ospf6_gr_nvm_read(ospf6
);
489 thread_add_read(master
, ospf6_receive
, ospf6
, ospf6
->fd
,
490 &ospf6
->t_ospf6_receive
);
495 void ospf6_delete(struct ospf6
*o
)
497 struct listnode
*node
, *nnode
;
498 struct route_node
*rn
= NULL
;
499 struct ospf6_area
*oa
;
501 struct ospf6_external_aggr_rt
*aggr
;
505 ospf6_gr_helper_deinit(o
);
506 if (!o
->gr_info
.prepare_in_progress
)
507 ospf6_flush_self_originated_lsas_now(o
);
511 ospf6_zebra_vrf_deregister(o
);
513 ospf6_serv_close(&o
->fd
);
515 for (ALL_LIST_ELEMENTS(o
->area_list
, node
, nnode
, oa
))
516 ospf6_area_delete(oa
);
519 list_delete(&o
->area_list
);
521 ospf6_lsdb_delete(o
->lsdb
);
522 ospf6_lsdb_delete(o
->lsdb_self
);
524 ospf6_route_table_delete(o
->route_table
);
525 ospf6_route_table_delete(o
->brouter_table
);
527 ospf6_route_table_delete(o
->external_table
);
529 ospf6_distance_reset(o
);
530 route_table_finish(o
->distance_table
);
531 list_delete(&o
->oi_write_q
);
533 if (o
->vrf_id
!= VRF_UNKNOWN
) {
534 vrf
= vrf_lookup_by_id(o
->vrf_id
);
536 ospf6_vrf_unlink(o
, vrf
);
539 for (rn
= route_top(o
->rt_aggr_tbl
); rn
; rn
= route_next(rn
))
542 ospf6_asbr_summary_config_delete(o
, rn
);
543 ospf6_external_aggregator_free(aggr
);
545 route_table_finish(o
->rt_aggr_tbl
);
547 XFREE(MTYPE_OSPF6_TOP
, o
->name
);
548 XFREE(MTYPE_OSPF6_TOP
, o
);
551 static void ospf6_disable(struct ospf6
*o
)
553 struct listnode
*node
, *nnode
;
554 struct ospf6_area
*oa
;
556 if (!CHECK_FLAG(o
->flag
, OSPF6_DISABLED
)) {
557 SET_FLAG(o
->flag
, OSPF6_DISABLED
);
559 for (ALL_LIST_ELEMENTS(o
->area_list
, node
, nnode
, oa
))
560 ospf6_area_disable(oa
);
562 /* XXX: This also changes persistent settings */
563 /* Unregister redistribution */
564 ospf6_asbr_redistribute_disable(o
);
566 ospf6_lsdb_remove_all(o
->lsdb
);
567 ospf6_route_remove_all(o
->route_table
);
568 ospf6_route_remove_all(o
->brouter_table
);
570 THREAD_OFF(o
->maxage_remover
);
571 THREAD_OFF(o
->t_spf_calc
);
572 THREAD_OFF(o
->t_ase_calc
);
573 THREAD_OFF(o
->t_distribute_update
);
574 THREAD_OFF(o
->t_ospf6_receive
);
575 THREAD_OFF(o
->t_external_aggr
);
576 THREAD_OFF(o
->gr_info
.t_grace_period
);
577 THREAD_OFF(o
->t_write
);
578 THREAD_OFF(o
->t_abr_task
);
582 void ospf6_master_init(struct thread_master
*master
)
584 memset(&ospf6_master
, 0, sizeof(ospf6_master
));
587 om6
->ospf6
= list_new();
588 om6
->master
= master
;
591 static void ospf6_maxage_remover(struct thread
*thread
)
593 struct ospf6
*o
= (struct ospf6
*)THREAD_ARG(thread
);
594 struct ospf6_area
*oa
;
595 struct ospf6_interface
*oi
;
596 struct ospf6_neighbor
*on
;
597 struct listnode
*i
, *j
, *k
;
600 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
601 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
)) {
602 for (ALL_LIST_ELEMENTS_RO(oi
->neighbor_list
, k
, on
)) {
603 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
604 && on
->state
!= OSPF6_NEIGHBOR_LOADING
)
607 ospf6_maxage_remove(o
);
613 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, i
, oa
)) {
614 for (ALL_LIST_ELEMENTS_RO(oa
->if_list
, j
, oi
)) {
615 if (ospf6_lsdb_maxage_remover(oi
->lsdb
)) {
620 if (ospf6_lsdb_maxage_remover(oa
->lsdb
)) {
625 if (ospf6_lsdb_maxage_remover(o
->lsdb
)) {
630 ospf6_maxage_remove(o
);
634 void ospf6_maxage_remove(struct ospf6
*o
)
637 thread_add_timer(master
, ospf6_maxage_remover
, o
,
638 OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT
,
642 bool ospf6_router_id_update(struct ospf6
*ospf6
, bool init
)
644 in_addr_t new_router_id
;
645 struct listnode
*node
;
646 struct ospf6_area
*oa
;
651 if (ospf6
->router_id_static
!= 0)
652 new_router_id
= ospf6
->router_id_static
;
654 new_router_id
= ospf6
->router_id_zebra
;
656 if (ospf6
->router_id
== new_router_id
)
660 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
663 "%s: cannot update router-id. Run the \"clear ipv6 ospf6 process\" command",
669 ospf6
->router_id
= new_router_id
;
674 DEFUN_NOSH(router_ospf6
, router_ospf6_cmd
, "router ospf6 [vrf NAME]",
675 ROUTER_STR OSPF6_STR VRF_CMD_HELP_STR
)
678 const char *vrf_name
= VRF_DEFAULT_NAME
;
681 if (argv_find(argv
, argc
, "vrf", &idx_vrf
)) {
682 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
685 ospf6
= ospf6_lookup_by_vrf_name(vrf_name
);
687 ospf6
= ospf6_instance_create(vrf_name
);
689 /* set current ospf point. */
690 VTY_PUSH_CONTEXT(OSPF6_NODE
, ospf6
);
696 DEFUN(no_router_ospf6
, no_router_ospf6_cmd
, "no router ospf6 [vrf NAME]",
697 NO_STR ROUTER_STR OSPF6_STR VRF_CMD_HELP_STR
)
700 const char *vrf_name
= VRF_DEFAULT_NAME
;
703 if (argv_find(argv
, argc
, "vrf", &idx_vrf
)) {
704 vrf_name
= argv
[idx_vrf
+ 1]->arg
;
707 ospf6
= ospf6_lookup_by_vrf_name(vrf_name
);
709 vty_out(vty
, "OSPFv3 is not configured\n");
715 /* return to config node . */
716 VTY_PUSH_CONTEXT_NULL(CONFIG_NODE
);
721 static void ospf6_db_clear(struct ospf6
*ospf6
)
723 struct ospf6_interface
*oi
;
724 struct interface
*ifp
;
725 struct vrf
*vrf
= vrf_lookup_by_id(ospf6
->vrf_id
);
726 struct listnode
*node
, *nnode
;
727 struct ospf6_area
*oa
;
729 FOR_ALL_INTERFACES (vrf
, ifp
) {
730 if (if_is_operative(ifp
) && ifp
->info
!= NULL
) {
731 oi
= (struct ospf6_interface
*)ifp
->info
;
732 ospf6_lsdb_remove_all(oi
->lsdb
);
733 ospf6_lsdb_remove_all(oi
->lsdb_self
);
734 ospf6_lsdb_remove_all(oi
->lsupdate_list
);
735 ospf6_lsdb_remove_all(oi
->lsack_list
);
739 for (ALL_LIST_ELEMENTS(ospf6
->area_list
, node
, nnode
, oa
)) {
740 ospf6_lsdb_remove_all(oa
->lsdb
);
741 ospf6_lsdb_remove_all(oa
->lsdb_self
);
743 ospf6_spf_table_finish(oa
->spf_table
);
744 ospf6_route_remove_all(oa
->route_table
);
747 ospf6_lsdb_remove_all(ospf6
->lsdb
);
748 ospf6_lsdb_remove_all(ospf6
->lsdb_self
);
749 ospf6_route_remove_all(ospf6
->route_table
);
750 ospf6_route_remove_all(ospf6
->brouter_table
);
753 static void ospf6_process_reset(struct ospf6
*ospf6
)
755 struct interface
*ifp
;
756 struct vrf
*vrf
= vrf_lookup_by_id(ospf6
->vrf_id
);
758 ospf6_unset_all_aggr_flag(ospf6
);
759 ospf6_flush_self_originated_lsas_now(ospf6
);
760 ospf6
->inst_shutdown
= 0;
761 ospf6_db_clear(ospf6
);
763 ospf6_asbr_redistribute_reset(ospf6
);
764 FOR_ALL_INTERFACES (vrf
, ifp
)
765 ospf6_interface_clear(ifp
);
768 DEFPY (clear_router_ospf6
,
769 clear_router_ospf6_cmd
,
770 "clear ipv6 ospf6 process [vrf NAME$name]",
774 "Reset OSPF Process\n"
778 const char *vrf_name
= VRF_DEFAULT_NAME
;
783 ospf6
= ospf6_lookup_by_vrf_name(vrf_name
);
785 vty_out(vty
, "OSPFv3 is not configured\n");
787 ospf6_router_id_update(ospf6
, true);
788 ospf6_process_reset(ospf6
);
794 /* change Router_ID commands. */
795 DEFUN(ospf6_router_id
,
797 "ospf6 router-id A.B.C.D",
799 "Configure OSPF6 Router-ID\n"
802 VTY_DECLVAR_CONTEXT(ospf6
, o
);
805 const char *router_id_str
;
808 argv_find(argv
, argc
, "A.B.C.D", &idx
);
809 router_id_str
= argv
[idx
]->arg
;
811 ret
= inet_pton(AF_INET
, router_id_str
, &router_id
);
813 vty_out(vty
, "malformed OSPF Router-ID: %s\n", router_id_str
);
817 o
->router_id_static
= router_id
;
819 if (ospf6_router_id_update(o
, false))
820 ospf6_process_reset(o
);
823 "For this router-id change to take effect run the \"clear ipv6 ospf6 process\" command\n");
828 DEFUN(no_ospf6_router_id
,
829 no_ospf6_router_id_cmd
,
830 "no ospf6 router-id [A.B.C.D]",
832 "Configure OSPF6 Router-ID\n"
835 VTY_DECLVAR_CONTEXT(ospf6
, o
);
837 o
->router_id_static
= 0;
840 if (ospf6_router_id_update(o
, false))
841 ospf6_process_reset(o
);
844 "For this router-id change to take effect run the \"clear ipv6 ospf6 process\" command\n");
849 DEFUN (ospf6_log_adjacency_changes
,
850 ospf6_log_adjacency_changes_cmd
,
851 "log-adjacency-changes",
852 "Log changes in adjacency state\n")
854 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
856 SET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
857 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
861 DEFUN (ospf6_log_adjacency_changes_detail
,
862 ospf6_log_adjacency_changes_detail_cmd
,
863 "log-adjacency-changes detail",
864 "Log changes in adjacency state\n"
865 "Log all state changes\n")
867 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
869 SET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
870 SET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
874 DEFUN (no_ospf6_log_adjacency_changes
,
875 no_ospf6_log_adjacency_changes_cmd
,
876 "no log-adjacency-changes",
878 "Log changes in adjacency state\n")
880 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
882 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
883 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
887 DEFUN (no_ospf6_log_adjacency_changes_detail
,
888 no_ospf6_log_adjacency_changes_detail_cmd
,
889 "no log-adjacency-changes detail",
891 "Log changes in adjacency state\n"
892 "Log all state changes\n")
894 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
896 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
900 static void ospf6_reinstall_routes(struct ospf6
*ospf6
)
902 struct ospf6_route
*route
;
904 for (route
= ospf6_route_head(ospf6
->route_table
); route
;
905 route
= ospf6_route_next(route
))
906 ospf6_zebra_route_update_add(route
, ospf6
);
909 DEFPY (ospf6_send_extra_data
,
910 ospf6_send_extra_data_cmd
,
911 "[no] ospf6 send-extra-data zebra",
914 "Extra data to Zebra for display/use\n"
917 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
920 && CHECK_FLAG(ospf6
->config_flags
,
921 OSPF6_SEND_EXTRA_DATA_TO_ZEBRA
)) {
922 UNSET_FLAG(ospf6
->config_flags
, OSPF6_SEND_EXTRA_DATA_TO_ZEBRA
);
923 ospf6_reinstall_routes(ospf6
);
924 } else if (!CHECK_FLAG(ospf6
->config_flags
,
925 OSPF6_SEND_EXTRA_DATA_TO_ZEBRA
)) {
926 SET_FLAG(ospf6
->config_flags
, OSPF6_SEND_EXTRA_DATA_TO_ZEBRA
);
927 ospf6_reinstall_routes(ospf6
);
933 DEFUN (ospf6_timers_lsa
,
934 ospf6_timers_lsa_cmd
,
935 "timers lsa min-arrival (0-600000)",
936 "Adjust routing timers\n"
938 "Minimum delay in receiving new version of a LSA\n"
939 "Delay in milliseconds\n")
941 VTY_DECLVAR_CONTEXT(ospf6
, ospf
);
943 unsigned int minarrival
;
945 minarrival
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
946 ospf
->lsa_minarrival
= minarrival
;
951 DEFUN (no_ospf6_timers_lsa
,
952 no_ospf6_timers_lsa_cmd
,
953 "no timers lsa min-arrival [(0-600000)]",
955 "Adjust routing timers\n"
957 "Minimum delay in receiving new version of a LSA\n"
958 "Delay in milliseconds\n")
960 VTY_DECLVAR_CONTEXT(ospf6
, ospf
);
962 unsigned int minarrival
;
965 minarrival
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
967 if (ospf
->lsa_minarrival
!= minarrival
968 || minarrival
== OSPF_MIN_LS_ARRIVAL
)
972 ospf
->lsa_minarrival
= OSPF_MIN_LS_ARRIVAL
;
978 DEFUN (ospf6_distance
,
981 "Administrative distance\n"
982 "OSPF6 Administrative distance\n")
984 VTY_DECLVAR_CONTEXT(ospf6
, o
);
987 distance
= atoi(argv
[1]->arg
);
988 if (o
->distance_all
!= distance
) {
989 o
->distance_all
= distance
;
990 ospf6_restart_spf(o
);
996 DEFUN (no_ospf6_distance
,
997 no_ospf6_distance_cmd
,
998 "no distance (1-255)",
1000 "Administrative distance\n"
1001 "OSPF6 Administrative distance\n")
1003 VTY_DECLVAR_CONTEXT(ospf6
, o
);
1005 if (o
->distance_all
) {
1006 o
->distance_all
= 0;
1007 ospf6_restart_spf(o
);
1012 DEFUN (ospf6_distance_ospf6
,
1013 ospf6_distance_ospf6_cmd
,
1014 "distance ospf6 {intra-area (1-255)|inter-area (1-255)|external (1-255)}",
1015 "Administrative distance\n"
1016 "OSPF6 administrative distance\n"
1017 "Intra-area routes\n"
1018 "Distance for intra-area routes\n"
1019 "Inter-area routes\n"
1020 "Distance for inter-area routes\n"
1022 "Distance for external routes\n")
1024 VTY_DECLVAR_CONTEXT(ospf6
, o
);
1027 o
->distance_intra
= 0;
1028 o
->distance_inter
= 0;
1029 o
->distance_external
= 0;
1031 if (argv_find(argv
, argc
, "intra-area", &idx
))
1032 o
->distance_intra
= atoi(argv
[idx
+ 1]->arg
);
1034 if (argv_find(argv
, argc
, "inter-area", &idx
))
1035 o
->distance_inter
= atoi(argv
[idx
+ 1]->arg
);
1037 if (argv_find(argv
, argc
, "external", &idx
))
1038 o
->distance_external
= atoi(argv
[idx
+ 1]->arg
);
1043 DEFUN (no_ospf6_distance_ospf6
,
1044 no_ospf6_distance_ospf6_cmd
,
1045 "no distance ospf6 [{intra-area [(1-255)]|inter-area [(1-255)]|external [(1-255)]}]",
1047 "Administrative distance\n"
1049 "Intra-area routes\n"
1050 "Distance for intra-area routes\n"
1051 "Inter-area routes\n"
1052 "Distance for inter-area routes\n"
1054 "Distance for external routes\n")
1056 VTY_DECLVAR_CONTEXT(ospf6
, o
);
1059 if (argv_find(argv
, argc
, "intra-area", &idx
) || argc
== 3)
1060 idx
= o
->distance_intra
= 0;
1061 if (argv_find(argv
, argc
, "inter-area", &idx
) || argc
== 3)
1062 idx
= o
->distance_inter
= 0;
1063 if (argv_find(argv
, argc
, "external", &idx
) || argc
== 3)
1064 o
->distance_external
= 0;
1069 DEFUN_HIDDEN (ospf6_interface_area
,
1070 ospf6_interface_area_cmd
,
1071 "interface IFNAME area <A.B.C.D|(0-4294967295)>",
1072 "Enable routing on an IPv6 interface\n"
1074 "Specify the OSPF6 area ID\n"
1075 "OSPF6 area ID in IPv4 address notation\n"
1076 "OSPF6 area ID in decimal notation\n"
1079 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1082 struct ospf6_area
*oa
;
1083 struct ospf6_interface
*oi
;
1084 struct interface
*ifp
;
1089 "This command is deprecated, because it is not VRF-aware.\n");
1091 "Please, use \"ipv6 ospf6 area\" on an interface instead.\n");
1093 /* find/create ospf6 interface */
1094 ifp
= if_get_by_name(argv
[idx_ifname
]->arg
, ospf6
->vrf_id
, ospf6
->name
);
1095 oi
= (struct ospf6_interface
*)ifp
->info
;
1097 oi
= ospf6_interface_create(ifp
);
1099 vty_out(vty
, "%s already attached to Area %s\n",
1100 oi
->interface
->name
, oi
->area
->name
);
1104 if (str2area_id(argv
[idx_ipv4
]->arg
, &area_id
, &format
)) {
1105 vty_out(vty
, "Malformed Area-ID: %s\n", argv
[idx_ipv4
]->arg
);
1106 return CMD_WARNING_CONFIG_FAILED
;
1109 oi
->area_id
= area_id
;
1110 oi
->area_id_format
= format
;
1112 oa
= ospf6_area_lookup(area_id
, ospf6
);
1114 oa
= ospf6_area_create(area_id
, ospf6
, format
);
1116 /* attach interface to area */
1117 listnode_add(oa
->if_list
, oi
); /* sort ?? */
1120 SET_FLAG(oa
->flag
, OSPF6_AREA_ENABLE
);
1122 /* ospf6 process is currently disabled, not much more to do */
1123 if (CHECK_FLAG(ospf6
->flag
, OSPF6_DISABLED
))
1127 ospf6_interface_enable(oi
);
1129 /* If the router is ABR, originate summary routes */
1130 if (ospf6_check_and_set_router_abr(ospf6
)) {
1131 ospf6_abr_enable_area(oa
);
1132 ospf6_schedule_abr_task(oa
->ospf6
);
1138 DEFUN_HIDDEN (no_ospf6_interface_area
,
1139 no_ospf6_interface_area_cmd
,
1140 "no interface IFNAME area <A.B.C.D|(0-4294967295)>",
1142 "Disable routing on an IPv6 interface\n"
1144 "Specify the OSPF6 area ID\n"
1145 "OSPF6 area ID in IPv4 address notation\n"
1146 "OSPF6 area ID in decimal notation\n"
1149 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1152 struct ospf6_interface
*oi
;
1153 struct ospf6_area
*oa
;
1154 struct interface
*ifp
;
1158 "This command is deprecated, because it is not VRF-aware.\n");
1160 "Please, use \"no ipv6 ospf6 area\" on an interface instead.\n");
1162 /* find/create ospf6 interface */
1163 ifp
= if_get_by_name(argv
[idx_ifname
]->arg
, ospf6
->vrf_id
, ospf6
->name
);
1166 vty_out(vty
, "No such interface %s\n", argv
[idx_ifname
]->arg
);
1170 oi
= (struct ospf6_interface
*)ifp
->info
;
1172 vty_out(vty
, "Interface %s not enabled\n", ifp
->name
);
1177 if (inet_pton(AF_INET
, argv
[idx_ipv4
]->arg
, &area_id
) != 1)
1178 area_id
= htonl(strtoul(argv
[idx_ipv4
]->arg
, NULL
, 10));
1181 if (oi
->area
== NULL
) {
1182 vty_out(vty
, "%s not attached to area %s\n",
1183 oi
->interface
->name
, argv
[idx_ipv4
]->arg
);
1187 if (oi
->area
->area_id
!= area_id
) {
1188 vty_out(vty
, "Wrong Area-ID: %s is attached to area %s\n",
1189 oi
->interface
->name
, oi
->area
->name
);
1193 ospf6_interface_disable(oi
);
1196 listnode_delete(oi
->area
->if_list
, oi
);
1197 oi
->area
= (struct ospf6_area
*)NULL
;
1199 /* Withdraw inter-area routes from this area, if necessary */
1200 if (oa
->if_list
->count
== 0) {
1201 UNSET_FLAG(oa
->flag
, OSPF6_AREA_ENABLE
);
1202 ospf6_abr_disable_area(oa
);
1206 oi
->area_id_format
= OSPF6_AREA_FMT_UNSET
;
1211 DEFUN (ospf6_stub_router_admin
,
1212 ospf6_stub_router_admin_cmd
,
1213 "stub-router administrative",
1214 "Make router a stub router\n"
1215 "Administratively applied, for an indefinite period\n")
1217 struct listnode
*node
;
1218 struct ospf6_area
*oa
;
1220 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1222 if (!CHECK_FLAG(ospf6
->flag
, OSPF6_STUB_ROUTER
)) {
1223 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
1224 OSPF6_OPT_CLEAR(oa
->options
, OSPF6_OPT_V6
);
1225 OSPF6_OPT_CLEAR(oa
->options
, OSPF6_OPT_R
);
1226 OSPF6_ROUTER_LSA_SCHEDULE(oa
);
1228 SET_FLAG(ospf6
->flag
, OSPF6_STUB_ROUTER
);
1234 DEFUN (no_ospf6_stub_router_admin
,
1235 no_ospf6_stub_router_admin_cmd
,
1236 "no stub-router administrative",
1238 "Make router a stub router\n"
1239 "Administratively applied, for an indefinite period\n")
1241 struct listnode
*node
;
1242 struct ospf6_area
*oa
;
1244 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1245 if (CHECK_FLAG(ospf6
->flag
, OSPF6_STUB_ROUTER
)) {
1246 for (ALL_LIST_ELEMENTS_RO(ospf6
->area_list
, node
, oa
)) {
1247 OSPF6_OPT_SET(oa
->options
, OSPF6_OPT_V6
);
1248 OSPF6_OPT_SET(oa
->options
, OSPF6_OPT_R
);
1249 OSPF6_ROUTER_LSA_SCHEDULE(oa
);
1251 UNSET_FLAG(ospf6
->flag
, OSPF6_STUB_ROUTER
);
1257 /* Restart OSPF SPF algorithm*/
1258 void ospf6_restart_spf(struct ospf6
*ospf6
)
1260 ospf6_route_remove_all(ospf6
->route_table
);
1261 ospf6_route_remove_all(ospf6
->brouter_table
);
1264 ospf6_spf_schedule(ospf6
, OSPF6_SPF_FLAGS_CONFIG_CHANGE
);
1267 /* Set the max paths */
1268 static void ospf6_maxpath_set(struct ospf6
*ospf6
, uint16_t paths
)
1270 if (ospf6
->max_multipath
== paths
)
1273 ospf6
->max_multipath
= paths
;
1275 /* Send deletion to zebra to delete all
1276 * ospf specific routes and reinitiate
1277 * SPF to reflect the new max multipath.
1279 ospf6_restart_spf(ospf6
);
1282 /* Ospf Maximum-paths config support */
1283 DEFUN(ospf6_max_multipath
,
1284 ospf6_max_multipath_cmd
,
1285 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1286 "Max no of multiple paths for ECMP support\n"
1287 "Number of paths\n")
1289 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1291 int maximum_paths
= strtol(argv
[idx_number
]->arg
, NULL
, 10);
1293 ospf6_maxpath_set(ospf6
, maximum_paths
);
1298 DEFUN(no_ospf6_max_multipath
,
1299 no_ospf6_max_multipath_cmd
,
1300 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
)"]",
1302 "Max no of multiple paths for ECMP support\n"
1303 "Number of paths\n")
1305 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1307 ospf6_maxpath_set(ospf6
, MULTIPATH_NUM
);
1312 static void ospf6_show(struct vty
*vty
, struct ospf6
*o
, json_object
*json
,
1316 struct ospf6_area
*oa
;
1317 char router_id
[16], duration
[32];
1318 struct timeval now
, running
, result
;
1319 char buf
[32], rbuf
[32];
1320 json_object
*json_areas
= NULL
;
1321 const char *adjacency
;
1324 json_areas
= json_object_new_object();
1326 /* process id, router id */
1327 inet_ntop(AF_INET
, &o
->router_id
, router_id
, sizeof(router_id
));
1328 json_object_string_add(json
, "routerId", router_id
);
1332 timersub(&now
, &o
->starttime
, &running
);
1333 timerstring(&running
, duration
, sizeof(duration
));
1334 json_object_string_add(json
, "running", duration
);
1336 /* Redistribute configuration */
1338 json_object_int_add(json
, "lsaMinimumArrivalMsecs",
1341 /* Show SPF parameters */
1342 json_object_int_add(json
, "spfScheduleDelayMsecs",
1344 json_object_int_add(json
, "holdTimeMinMsecs", o
->spf_holdtime
);
1345 json_object_int_add(json
, "holdTimeMaxMsecs",
1346 o
->spf_max_holdtime
);
1347 json_object_int_add(json
, "holdTimeMultiplier",
1348 o
->spf_hold_multiplier
);
1350 json_object_int_add(json
, "maximumPaths", o
->max_multipath
);
1351 json_object_int_add(json
, "preference",
1354 : ZEBRA_OSPF6_DISTANCE_DEFAULT
);
1356 if (o
->ts_spf
.tv_sec
|| o
->ts_spf
.tv_usec
) {
1357 timersub(&now
, &o
->ts_spf
, &result
);
1358 timerstring(&result
, buf
, sizeof(buf
));
1359 ospf6_spf_reason_string(o
->last_spf_reason
, rbuf
,
1361 json_object_boolean_true_add(json
, "spfHasRun");
1362 json_object_string_add(json
, "spfLastExecutedMsecs",
1364 json_object_string_add(json
, "spfLastExecutedReason",
1367 json_object_int_add(
1368 json
, "spfLastDurationSecs",
1369 (long long)o
->ts_spf_duration
.tv_sec
);
1371 json_object_int_add(
1372 json
, "spfLastDurationMsecs",
1373 (long long)o
->ts_spf_duration
.tv_usec
);
1375 json_object_boolean_false_add(json
, "spfHasRun");
1377 if (thread_is_scheduled(o
->t_spf_calc
)) {
1380 json_object_boolean_true_add(json
, "spfTimerActive");
1382 monotime_until(&o
->t_spf_calc
->u
.sands
, NULL
)
1384 json_object_int_add(json
, "spfTimerDueInMsecs",
1387 json_object_boolean_false_add(json
, "spfTimerActive");
1389 json_object_boolean_add(json
, "routerIsStubRouter",
1390 CHECK_FLAG(o
->flag
, OSPF6_STUB_ROUTER
));
1393 json_object_int_add(json
, "numberOfAsScopedLsa",
1396 json_object_int_add(json
, "numberOfAreaInRouter",
1397 listcount(o
->area_list
));
1399 json_object_int_add(json
, "AuthTrailerHigherSeqNo",
1401 json_object_int_add(json
, "AuthTrailerLowerSeqNo", o
->seqnum_l
);
1403 if (CHECK_FLAG(o
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
)) {
1404 if (CHECK_FLAG(o
->config_flags
,
1405 OSPF6_LOG_ADJACENCY_DETAIL
))
1406 adjacency
= "LoggedAll";
1408 adjacency
= "Logged";
1410 adjacency
= "NotLogged";
1411 json_object_string_add(json
, "adjacencyChanges", adjacency
);
1413 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, n
, oa
))
1414 ospf6_area_show(vty
, oa
, json_areas
, use_json
);
1416 json_object_object_add(json
, "areas", json_areas
);
1418 vty_out(vty
, "%s\n",
1419 json_object_to_json_string_ext(
1420 json
, JSON_C_TO_STRING_PRETTY
));
1423 /* process id, router id */
1424 inet_ntop(AF_INET
, &o
->router_id
, router_id
, sizeof(router_id
));
1425 vty_out(vty
, " OSPFv3 Routing Process (0) with Router-ID %s\n",
1430 timersub(&now
, &o
->starttime
, &running
);
1431 timerstring(&running
, duration
, sizeof(duration
));
1432 vty_out(vty
, " Running %s\n", duration
);
1434 /* Redistribute configuration */
1436 vty_out(vty
, " LSA minimum arrival %d msecs\n",
1439 vty_out(vty
, " Maximum-paths %u\n", o
->max_multipath
);
1440 vty_out(vty
, " Administrative distance %u\n",
1441 o
->distance_all
? o
->distance_all
1442 : ZEBRA_OSPF6_DISTANCE_DEFAULT
);
1444 /* Show SPF parameters */
1446 " Initial SPF scheduling delay %d millisec(s)\n"
1447 " Minimum hold time between consecutive SPFs %d millsecond(s)\n"
1448 " Maximum hold time between consecutive SPFs %d millsecond(s)\n"
1449 " Hold time multiplier is currently %d\n",
1450 o
->spf_delay
, o
->spf_holdtime
, o
->spf_max_holdtime
,
1451 o
->spf_hold_multiplier
);
1454 vty_out(vty
, " SPF algorithm ");
1455 if (o
->ts_spf
.tv_sec
|| o
->ts_spf
.tv_usec
) {
1456 timersub(&now
, &o
->ts_spf
, &result
);
1457 timerstring(&result
, buf
, sizeof(buf
));
1458 ospf6_spf_reason_string(o
->last_spf_reason
, rbuf
,
1460 vty_out(vty
, "last executed %s ago, reason %s\n", buf
,
1462 vty_out(vty
, " Last SPF duration %lld sec %lld usec\n",
1463 (long long)o
->ts_spf_duration
.tv_sec
,
1464 (long long)o
->ts_spf_duration
.tv_usec
);
1466 vty_out(vty
, "has not been run\n");
1468 threadtimer_string(now
, o
->t_spf_calc
, buf
, sizeof(buf
));
1469 vty_out(vty
, " SPF timer %s%s\n",
1470 (thread_is_scheduled(o
->t_spf_calc
) ? "due in "
1474 if (CHECK_FLAG(o
->flag
, OSPF6_STUB_ROUTER
))
1475 vty_out(vty
, " Router Is Stub Router\n");
1478 vty_out(vty
, " Number of AS scoped LSAs is %u\n",
1482 vty_out(vty
, " Number of areas in this router is %u\n",
1483 listcount(o
->area_list
));
1485 vty_out(vty
, " Authentication Sequence number info\n");
1486 vty_out(vty
, " Higher sequence no %u, Lower sequence no %u\n",
1487 o
->seqnum_h
, o
->seqnum_l
);
1489 if (CHECK_FLAG(o
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
)) {
1490 if (CHECK_FLAG(o
->config_flags
,
1491 OSPF6_LOG_ADJACENCY_DETAIL
))
1493 " All adjacency changes are logged\n");
1495 vty_out(vty
, " Adjacency changes are logged\n");
1501 for (ALL_LIST_ELEMENTS_RO(o
->area_list
, n
, oa
))
1502 ospf6_area_show(vty
, oa
, json_areas
, use_json
);
1506 DEFUN(show_ipv6_ospf6_vrfs
, show_ipv6_ospf6_vrfs_cmd
,
1507 "show ipv6 ospf6 vrfs [json]",
1508 SHOW_STR IP6_STR OSPF6_STR
"Show OSPF6 VRFs \n" JSON_STR
)
1510 bool uj
= use_json(argc
, argv
);
1511 json_object
*json
= NULL
;
1512 json_object
*json_vrfs
= NULL
;
1513 struct ospf6
*ospf6
= NULL
;
1514 struct listnode
*node
= NULL
;
1516 char buf
[PREFIX_STRLEN
];
1517 static const char header
[] =
1518 "Name Id RouterId ";
1521 json
= json_object_new_object();
1522 json_vrfs
= json_object_new_object();
1525 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1526 json_object
*json_vrf
= NULL
;
1527 const char *name
= NULL
;
1528 int64_t vrf_id_ui
= 0;
1529 struct in_addr router_id
;
1531 router_id
.s_addr
= ospf6
->router_id
;
1534 if (!uj
&& count
== 1)
1535 vty_out(vty
, "%s\n", header
);
1537 json_vrf
= json_object_new_object();
1539 if (ospf6
->vrf_id
== VRF_DEFAULT
)
1540 name
= VRF_DEFAULT_NAME
;
1544 vrf_id_ui
= (ospf6
->vrf_id
== VRF_UNKNOWN
)
1546 : (int64_t)ospf6
->vrf_id
;
1549 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
1550 json_object_string_addf(json_vrf
, "routerId", "%pI4",
1552 json_object_object_add(json_vrfs
, name
, json_vrf
);
1555 vty_out(vty
, "%-25s %-5d %-16s \n", name
,
1557 inet_ntop(AF_INET
, &router_id
, buf
,
1563 json_object_object_add(json
, "vrfs", json_vrfs
);
1564 json_object_int_add(json
, "totalVrfs", count
);
1566 vty_json(vty
, json
);
1569 vty_out(vty
, "\nTotal number of OSPF VRFs: %d\n",
1576 /* show top level structures */
1577 DEFUN(show_ipv6_ospf6
, show_ipv6_ospf6_cmd
,
1578 "show ipv6 ospf6 [vrf <NAME|all>] [json]",
1579 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
"All VRFs\n" JSON_STR
)
1581 struct ospf6
*ospf6
;
1582 struct listnode
*node
;
1583 const char *vrf_name
= NULL
;
1584 bool all_vrf
= false;
1587 bool uj
= use_json(argc
, argv
);
1588 json_object
*json
= NULL
;
1590 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1592 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1593 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1595 json
= json_object_new_object();
1596 ospf6_show(vty
, ospf6
, json
, uj
);
1604 json_object_free(json
);
1606 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1611 DEFUN(show_ipv6_ospf6_route
, show_ipv6_ospf6_route_cmd
,
1612 "show ipv6 ospf6 [vrf <NAME|all>] route [<intra-area|inter-area|external-1|external-2|X:X::X:X|X:X::X:X/M|detail|summary>] [json]",
1613 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1614 "All VRFs\n" ROUTE_STR
1615 "Display Intra-Area routes\n"
1616 "Display Inter-Area routes\n"
1617 "Display Type-1 External routes\n"
1618 "Display Type-2 External routes\n"
1619 "Specify IPv6 address\n"
1620 "Specify IPv6 prefix\n"
1621 "Detailed information\n"
1622 "Summary of route table\n" JSON_STR
)
1624 struct ospf6
*ospf6
;
1625 struct listnode
*node
;
1626 const char *vrf_name
= NULL
;
1627 bool all_vrf
= false;
1629 int idx_arg_start
= 4;
1630 bool uj
= use_json(argc
, argv
);
1632 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1636 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1637 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1638 ospf6_route_table_show(vty
, idx_arg_start
, argc
, argv
,
1639 ospf6
->route_table
, uj
);
1646 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1651 DEFUN(show_ipv6_ospf6_route_match
, show_ipv6_ospf6_route_match_cmd
,
1652 "show ipv6 ospf6 [vrf <NAME|all>] route X:X::X:X/M <match|longer> [json]",
1653 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1654 "All VRFs\n" ROUTE_STR
1655 "Specify IPv6 prefix\n"
1656 "Display routes which match the specified route\n"
1657 "Display routes longer than the specified route\n" JSON_STR
)
1659 struct ospf6
*ospf6
;
1660 struct listnode
*node
;
1661 const char *vrf_name
= NULL
;
1662 bool all_vrf
= false;
1664 int idx_start_arg
= 4;
1665 bool uj
= use_json(argc
, argv
);
1667 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1671 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1672 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1673 ospf6_route_table_show(vty
, idx_start_arg
, argc
, argv
,
1674 ospf6
->route_table
, uj
);
1681 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1686 DEFUN(show_ipv6_ospf6_route_match_detail
,
1687 show_ipv6_ospf6_route_match_detail_cmd
,
1688 "show ipv6 ospf6 [vrf <NAME|all>] route X:X::X:X/M match detail [json]",
1689 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1690 "All VRFs\n" ROUTE_STR
1691 "Specify IPv6 prefix\n"
1692 "Display routes which match the specified route\n"
1693 "Detailed information\n" JSON_STR
)
1695 struct ospf6
*ospf6
;
1696 struct listnode
*node
;
1697 const char *vrf_name
= NULL
;
1698 bool all_vrf
= false;
1700 int idx_start_arg
= 4;
1701 bool uj
= use_json(argc
, argv
);
1703 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1707 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1708 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1709 ospf6_route_table_show(vty
, idx_start_arg
, argc
, argv
,
1710 ospf6
->route_table
, uj
);
1717 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1722 DEFUN(show_ipv6_ospf6_route_type_detail
, show_ipv6_ospf6_route_type_detail_cmd
,
1723 "show ipv6 ospf6 [vrf <NAME|all>] route <intra-area|inter-area|external-1|external-2> detail [json]",
1724 SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
1725 "All VRFs\n" ROUTE_STR
1726 "Display Intra-Area routes\n"
1727 "Display Inter-Area routes\n"
1728 "Display Type-1 External routes\n"
1729 "Display Type-2 External routes\n"
1730 "Detailed information\n" JSON_STR
)
1732 struct ospf6
*ospf6
;
1733 struct listnode
*node
;
1734 const char *vrf_name
= NULL
;
1735 bool all_vrf
= false;
1737 int idx_start_arg
= 4;
1738 bool uj
= use_json(argc
, argv
);
1740 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
1744 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
1745 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
1746 ospf6_route_table_show(vty
, idx_start_arg
, argc
, argv
,
1747 ospf6
->route_table
, uj
);
1754 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
1759 bool ospf6_is_valid_summary_addr(struct vty
*vty
, struct prefix
*p
)
1761 /* Default prefix validation*/
1762 if (is_default_prefix(p
)) {
1764 "Default address should not be configured as summary address.\n");
1768 /* Host route should not be configured as summary address */
1769 if (p
->prefixlen
== IPV6_MAX_BITLEN
) {
1770 vty_out(vty
, "Host route should not be configured as summary address.\n");
1777 /* External Route Aggregation */
1778 DEFPY (ospf6_external_route_aggregation
,
1779 ospf6_external_route_aggregation_cmd
,
1780 "summary-address X:X::X:X/M$prefix [tag (1-4294967295)] [{metric (0-16777215) | metric-type (1-2)$mtype}]",
1781 "External summary address\n"
1782 "Specify IPv6 prefix\n"
1784 "Router tag value\n"
1786 "Advertised metric for this route\n"
1787 "OSPFv3 exterior metric type for summarised routes\n"
1788 "Set OSPFv3 External Type 1/2 metrics\n")
1790 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1793 int ret
= CMD_SUCCESS
;
1795 p
.family
= AF_INET6
;
1796 ret
= str2prefix(prefix_str
, &p
);
1798 vty_out(vty
, "Malformed prefix\n");
1799 return CMD_WARNING_CONFIG_FAILED
;
1802 /* Apply mask for given prefix. */
1805 if (!ospf6_is_valid_summary_addr(vty
, &p
))
1806 return CMD_WARNING_CONFIG_FAILED
;
1815 mtype
= DEFAULT_METRIC_TYPE
;
1817 ret
= ospf6_external_aggr_config_set(ospf6
, &p
, tag
, metric
, mtype
);
1818 if (ret
== OSPF6_FAILURE
) {
1819 vty_out(vty
, "Invalid configuration!!\n");
1820 return CMD_WARNING_CONFIG_FAILED
;
1826 DEFPY(no_ospf6_external_route_aggregation
,
1827 no_ospf6_external_route_aggregation_cmd
,
1828 "no summary-address X:X::X:X/M$prefix [tag (1-4294967295)] [{metric (0-16777215) | metric-type (1-2)}]",
1830 "External summary address\n"
1831 "Specify IPv6 prefix\n"
1833 "Router tag value\n"
1835 "Advertised metric for this route\n"
1836 "OSPFv3 exterior metric type for summarised routes\n"
1837 "Set OSPFv3 External Type 1/2 metrics\n")
1839 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1842 int ret
= CMD_SUCCESS
;
1844 ret
= str2prefix(prefix_str
, &p
);
1846 vty_out(vty
, "Malformed prefix\n");
1847 return CMD_WARNING_CONFIG_FAILED
;
1850 /* Apply mask for given prefix. */
1853 if (!ospf6_is_valid_summary_addr(vty
, &p
))
1854 return CMD_WARNING_CONFIG_FAILED
;
1856 ret
= ospf6_external_aggr_config_unset(ospf6
, &p
);
1857 if (ret
== OSPF6_INVALID
)
1858 vty_out(vty
, "Invalid configuration!!\n");
1863 DEFPY (ospf6_external_route_aggregation_no_advertise
,
1864 ospf6_external_route_aggregation_no_advertise_cmd
,
1865 "summary-address X:X::X:X/M$prefix no-advertise",
1866 "External summary address\n"
1867 "Specify IPv6 prefix\n"
1868 "Don't advertise summary route \n")
1870 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1873 int ret
= CMD_SUCCESS
;
1875 ret
= str2prefix(prefix_str
, &p
);
1877 vty_out(vty
, "Malformed prefix\n");
1878 return CMD_WARNING_CONFIG_FAILED
;
1881 /* Apply mask for given prefix. */
1884 if (!ospf6_is_valid_summary_addr(vty
, &p
))
1885 return CMD_WARNING_CONFIG_FAILED
;
1887 ret
= ospf6_asbr_external_rt_no_advertise(ospf6
, &p
);
1888 if (ret
== OSPF6_INVALID
)
1889 vty_out(vty
, "!!Invalid configuration\n");
1894 DEFPY (no_ospf6_external_route_aggregation_no_advertise
,
1895 no_ospf6_external_route_aggregation_no_advertise_cmd
,
1896 "no summary-address X:X::X:X/M$prefix no-advertise",
1898 "External summary address\n"
1899 "Specify IPv6 prefix\n"
1900 "Adverise summary route to the AS \n")
1902 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1905 int ret
= CMD_SUCCESS
;
1907 ret
= str2prefix(prefix_str
, &p
);
1909 vty_out(vty
, "Malformed prefix\n");
1910 return CMD_WARNING_CONFIG_FAILED
;
1913 /* Apply mask for given prefix. */
1916 if (!ospf6_is_valid_summary_addr(vty
, &p
))
1917 return CMD_WARNING_CONFIG_FAILED
;
1919 ret
= ospf6_asbr_external_rt_advertise(ospf6
, &p
);
1920 if (ret
== OSPF6_INVALID
)
1921 vty_out(vty
, "!!Invalid configuration\n");
1926 DEFPY (ospf6_route_aggregation_timer
,
1927 ospf6_route_aggregation_timer_cmd
,
1928 "aggregation timer (5-1800)",
1929 "External route aggregation\n"
1930 "Delay timer (in seconds)\n"
1931 "Timer interval(in seconds)\n")
1933 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1935 ospf6_external_aggr_delay_timer_set(ospf6
, timer
);
1940 DEFPY (no_ospf6_route_aggregation_timer
,
1941 no_ospf6_route_aggregation_timer_cmd
,
1942 "no aggregation timer [5-1800]",
1944 "External route aggregation\n"
1946 "Timer interval(in seconds)\n")
1948 VTY_DECLVAR_CONTEXT(ospf6
, ospf6
);
1950 ospf6_external_aggr_delay_timer_set(ospf6
,
1951 OSPF6_EXTL_AGGR_DEFAULT_DELAY
);
1956 ospf6_print_vty_external_routes_walkcb(struct hash_bucket
*bucket
, void *arg
)
1958 struct ospf6_route
*rt
= bucket
->data
;
1959 struct vty
*vty
= (struct vty
*)arg
;
1960 static unsigned int count
;
1962 vty_out(vty
, "%pFX ", &rt
->prefix
);
1969 if (OSPF6_EXTERNAL_RT_COUNT(rt
->aggr_route
) == count
)
1972 return HASHWALK_CONTINUE
;
1976 ospf6_print_json_external_routes_walkcb(struct hash_bucket
*bucket
, void *arg
)
1978 struct ospf6_route
*rt
= bucket
->data
;
1979 struct json_object
*json
= (struct json_object
*)arg
;
1980 char buf
[PREFIX2STR_BUFFER
];
1982 static unsigned int count
;
1984 prefix2str(&rt
->prefix
, buf
, sizeof(buf
));
1986 snprintf(exnalbuf
, sizeof(exnalbuf
), "Exnl Addr-%d", count
);
1988 json_object_string_add(json
, exnalbuf
, buf
);
1992 if (OSPF6_EXTERNAL_RT_COUNT(rt
->aggr_route
) == count
)
1995 return HASHWALK_CONTINUE
;
1999 ospf6_show_vrf_name(struct vty
*vty
, struct ospf6
*ospf6
,
2003 if (ospf6
->vrf_id
== VRF_DEFAULT
)
2004 json_object_string_add(json
, "vrfName",
2007 json_object_string_add(json
, "vrfName",
2009 json_object_int_add(json
, "vrfId", ospf6
->vrf_id
);
2011 if (ospf6
->vrf_id
== VRF_DEFAULT
)
2012 vty_out(vty
, "VRF Name: %s\n", "default");
2013 else if (ospf6
->name
)
2014 vty_out(vty
, "VRF Name: %s\n", ospf6
->name
);
2018 #if CONFDATE > 20230131
2019 CPP_NOTICE("Remove JSON object commands with keys containing whitespaces")
2022 ospf6_show_summary_address(struct vty
*vty
, struct ospf6
*ospf6
,
2024 bool uj
, const char *detail
)
2026 struct route_node
*rn
;
2027 static const char header
[] = "Summary-address Metric-type Metric Tag External_Rt_count\n";
2028 json_object
*json_vrf
= NULL
;
2031 ospf6_show_vrf_name(vty
, ospf6
, json_vrf
);
2032 vty_out(vty
, "aggregation delay interval :%u(in seconds)\n\n",
2033 ospf6
->aggr_delay_interval
);
2034 vty_out(vty
, "%s\n", header
);
2036 json_vrf
= json_object_new_object();
2038 ospf6_show_vrf_name(vty
, ospf6
, json_vrf
);
2040 json_object_int_add(json_vrf
, "aggregation delay interval",
2041 ospf6
->aggr_delay_interval
);
2042 json_object_int_add(json_vrf
, "aggregationDelayInterval",
2043 ospf6
->aggr_delay_interval
);
2047 for (rn
= route_top(ospf6
->rt_aggr_tbl
); rn
; rn
= route_next(rn
)) {
2051 struct ospf6_external_aggr_rt
*aggr
= rn
->info
;
2052 json_object
*json_aggr
= NULL
;
2053 char buf
[PREFIX2STR_BUFFER
];
2055 prefix2str(&aggr
->p
, buf
, sizeof(buf
));
2059 json_aggr
= json_object_new_object();
2061 json_object_object_add(json_vrf
,
2065 json_object_string_add(json_aggr
,
2068 json_object_string_add(json_aggr
, "summaryAddress",
2071 json_object_string_add(
2072 json_aggr
, "Metric-type",
2073 (aggr
->mtype
== DEFAULT_METRIC_TYPE
)
2076 json_object_string_add(
2077 json_aggr
, "metricType",
2078 (aggr
->mtype
== DEFAULT_METRIC_TYPE
) ? "E2"
2081 json_object_int_add(json_aggr
, "Metric",
2082 (aggr
->metric
!= -1)
2084 : DEFAULT_DEFAULT_METRIC
);
2086 json_object_int_add(json_aggr
, "Tag",
2089 json_object_int_add(json_aggr
,
2090 "External route count",
2091 OSPF6_EXTERNAL_RT_COUNT(aggr
));
2092 json_object_int_add(json_aggr
, "externalRouteCount",
2093 OSPF6_EXTERNAL_RT_COUNT(aggr
));
2095 if (OSPF6_EXTERNAL_RT_COUNT(aggr
) && detail
) {
2096 json_object_int_add(json_aggr
, "ID",
2098 json_object_int_add(json_aggr
, "Flags",
2100 hash_walk(aggr
->match_extnl_hash
,
2101 ospf6_print_json_external_routes_walkcb
,
2106 vty_out(vty
, "%-22s", buf
);
2108 (aggr
->mtype
== DEFAULT_METRIC_TYPE
)
2109 ? vty_out(vty
, "%-16s", "E2")
2110 : vty_out(vty
, "%-16s", "E1");
2111 vty_out(vty
, "%-11d", (aggr
->metric
!= -1)
2113 : DEFAULT_DEFAULT_METRIC
);
2115 vty_out(vty
, "%-12u", aggr
->tag
);
2117 vty_out(vty
, "%-5ld\n",
2118 OSPF6_EXTERNAL_RT_COUNT(aggr
));
2120 if (OSPF6_EXTERNAL_RT_COUNT(aggr
) && detail
) {
2122 "Matched External routes:\n");
2123 hash_walk(aggr
->match_extnl_hash
,
2124 ospf6_print_vty_external_routes_walkcb
,
2134 json_object_object_add(json
, ospf6
->name
,
2140 DEFPY (show_ipv6_ospf6_external_aggregator
,
2141 show_ipv6_ospf6_external_aggregator_cmd
,
2142 "show ipv6 ospf6 [vrf <NAME|all>] summary-address [detail$detail] [json]",
2148 "Show external summary addresses\n"
2149 "detailed information\n"
2152 bool uj
= use_json(argc
, argv
);
2153 struct ospf6
*ospf6
= NULL
;
2154 json_object
*json
= NULL
;
2155 const char *vrf_name
= NULL
;
2156 struct listnode
*node
;
2157 bool all_vrf
= false;
2161 json
= json_object_new_object();
2163 OSPF6_FIND_VRF_ARGS(argv
, argc
, idx_vrf
, vrf_name
, all_vrf
);
2165 for (ALL_LIST_ELEMENTS_RO(om6
->ospf6
, node
, ospf6
)) {
2166 if (all_vrf
|| strcmp(ospf6
->name
, vrf_name
) == 0) {
2168 ospf6_show_summary_address(vty
, ospf6
, json
, uj
,
2177 vty_json(vty
, json
);
2180 OSPF6_CMD_CHECK_VRF(uj
, all_vrf
, ospf6
);
2185 static void ospf6_stub_router_config_write(struct vty
*vty
, struct ospf6
*ospf6
)
2187 if (CHECK_FLAG(ospf6
->flag
, OSPF6_STUB_ROUTER
))
2188 vty_out(vty
, " stub-router administrative\n");
2192 static int ospf6_distance_config_write(struct vty
*vty
, struct ospf6
*ospf6
)
2194 struct route_node
*rn
;
2195 struct ospf6_distance
*odistance
;
2197 if (ospf6
->distance_all
)
2198 vty_out(vty
, " distance %u\n", ospf6
->distance_all
);
2200 if (ospf6
->distance_intra
|| ospf6
->distance_inter
2201 || ospf6
->distance_external
) {
2202 vty_out(vty
, " distance ospf6");
2204 if (ospf6
->distance_intra
)
2205 vty_out(vty
, " intra-area %u", ospf6
->distance_intra
);
2206 if (ospf6
->distance_inter
)
2207 vty_out(vty
, " inter-area %u", ospf6
->distance_inter
);
2208 if (ospf6
->distance_external
)
2209 vty_out(vty
, " external %u", ospf6
->distance_external
);
2214 for (rn
= route_top(ospf6
->distance_table
); rn
; rn
= route_next(rn
))
2215 if ((odistance
= rn
->info
) != NULL
)
2216 vty_out(vty
, " distance %u %pFX %s\n",
2217 odistance
->distance
, &rn
->p
,
2218 odistance
->access_list
? odistance
->access_list
2223 static int ospf6_asbr_summary_config_write(struct vty
*vty
, struct ospf6
*ospf6
)
2225 struct route_node
*rn
;
2226 struct ospf6_external_aggr_rt
*aggr
;
2227 char buf
[PREFIX2STR_BUFFER
];
2229 if (ospf6
->aggr_delay_interval
!= OSPF6_EXTL_AGGR_DEFAULT_DELAY
)
2230 vty_out(vty
, " aggregation timer %u\n",
2231 ospf6
->aggr_delay_interval
);
2233 /* print 'summary-address A:B::C:D/M' */
2234 for (rn
= route_top(ospf6
->rt_aggr_tbl
); rn
; rn
= route_next(rn
)) {
2240 prefix2str(&aggr
->p
, buf
, sizeof(buf
));
2241 vty_out(vty
, " summary-address %s", buf
);
2243 vty_out(vty
, " tag %u", aggr
->tag
);
2245 if (aggr
->metric
!= -1)
2246 vty_out(vty
, " metric %d", aggr
->metric
);
2248 if (aggr
->mtype
!= DEFAULT_METRIC_TYPE
)
2249 vty_out(vty
, " metric-type %d", aggr
->mtype
);
2251 if (CHECK_FLAG(aggr
->aggrflags
,
2252 OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE
))
2253 vty_out(vty
, " no-advertise");
2261 /* OSPF configuration write function. */
2262 static int config_write_ospf6(struct vty
*vty
)
2264 struct ospf6
*ospf6
;
2265 struct listnode
*node
, *nnode
;
2267 /* OSPFv3 configuration. */
2271 for (ALL_LIST_ELEMENTS(om6
->ospf6
, node
, nnode
, ospf6
)) {
2272 if (ospf6
->name
&& strcmp(ospf6
->name
, VRF_DEFAULT_NAME
))
2273 vty_out(vty
, "router ospf6 vrf %s\n", ospf6
->name
);
2275 vty_out(vty
, "router ospf6\n");
2277 if (ospf6
->router_id_static
!= 0)
2278 vty_out(vty
, " ospf6 router-id %pI4\n",
2279 &ospf6
->router_id_static
);
2281 if (CHECK_FLAG(ospf6
->config_flags
,
2282 OSPF6_SEND_EXTRA_DATA_TO_ZEBRA
))
2283 vty_out(vty
, " ospf6 send-extra-data zebra\n");
2285 /* log-adjacency-changes flag print. */
2286 if (CHECK_FLAG(ospf6
->config_flags
,
2287 OSPF6_LOG_ADJACENCY_CHANGES
)) {
2288 if (CHECK_FLAG(ospf6
->config_flags
,
2289 OSPF6_LOG_ADJACENCY_DETAIL
))
2290 vty_out(vty
, " log-adjacency-changes detail\n");
2291 else if (!SAVE_OSPF6_LOG_ADJACENCY_CHANGES
)
2292 vty_out(vty
, " log-adjacency-changes\n");
2293 } else if (SAVE_OSPF6_LOG_ADJACENCY_CHANGES
) {
2294 vty_out(vty
, " no log-adjacency-changes\n");
2297 if (ospf6
->ref_bandwidth
!= OSPF6_REFERENCE_BANDWIDTH
)
2298 vty_out(vty
, " auto-cost reference-bandwidth %d\n",
2299 ospf6
->ref_bandwidth
);
2301 if (ospf6
->write_oi_count
2302 != OSPF6_WRITE_INTERFACE_COUNT_DEFAULT
)
2303 vty_out(vty
, " write-multiplier %d\n",
2304 ospf6
->write_oi_count
);
2306 /* LSA timers print. */
2307 if (ospf6
->lsa_minarrival
!= OSPF_MIN_LS_ARRIVAL
)
2308 vty_out(vty
, " timers lsa min-arrival %d\n",
2309 ospf6
->lsa_minarrival
);
2311 /* ECMP max path config */
2312 if (ospf6
->max_multipath
!= MULTIPATH_NUM
)
2313 vty_out(vty
, " maximum-paths %d\n",
2314 ospf6
->max_multipath
);
2316 ospf6_stub_router_config_write(vty
, ospf6
);
2317 ospf6_redistribute_config_write(vty
, ospf6
);
2318 ospf6_area_config_write(vty
, ospf6
);
2319 ospf6_spf_config_write(vty
, ospf6
);
2320 ospf6_distance_config_write(vty
, ospf6
);
2321 ospf6_distribute_config_write(vty
, ospf6
);
2322 ospf6_asbr_summary_config_write(vty
, ospf6
);
2323 config_write_ospf6_gr(vty
, ospf6
);
2324 config_write_ospf6_gr_helper(vty
, ospf6
);
2326 vty_out(vty
, "exit\n");
2327 vty_out(vty
, "!\n");
2332 static int config_write_ospf6(struct vty
*vty
);
2333 /* OSPF6 node structure. */
2334 static struct cmd_node ospf6_node
= {
2337 .parent_node
= CONFIG_NODE
,
2338 .prompt
= "%s(config-ospf6)# ",
2339 .config_write
= config_write_ospf6
,
2342 void install_element_ospf6_clear_process(void)
2344 install_element(ENABLE_NODE
, &clear_router_ospf6_cmd
);
2347 /* Install ospf related commands. */
2348 void ospf6_top_init(void)
2350 /* Install ospf6 top node. */
2351 install_node(&ospf6_node
);
2353 install_element(VIEW_NODE
, &show_ipv6_ospf6_cmd
);
2354 install_element(VIEW_NODE
, &show_ipv6_ospf6_vrfs_cmd
);
2355 install_element(CONFIG_NODE
, &router_ospf6_cmd
);
2356 install_element(CONFIG_NODE
, &no_router_ospf6_cmd
);
2358 install_element(VIEW_NODE
, &show_ipv6_ospf6_route_cmd
);
2359 install_element(VIEW_NODE
, &show_ipv6_ospf6_route_match_cmd
);
2360 install_element(VIEW_NODE
, &show_ipv6_ospf6_route_match_detail_cmd
);
2361 install_element(VIEW_NODE
, &show_ipv6_ospf6_route_type_detail_cmd
);
2363 install_default(OSPF6_NODE
);
2364 install_element(OSPF6_NODE
, &ospf6_router_id_cmd
);
2365 install_element(OSPF6_NODE
, &no_ospf6_router_id_cmd
);
2366 install_element(OSPF6_NODE
, &ospf6_log_adjacency_changes_cmd
);
2367 install_element(OSPF6_NODE
, &ospf6_log_adjacency_changes_detail_cmd
);
2368 install_element(OSPF6_NODE
, &no_ospf6_log_adjacency_changes_cmd
);
2369 install_element(OSPF6_NODE
, &no_ospf6_log_adjacency_changes_detail_cmd
);
2370 install_element(OSPF6_NODE
, &ospf6_send_extra_data_cmd
);
2372 /* LSA timers commands */
2373 install_element(OSPF6_NODE
, &ospf6_timers_lsa_cmd
);
2374 install_element(OSPF6_NODE
, &no_ospf6_timers_lsa_cmd
);
2376 install_element(OSPF6_NODE
, &ospf6_interface_area_cmd
);
2377 install_element(OSPF6_NODE
, &no_ospf6_interface_area_cmd
);
2378 install_element(OSPF6_NODE
, &ospf6_stub_router_admin_cmd
);
2379 install_element(OSPF6_NODE
, &no_ospf6_stub_router_admin_cmd
);
2381 /* maximum-paths command */
2382 install_element(OSPF6_NODE
, &ospf6_max_multipath_cmd
);
2383 install_element(OSPF6_NODE
, &no_ospf6_max_multipath_cmd
);
2385 /* ASBR Summarisation */
2386 install_element(OSPF6_NODE
, &ospf6_external_route_aggregation_cmd
);
2387 install_element(OSPF6_NODE
, &no_ospf6_external_route_aggregation_cmd
);
2388 install_element(OSPF6_NODE
,
2389 &ospf6_external_route_aggregation_no_advertise_cmd
);
2390 install_element(OSPF6_NODE
,
2391 &no_ospf6_external_route_aggregation_no_advertise_cmd
);
2392 install_element(OSPF6_NODE
, &ospf6_route_aggregation_timer_cmd
);
2393 install_element(OSPF6_NODE
, &no_ospf6_route_aggregation_timer_cmd
);
2394 install_element(VIEW_NODE
, &show_ipv6_ospf6_external_aggregator_cmd
);
2396 install_element(OSPF6_NODE
, &ospf6_distance_cmd
);
2397 install_element(OSPF6_NODE
, &no_ospf6_distance_cmd
);
2398 install_element(OSPF6_NODE
, &ospf6_distance_ospf6_cmd
);
2399 install_element(OSPF6_NODE
, &no_ospf6_distance_ospf6_cmd
);