2 * This is an implementation of RFC 3623 Graceful OSPF Restart.
4 * Copyright 2021 NetDEF (c), All rights reserved.
5 * Copyright 2020 6WIND (c), All rights reserved.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 #include "ospfd/ospfd.h"
32 #include "ospfd/ospf_abr.h"
33 #include "ospfd/ospf_flood.h"
34 #include "ospfd/ospf_ism.h"
35 #include "ospfd/ospf_interface.h"
36 #include "ospfd/ospf_asbr.h"
37 #include "ospfd/ospf_lsa.h"
38 #include "ospfd/ospf_route.h"
39 #include "ospfd/ospf_zebra.h"
40 #include "ospfd/ospf_lsdb.h"
41 #include "ospfd/ospf_neighbor.h"
42 #include "ospfd/ospf_opaque.h"
43 #include "ospfd/ospf_nsm.h"
44 #include "ospfd/ospf_gr.h"
45 #include "ospfd/ospf_errors.h"
46 #include "ospfd/ospf_dump.h"
47 #ifndef VTYSH_EXTRACT_PL
48 #include "ospfd/ospf_gr_clippy.c"
51 static void ospf_gr_nvm_delete(struct ospf
*ospf
);
53 /* Lookup self-originated Grace-LSA in the LSDB. */
54 static struct ospf_lsa
*ospf_gr_lsa_lookup(struct ospf
*ospf
,
55 struct ospf_area
*area
)
58 struct in_addr lsa_id
;
59 uint32_t lsa_id_host_byte_order
;
61 lsa_id_host_byte_order
= SET_OPAQUE_LSID(OPAQUE_TYPE_GRACE_LSA
, 0);
62 lsa_id
.s_addr
= htonl(lsa_id_host_byte_order
);
63 lsa
= ospf_lsa_lookup(ospf
, area
, OSPF_OPAQUE_LINK_LSA
, lsa_id
,
69 /* Fill in fields of the Grace-LSA that is being originated. */
70 static void ospf_gr_lsa_body_set(struct ospf_gr_info
*gr_info
,
71 struct ospf_interface
*oi
, struct stream
*s
)
73 struct grace_tlv_graceperiod tlv_period
= {};
74 struct grace_tlv_restart_reason tlv_reason
= {};
75 struct grace_tlv_restart_addr tlv_address
= {};
77 /* Put grace period. */
78 tlv_period
.header
.type
= htons(GRACE_PERIOD_TYPE
);
79 tlv_period
.header
.length
= htons(GRACE_PERIOD_LENGTH
);
80 tlv_period
.interval
= htonl(gr_info
->grace_period
);
81 stream_put(s
, &tlv_period
, sizeof(tlv_period
));
83 /* Put restart reason. */
84 tlv_reason
.header
.type
= htons(RESTART_REASON_TYPE
);
85 tlv_reason
.header
.length
= htons(RESTART_REASON_LENGTH
);
86 if (gr_info
->restart_support
)
87 tlv_reason
.reason
= OSPF_GR_SW_RESTART
;
89 tlv_reason
.reason
= OSPF_GR_UNKNOWN_RESTART
;
90 stream_put(s
, &tlv_reason
, sizeof(tlv_reason
));
93 if (oi
->type
== OSPF_IFTYPE_BROADCAST
|| oi
->type
== OSPF_IFTYPE_NBMA
94 || oi
->type
== OSPF_IFTYPE_POINTOMULTIPOINT
) {
95 tlv_address
.header
.type
= htons(RESTARTER_IP_ADDR_TYPE
);
96 tlv_address
.header
.length
= htons(RESTARTER_IP_ADDR_LEN
);
97 tlv_address
.addr
= oi
->address
->u
.prefix4
;
98 stream_put(s
, &tlv_address
, sizeof(tlv_address
));
102 /* Generate Grace-LSA for a given interface. */
103 static struct ospf_lsa
*ospf_gr_lsa_new(struct ospf_interface
*oi
)
106 struct lsa_header
*lsah
;
107 struct ospf_lsa
*new;
108 uint8_t options
, lsa_type
;
109 struct in_addr lsa_id
;
110 uint32_t lsa_id_host_byte_order
;
113 /* Create a stream for LSA. */
114 s
= stream_new(OSPF_MAX_LSA_SIZE
);
116 lsah
= (struct lsa_header
*)STREAM_DATA(s
);
118 options
= LSA_OPTIONS_GET(oi
->area
);
119 options
|= LSA_OPTIONS_NSSA_GET(oi
->area
);
120 options
|= OSPF_OPTION_O
;
122 lsa_type
= OSPF_OPAQUE_LINK_LSA
;
123 lsa_id_host_byte_order
= SET_OPAQUE_LSID(OPAQUE_TYPE_GRACE_LSA
, 0);
124 lsa_id
.s_addr
= htonl(lsa_id_host_byte_order
);
126 /* Set opaque-LSA header fields. */
127 lsa_header_set(s
, options
, lsa_type
, lsa_id
, oi
->ospf
->router_id
);
129 /* Set opaque-LSA body fields. */
130 ospf_gr_lsa_body_set(&oi
->ospf
->gr_info
, oi
, s
);
133 length
= stream_get_endp(s
);
134 lsah
->length
= htons(length
);
136 /* Now, create an OSPF LSA instance. */
137 new = ospf_lsa_new_and_data(length
);
139 if (IS_DEBUG_OSPF_GR
)
140 zlog_debug("LSA[Type%d:%pI4]: Create an Opaque-LSA/GR instance",
143 new->area
= oi
->area
;
145 SET_FLAG(new->flags
, OSPF_LSA_SELF
);
146 memcpy(new->data
, lsah
, length
);
152 /* Originate and install Grace-LSA for a given interface. */
153 static void ospf_gr_lsa_originate(struct ospf_interface
*oi
, bool maxage
)
155 struct ospf_lsa
*lsa
, *old
;
157 if (ospf_interface_neighbor_count(oi
) == 0)
160 /* Create new Grace-LSA. */
161 lsa
= ospf_gr_lsa_new(oi
);
163 zlog_warn("%s: ospf_gr_lsa_new() failed", __func__
);
168 lsa
->data
->ls_age
= htons(OSPF_LSA_MAXAGE
);
170 /* Find the old LSA and increase the seqno. */
171 old
= ospf_gr_lsa_lookup(oi
->ospf
, oi
->area
);
173 lsa
->data
->ls_seqnum
= lsa_seqnum_increment(old
);
175 /* Install this LSA into LSDB. */
176 if (ospf_lsa_install(oi
->ospf
, oi
, lsa
) == NULL
) {
177 zlog_warn("%s: ospf_lsa_install() failed", __func__
);
178 ospf_lsa_unlock(&lsa
);
182 /* Update new LSA origination count. */
183 oi
->ospf
->lsa_originate_count
++;
185 /* Flood the LSA through out the interface */
186 ospf_flood_through_interface(oi
, NULL
, lsa
);
189 /* Flush all self-originated Grace-LSAs. */
190 static void ospf_gr_flush_grace_lsas(struct ospf
*ospf
)
192 struct ospf_area
*area
;
193 struct listnode
*anode
;
195 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, anode
, area
)) {
196 struct ospf_interface
*oi
;
197 struct listnode
*inode
;
199 if (IS_DEBUG_OSPF_GR
)
201 "GR: flushing self-originated Grace-LSAs [area %pI4]",
204 for (ALL_LIST_ELEMENTS_RO(area
->oiflist
, inode
, oi
))
205 ospf_gr_lsa_originate(oi
, true);
209 /* Exit from the Graceful Restart mode. */
210 static void ospf_gr_restart_exit(struct ospf
*ospf
, const char *reason
)
212 struct ospf_area
*area
;
213 struct listnode
*onode
, *anode
;
215 if (IS_DEBUG_OSPF_GR
)
216 zlog_debug("GR: exiting graceful restart: %s", reason
);
218 ospf
->gr_info
.restart_in_progress
= false;
219 OSPF_TIMER_OFF(ospf
->gr_info
.t_grace_period
);
221 /* Record in non-volatile memory that the restart is complete. */
222 ospf_gr_nvm_delete(ospf
);
224 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, onode
, area
)) {
225 struct ospf_interface
*oi
;
228 * 1) The router should reoriginate its router-LSAs for all
229 * attached areas in order to make sure they have the correct
232 ospf_router_lsa_update_area(area
);
235 * 2) The router should reoriginate network-LSAs on all segments
236 * where it is the Designated Router.
238 for (ALL_LIST_ELEMENTS_RO(area
->oiflist
, anode
, oi
))
239 if (oi
->state
== ISM_DR
)
240 ospf_network_lsa_update(oi
);
244 * 5) Any received self-originated LSAs that are no longer valid should
247 ospf_schedule_abr_task(ospf
);
250 * 3) The router reruns its OSPF routing calculations, this time
251 * installing the results into the system forwarding table, and
252 * originating summary-LSAs, Type-7 LSAs and AS-external-LSAs as
255 * 4) Any remnant entries in the system forwarding table that were
256 * installed before the restart, but that are no longer valid,
259 ospf
->gr_info
.finishing_restart
= true;
260 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_GR_FINISH
);
262 /* 6) Any grace-LSAs that the router originated should be flushed. */
263 ospf_gr_flush_grace_lsas(ospf
);
266 /* Check if a Router-LSA contains a given link. */
267 static bool ospf_router_lsa_contains_adj(struct ospf_lsa
*lsa
,
270 struct router_lsa
*rl
;
272 rl
= (struct router_lsa
*)lsa
->data
;
273 for (int i
= 0; i
< ntohs(rl
->links
); i
++) {
274 struct in_addr
*link_id
= &rl
->link
[i
].link_id
;
276 if (rl
->link
[i
].type
!= LSA_LINK_TYPE_POINTOPOINT
)
279 if (IPV4_ADDR_SAME(id
, link_id
))
286 static bool ospf_gr_check_router_lsa_consistency(struct ospf
*ospf
,
287 struct ospf_area
*area
,
288 struct ospf_lsa
*lsa
)
290 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_SELF
)) {
291 struct ospf_lsa
*lsa_self
= lsa
;
292 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
294 for (int i
= 0; i
< ntohs(rl
->links
); i
++) {
295 struct in_addr
*link_id
= &rl
->link
[i
].link_id
;
296 struct ospf_lsa
*lsa_adj
;
298 if (rl
->link
[i
].type
!= LSA_LINK_TYPE_POINTOPOINT
)
301 lsa_adj
= ospf_lsa_lookup_by_id(area
, OSPF_ROUTER_LSA
,
306 if (!ospf_router_lsa_contains_adj(lsa_adj
,
307 &lsa_self
->data
->id
))
311 struct ospf_lsa
*lsa_self
;
313 lsa_self
= ospf_lsa_lookup_by_id(area
, OSPF_ROUTER_LSA
,
316 || !CHECK_FLAG(lsa_self
->flags
, OSPF_LSA_RECEIVED
))
319 if (ospf_router_lsa_contains_adj(lsa
, &ospf
->router_id
)
320 != ospf_router_lsa_contains_adj(lsa_self
, &lsa
->data
->id
))
328 * Check for LSAs that are inconsistent with the pre-restart LSAs, and abort the
329 * ongoing graceful restart when that's the case.
331 void ospf_gr_check_lsdb_consistency(struct ospf
*ospf
, struct ospf_area
*area
)
333 struct route_node
*rn
;
334 struct ospf_lsa
*lsa
;
336 for (rn
= route_top(ROUTER_LSDB(area
)); rn
; rn
= route_next(rn
)) {
341 if (!ospf_gr_check_router_lsa_consistency(ospf
, area
, lsa
)) {
344 snprintfrr(reason
, sizeof(reason
),
345 "detected inconsistent LSA[%s] [area %pI4]",
346 dump_lsa_key(lsa
), &area
->area_id
);
347 ospf_gr_restart_exit(ospf
, reason
);
348 route_unlock_node(rn
);
354 /* Lookup neighbor by address in a given OSPF area. */
355 static struct ospf_neighbor
*
356 ospf_area_nbr_lookup_by_addr(struct ospf_area
*area
, struct in_addr
*addr
)
358 struct ospf_interface
*oi
;
359 struct ospf_neighbor
*nbr
;
360 struct listnode
*node
;
362 for (ALL_LIST_ELEMENTS_RO(area
->oiflist
, node
, oi
)) {
363 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, addr
);
371 /* Lookup neighbor by Router ID in a given OSPF area. */
372 static struct ospf_neighbor
*
373 ospf_area_nbr_lookup_by_routerid(struct ospf_area
*area
, struct in_addr
*id
)
375 struct ospf_interface
*oi
;
376 struct ospf_neighbor
*nbr
;
377 struct listnode
*node
;
379 for (ALL_LIST_ELEMENTS_RO(area
->oiflist
, node
, oi
)) {
380 nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, id
);
388 /* Check if there's a fully formed adjacency with the given neighbor ID. */
389 static bool ospf_gr_check_adj_id(struct ospf_area
*area
,
390 struct in_addr
*nbr_id
)
392 struct ospf_neighbor
*nbr
;
394 nbr
= ospf_area_nbr_lookup_by_routerid(area
, nbr_id
);
395 if (!nbr
|| nbr
->state
< NSM_Full
) {
396 if (IS_DEBUG_OSPF_GR
)
397 zlog_debug("GR: missing adjacency to router %pI4",
405 static bool ospf_gr_check_adjs_lsa_transit(struct ospf_area
*area
,
406 struct in_addr
*link_id
)
408 struct ospf
*ospf
= area
->ospf
;
409 struct ospf_interface
*oi
;
412 * Check if the transit network refers to a local interface (in which
413 * case it must be a DR for that network).
415 oi
= ospf_if_lookup_by_local_addr(ospf
, NULL
, *link_id
);
417 struct ospf_lsa
*lsa
;
418 struct network_lsa
*nlsa
;
421 /* Lookup Network LSA corresponding to this interface. */
422 lsa
= ospf_lsa_lookup_by_id(area
, OSPF_NETWORK_LSA
, *link_id
);
426 /* Iterate over all routers present in the network. */
427 nlsa
= (struct network_lsa
*)lsa
->data
;
428 cnt
= (lsa
->size
- (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
429 for (size_t i
= 0; i
< cnt
; i
++) {
430 struct in_addr
*nbr_id
= &nlsa
->routers
[i
];
432 /* Skip self in the pseudonode. */
433 if (IPV4_ADDR_SAME(nbr_id
, &ospf
->router_id
))
437 * Check if there's a fully formed adjacency with this
440 if (!ospf_gr_check_adj_id(area
, nbr_id
))
444 struct ospf_neighbor
*nbr
;
446 /* Check if there's a fully formed adjacency with the DR. */
447 nbr
= ospf_area_nbr_lookup_by_addr(area
, link_id
);
448 if (!nbr
|| nbr
->state
< NSM_Full
) {
449 if (IS_DEBUG_OSPF_GR
)
451 "GR: missing adjacency to DR router %pI4",
460 static bool ospf_gr_check_adjs_lsa(struct ospf_area
*area
, struct ospf_lsa
*lsa
)
462 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
464 for (int i
= 0; i
< ntohs(rl
->links
); i
++) {
465 struct in_addr
*link_id
= &rl
->link
[i
].link_id
;
467 switch (rl
->link
[i
].type
) {
468 case LSA_LINK_TYPE_POINTOPOINT
:
469 if (!ospf_gr_check_adj_id(area
, link_id
))
472 case LSA_LINK_TYPE_TRANSIT
:
473 if (!ospf_gr_check_adjs_lsa_transit(area
, link_id
))
485 * Check if all adjacencies prior to the restart were reestablished.
487 * This is done using pre-restart Router LSAs and pre-restart Network LSAs
488 * received from the helping neighbors.
490 void ospf_gr_check_adjs(struct ospf
*ospf
)
492 struct ospf_area
*area
;
493 struct listnode
*node
;
495 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
496 struct ospf_lsa
*lsa_self
;
498 lsa_self
= ospf_lsa_lookup_by_id(area
, OSPF_ROUTER_LSA
,
500 if (!lsa_self
|| !ospf_gr_check_adjs_lsa(area
, lsa_self
)) {
501 if (IS_DEBUG_OSPF_GR
)
503 "GR: not all adjacencies were reestablished yet [area %pI4]",
509 ospf_gr_restart_exit(ospf
, "all adjacencies were reestablished");
512 /* Handling of grace period expiry. */
513 static void ospf_gr_grace_period_expired(struct thread
*thread
)
515 struct ospf
*ospf
= THREAD_ARG(thread
);
517 ospf
->gr_info
.t_grace_period
= NULL
;
518 ospf_gr_restart_exit(ospf
, "grace period has expired");
522 * Returns the path of the file (non-volatile memory) that contains GR status
525 static char *ospf_gr_nvm_filepath(struct ospf
*ospf
)
527 static char filepath
[MAXPATHLEN
];
528 char instance
[16] = "";
531 snprintf(instance
, sizeof(instance
), "-%d", ospf
->instance
);
532 snprintf(filepath
, sizeof(filepath
), OSPFD_GR_STATE
, instance
);
537 * Record in non-volatile memory that the given OSPF instance is attempting to
538 * perform a graceful restart.
540 static void ospf_gr_nvm_update(struct ospf
*ospf
)
543 const char *inst_name
;
545 json_object
*json_instances
;
546 json_object
*json_instance
;
548 filepath
= ospf_gr_nvm_filepath(ospf
);
549 inst_name
= ospf_get_name(ospf
);
551 json
= json_object_from_file(filepath
);
553 json
= json_object_new_object();
555 json_object_object_get_ex(json
, "instances", &json_instances
);
556 if (!json_instances
) {
557 json_instances
= json_object_new_object();
558 json_object_object_add(json
, "instances", json_instances
);
561 json_object_object_get_ex(json_instances
, inst_name
, &json_instance
);
562 if (!json_instance
) {
563 json_instance
= json_object_new_object();
564 json_object_object_add(json_instances
, inst_name
,
569 * Record not only the grace period, but also a UNIX timestamp
570 * corresponding to the end of that period. That way, once ospfd is
571 * restarted, it will be possible to take into account the time that
572 * passed while ospfd wasn't running.
574 json_object_int_add(json_instance
, "gracePeriod",
575 ospf
->gr_info
.grace_period
);
576 json_object_int_add(json_instance
, "timestamp",
577 time(NULL
) + ospf
->gr_info
.grace_period
);
579 json_object_to_file_ext(filepath
, json
, JSON_C_TO_STRING_PRETTY
);
580 json_object_free(json
);
584 * Delete GR status information about the given OSPF instance from non-volatile
587 static void ospf_gr_nvm_delete(struct ospf
*ospf
)
590 const char *inst_name
;
592 json_object
*json_instances
;
594 filepath
= ospf_gr_nvm_filepath(ospf
);
595 inst_name
= ospf_get_name(ospf
);
597 json
= json_object_from_file(filepath
);
599 json
= json_object_new_object();
601 json_object_object_get_ex(json
, "instances", &json_instances
);
602 if (!json_instances
) {
603 json_instances
= json_object_new_object();
604 json_object_object_add(json
, "instances", json_instances
);
607 json_object_object_del(json_instances
, inst_name
);
609 json_object_to_file_ext(filepath
, json
, JSON_C_TO_STRING_PRETTY
);
610 json_object_free(json
);
614 * Fetch from non-volatile memory whether the given OSPF instance is performing
615 * a graceful shutdown or not.
617 void ospf_gr_nvm_read(struct ospf
*ospf
)
620 const char *inst_name
;
622 json_object
*json_instances
;
623 json_object
*json_instance
;
624 json_object
*json_timestamp
;
625 time_t timestamp
= 0;
627 filepath
= ospf_gr_nvm_filepath(ospf
);
628 inst_name
= ospf_get_name(ospf
);
630 json
= json_object_from_file(filepath
);
632 json
= json_object_new_object();
634 json_object_object_get_ex(json
, "instances", &json_instances
);
635 if (!json_instances
) {
636 json_instances
= json_object_new_object();
637 json_object_object_add(json
, "instances", json_instances
);
640 json_object_object_get_ex(json_instances
, inst_name
, &json_instance
);
641 if (!json_instance
) {
642 json_instance
= json_object_new_object();
643 json_object_object_add(json_instances
, inst_name
,
647 json_object_object_get_ex(json_instance
, "timestamp", &json_timestamp
);
648 if (json_timestamp
) {
650 unsigned long remaining_time
;
652 /* Check if the grace period has already expired. */
654 timestamp
= json_object_get_int(json_timestamp
);
655 if (now
> timestamp
) {
656 ospf_gr_restart_exit(
657 ospf
, "grace period has expired already");
659 /* Schedule grace period timeout. */
660 ospf
->gr_info
.restart_in_progress
= true;
661 remaining_time
= timestamp
- time(NULL
);
662 if (IS_DEBUG_OSPF_GR
)
664 "GR: remaining time until grace period expires: %lu(s)",
666 thread_add_timer(master
, ospf_gr_grace_period_expired
,
667 ospf
, remaining_time
,
668 &ospf
->gr_info
.t_grace_period
);
672 json_object_object_del(json_instances
, inst_name
);
674 json_object_to_file_ext(filepath
, json
, JSON_C_TO_STRING_PRETTY
);
675 json_object_free(json
);
678 /* Prepare to start a Graceful Restart. */
679 static void ospf_gr_prepare(void)
682 struct ospf_interface
*oi
;
683 struct listnode
*onode
;
685 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, onode
, ospf
)) {
686 struct listnode
*inode
;
688 if (!ospf
->gr_info
.restart_support
689 || ospf
->gr_info
.prepare_in_progress
)
692 if (IS_DEBUG_OSPF_GR
)
694 "GR: preparing to perform a graceful restart [period %u second(s)] [vrf %s]",
695 ospf
->gr_info
.grace_period
,
696 ospf_vrf_id_to_name(ospf
->vrf_id
));
698 if (!CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
700 "%s: failed to activate graceful restart: opaque capability not enabled",
705 /* Freeze OSPF routes in the RIB. */
706 if (ospf_zebra_gr_enable(ospf
, ospf
->gr_info
.grace_period
)) {
708 "%s: failed to activate graceful restart: not connected to zebra",
713 /* Send a Grace-LSA to all neighbors. */
714 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, inode
, oi
))
715 ospf_gr_lsa_originate(oi
, false);
717 /* Record end of the grace period in non-volatile memory. */
718 ospf_gr_nvm_update(ospf
);
721 * Mark that a Graceful Restart preparation is in progress, to
722 * prevent ospfd from flushing its self-originated LSAs on exit.
724 ospf
->gr_info
.prepare_in_progress
= true;
728 DEFPY(graceful_restart_prepare
, graceful_restart_prepare_cmd
,
729 "graceful-restart prepare ip ospf",
730 "Graceful Restart commands\n"
731 "Prepare upcoming graceful restart\n"
733 "Prepare to restart the OSPF process")
736 struct listnode
*node
;
738 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
739 if (!CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
741 "%% Can't start graceful restart: opaque capability not enabled (VRF %s)\n\n",
742 ospf_get_name(ospf
));
752 DEFPY(graceful_restart
, graceful_restart_cmd
,
753 "graceful-restart [grace-period (1-1800)$grace_period]",
755 "Maximum length of the 'grace period'\n"
756 "Maximum length of the 'grace period' in seconds\n")
758 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
760 /* Check and get restart period if present. */
761 if (!grace_period_str
)
762 grace_period
= OSPF_DFLT_GRACE_INTERVAL
;
764 ospf
->gr_info
.restart_support
= true;
765 ospf
->gr_info
.grace_period
= grace_period
;
770 DEFPY(no_graceful_restart
, no_graceful_restart_cmd
,
771 "no graceful-restart [grace-period (1-1800)]",
773 "Maximum length of the 'grace period'\n"
774 "Maximum length of the 'grace period' in seconds\n")
776 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
778 if (!ospf
->gr_info
.restart_support
)
781 if (ospf
->gr_info
.prepare_in_progress
) {
783 "%% Error: Graceful Restart preparation in progress\n");
787 ospf
->gr_info
.restart_support
= false;
788 ospf
->gr_info
.grace_period
= OSPF_DFLT_GRACE_INTERVAL
;
793 void ospf_gr_init(void)
795 install_element(ENABLE_NODE
, &graceful_restart_prepare_cmd
);
796 install_element(OSPF_NODE
, &graceful_restart_cmd
);
797 install_element(OSPF_NODE
, &no_graceful_restart_cmd
);