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 #include "ospfd/ospf_gr_clippy.c"
49 static void ospf_gr_nvm_delete(struct ospf
*ospf
);
51 /* Lookup self-originated Grace-LSA in the LSDB. */
52 static struct ospf_lsa
*ospf_gr_lsa_lookup(struct ospf
*ospf
,
53 struct ospf_area
*area
)
56 struct in_addr lsa_id
;
57 uint32_t lsa_id_host_byte_order
;
59 lsa_id_host_byte_order
= SET_OPAQUE_LSID(OPAQUE_TYPE_GRACE_LSA
, 0);
60 lsa_id
.s_addr
= htonl(lsa_id_host_byte_order
);
61 lsa
= ospf_lsa_lookup(ospf
, area
, OSPF_OPAQUE_LINK_LSA
, lsa_id
,
67 /* Fill in fields of the Grace-LSA that is being originated. */
68 static void ospf_gr_lsa_body_set(struct ospf_gr_info
*gr_info
,
69 struct ospf_interface
*oi
, struct stream
*s
)
71 struct grace_tlv_graceperiod tlv_period
= {};
72 struct grace_tlv_restart_reason tlv_reason
= {};
73 struct grace_tlv_restart_addr tlv_address
= {};
75 /* Put grace period. */
76 tlv_period
.header
.type
= htons(GRACE_PERIOD_TYPE
);
77 tlv_period
.header
.length
= htons(GRACE_PERIOD_LENGTH
);
78 tlv_period
.interval
= htonl(gr_info
->grace_period
);
79 stream_put(s
, &tlv_period
, sizeof(tlv_period
));
81 /* Put restart reason. */
82 tlv_reason
.header
.type
= htons(RESTART_REASON_TYPE
);
83 tlv_reason
.header
.length
= htons(RESTART_REASON_LENGTH
);
84 if (gr_info
->restart_support
)
85 tlv_reason
.reason
= OSPF_GR_SW_RESTART
;
87 tlv_reason
.reason
= OSPF_GR_UNKNOWN_RESTART
;
88 stream_put(s
, &tlv_reason
, sizeof(tlv_reason
));
91 if (oi
->type
== OSPF_IFTYPE_BROADCAST
|| oi
->type
== OSPF_IFTYPE_NBMA
92 || oi
->type
== OSPF_IFTYPE_POINTOMULTIPOINT
) {
93 tlv_address
.header
.type
= htons(RESTARTER_IP_ADDR_TYPE
);
94 tlv_address
.header
.length
= htons(RESTARTER_IP_ADDR_LEN
);
95 tlv_address
.addr
= oi
->address
->u
.prefix4
;
96 stream_put(s
, &tlv_address
, sizeof(tlv_address
));
100 /* Generate Grace-LSA for a given interface. */
101 static struct ospf_lsa
*ospf_gr_lsa_new(struct ospf_interface
*oi
)
104 struct lsa_header
*lsah
;
105 struct ospf_lsa
*new;
106 uint8_t options
, lsa_type
;
107 struct in_addr lsa_id
;
108 uint32_t lsa_id_host_byte_order
;
111 /* Create a stream for LSA. */
112 s
= stream_new(OSPF_MAX_LSA_SIZE
);
114 lsah
= (struct lsa_header
*)STREAM_DATA(s
);
116 options
= LSA_OPTIONS_GET(oi
->area
);
117 options
|= LSA_OPTIONS_NSSA_GET(oi
->area
);
118 options
|= OSPF_OPTION_O
;
120 lsa_type
= OSPF_OPAQUE_LINK_LSA
;
121 lsa_id_host_byte_order
= SET_OPAQUE_LSID(OPAQUE_TYPE_GRACE_LSA
, 0);
122 lsa_id
.s_addr
= htonl(lsa_id_host_byte_order
);
124 /* Set opaque-LSA header fields. */
125 lsa_header_set(s
, options
, lsa_type
, lsa_id
, oi
->ospf
->router_id
);
127 /* Set opaque-LSA body fields. */
128 ospf_gr_lsa_body_set(&oi
->ospf
->gr_info
, oi
, s
);
131 length
= stream_get_endp(s
);
132 lsah
->length
= htons(length
);
134 /* Now, create an OSPF LSA instance. */
135 new = ospf_lsa_new_and_data(length
);
137 if (IS_DEBUG_OSPF_GR
)
138 zlog_debug("LSA[Type%d:%pI4]: Create an Opaque-LSA/GR instance",
141 new->area
= oi
->area
;
143 SET_FLAG(new->flags
, OSPF_LSA_SELF
);
144 memcpy(new->data
, lsah
, length
);
150 /* Originate and install Grace-LSA for a given interface. */
151 static void ospf_gr_lsa_originate(struct ospf_interface
*oi
, bool maxage
)
153 struct ospf_lsa
*lsa
, *old
;
155 if (ospf_interface_neighbor_count(oi
) == 0)
158 /* Create new Grace-LSA. */
159 lsa
= ospf_gr_lsa_new(oi
);
161 zlog_warn("%s: ospf_gr_lsa_new() failed", __func__
);
166 lsa
->data
->ls_age
= htons(OSPF_LSA_MAXAGE
);
168 /* Find the old LSA and increase the seqno. */
169 old
= ospf_gr_lsa_lookup(oi
->ospf
, oi
->area
);
171 lsa
->data
->ls_seqnum
= lsa_seqnum_increment(old
);
173 /* Install this LSA into LSDB. */
174 if (ospf_lsa_install(oi
->ospf
, oi
, lsa
) == NULL
) {
175 zlog_warn("%s: ospf_lsa_install() failed", __func__
);
176 ospf_lsa_unlock(&lsa
);
180 /* Update new LSA origination count. */
181 oi
->ospf
->lsa_originate_count
++;
183 /* Flood the LSA through out the interface */
184 ospf_flood_through_interface(oi
, NULL
, lsa
);
187 /* Flush all self-originated Grace-LSAs. */
188 static void ospf_gr_flush_grace_lsas(struct ospf
*ospf
)
190 struct ospf_area
*area
;
191 struct listnode
*anode
;
193 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, anode
, area
)) {
194 struct ospf_interface
*oi
;
195 struct listnode
*inode
;
197 if (IS_DEBUG_OSPF_GR
)
199 "GR: flushing self-originated Grace-LSAs [area %pI4]",
202 for (ALL_LIST_ELEMENTS_RO(area
->oiflist
, inode
, oi
))
203 ospf_gr_lsa_originate(oi
, true);
207 /* Exit from the Graceful Restart mode. */
208 static void ospf_gr_restart_exit(struct ospf
*ospf
, const char *reason
)
210 struct ospf_area
*area
;
211 struct listnode
*onode
, *anode
;
213 if (IS_DEBUG_OSPF_GR
)
214 zlog_debug("GR: exiting graceful restart: %s", reason
);
216 ospf
->gr_info
.restart_in_progress
= false;
217 THREAD_OFF(ospf
->gr_info
.t_grace_period
);
219 /* Record in non-volatile memory that the restart is complete. */
220 ospf_gr_nvm_delete(ospf
);
222 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, onode
, area
)) {
223 struct ospf_interface
*oi
;
226 * 1) The router should reoriginate its router-LSAs for all
227 * attached areas in order to make sure they have the correct
230 ospf_router_lsa_update_area(area
);
233 * 2) The router should reoriginate network-LSAs on all segments
234 * where it is the Designated Router.
236 for (ALL_LIST_ELEMENTS_RO(area
->oiflist
, anode
, oi
))
237 if (oi
->state
== ISM_DR
)
238 ospf_network_lsa_update(oi
);
242 * 5) Any received self-originated LSAs that are no longer valid should
245 ospf_schedule_abr_task(ospf
);
248 * 3) The router reruns its OSPF routing calculations, this time
249 * installing the results into the system forwarding table, and
250 * originating summary-LSAs, Type-7 LSAs and AS-external-LSAs as
253 * 4) Any remnant entries in the system forwarding table that were
254 * installed before the restart, but that are no longer valid,
257 ospf
->gr_info
.finishing_restart
= true;
258 ospf_spf_calculate_schedule(ospf
, SPF_FLAG_GR_FINISH
);
260 /* 6) Any grace-LSAs that the router originated should be flushed. */
261 ospf_gr_flush_grace_lsas(ospf
);
264 /* Check if a Router-LSA contains a given link. */
265 static bool ospf_router_lsa_contains_adj(struct ospf_lsa
*lsa
,
268 struct router_lsa
*rl
;
270 rl
= (struct router_lsa
*)lsa
->data
;
271 for (int i
= 0; i
< ntohs(rl
->links
); i
++) {
272 struct in_addr
*link_id
= &rl
->link
[i
].link_id
;
274 if (rl
->link
[i
].type
!= LSA_LINK_TYPE_POINTOPOINT
)
277 if (IPV4_ADDR_SAME(id
, link_id
))
284 static bool ospf_gr_check_router_lsa_consistency(struct ospf
*ospf
,
285 struct ospf_area
*area
,
286 struct ospf_lsa
*lsa
)
288 if (CHECK_FLAG(lsa
->flags
, OSPF_LSA_SELF
)) {
289 struct ospf_lsa
*lsa_self
= lsa
;
290 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
292 for (int i
= 0; i
< ntohs(rl
->links
); i
++) {
293 struct in_addr
*link_id
= &rl
->link
[i
].link_id
;
294 struct ospf_lsa
*lsa_adj
;
296 if (rl
->link
[i
].type
!= LSA_LINK_TYPE_POINTOPOINT
)
299 lsa_adj
= ospf_lsa_lookup_by_id(area
, OSPF_ROUTER_LSA
,
304 if (!ospf_router_lsa_contains_adj(lsa_adj
,
305 &lsa_self
->data
->id
))
309 struct ospf_lsa
*lsa_self
;
311 lsa_self
= ospf_lsa_lookup_by_id(area
, OSPF_ROUTER_LSA
,
314 || !CHECK_FLAG(lsa_self
->flags
, OSPF_LSA_RECEIVED
))
317 if (ospf_router_lsa_contains_adj(lsa
, &ospf
->router_id
)
318 != ospf_router_lsa_contains_adj(lsa_self
, &lsa
->data
->id
))
326 * Check for LSAs that are inconsistent with the pre-restart LSAs, and abort the
327 * ongoing graceful restart when that's the case.
329 void ospf_gr_check_lsdb_consistency(struct ospf
*ospf
, struct ospf_area
*area
)
331 struct route_node
*rn
;
332 struct ospf_lsa
*lsa
;
334 for (rn
= route_top(ROUTER_LSDB(area
)); rn
; rn
= route_next(rn
)) {
339 if (!ospf_gr_check_router_lsa_consistency(ospf
, area
, lsa
)) {
342 snprintfrr(reason
, sizeof(reason
),
343 "detected inconsistent LSA[%s] [area %pI4]",
344 dump_lsa_key(lsa
), &area
->area_id
);
345 ospf_gr_restart_exit(ospf
, reason
);
346 route_unlock_node(rn
);
352 /* Lookup neighbor by address in a given OSPF area. */
353 static struct ospf_neighbor
*
354 ospf_area_nbr_lookup_by_addr(struct ospf_area
*area
, struct in_addr
*addr
)
356 struct ospf_interface
*oi
;
357 struct ospf_neighbor
*nbr
;
358 struct listnode
*node
;
360 for (ALL_LIST_ELEMENTS_RO(area
->oiflist
, node
, oi
)) {
361 nbr
= ospf_nbr_lookup_by_addr(oi
->nbrs
, addr
);
369 /* Lookup neighbor by Router ID in a given OSPF area. */
370 static struct ospf_neighbor
*
371 ospf_area_nbr_lookup_by_routerid(struct ospf_area
*area
, struct in_addr
*id
)
373 struct ospf_interface
*oi
;
374 struct ospf_neighbor
*nbr
;
375 struct listnode
*node
;
377 for (ALL_LIST_ELEMENTS_RO(area
->oiflist
, node
, oi
)) {
378 nbr
= ospf_nbr_lookup_by_routerid(oi
->nbrs
, id
);
386 /* Check if there's a fully formed adjacency with the given neighbor ID. */
387 static bool ospf_gr_check_adj_id(struct ospf_area
*area
,
388 struct in_addr
*nbr_id
)
390 struct ospf_neighbor
*nbr
;
392 nbr
= ospf_area_nbr_lookup_by_routerid(area
, nbr_id
);
393 if (!nbr
|| nbr
->state
< NSM_Full
) {
394 if (IS_DEBUG_OSPF_GR
)
395 zlog_debug("GR: missing adjacency to router %pI4",
403 static bool ospf_gr_check_adjs_lsa_transit(struct ospf_area
*area
,
404 struct in_addr
*link_id
)
406 struct ospf
*ospf
= area
->ospf
;
407 struct ospf_interface
*oi
;
410 * Check if the transit network refers to a local interface (in which
411 * case it must be a DR for that network).
413 oi
= ospf_if_lookup_by_local_addr(ospf
, NULL
, *link_id
);
415 struct ospf_lsa
*lsa
;
416 struct network_lsa
*nlsa
;
419 /* Lookup Network LSA corresponding to this interface. */
420 lsa
= ospf_lsa_lookup_by_id(area
, OSPF_NETWORK_LSA
, *link_id
);
424 /* Iterate over all routers present in the network. */
425 nlsa
= (struct network_lsa
*)lsa
->data
;
426 cnt
= (lsa
->size
- (OSPF_LSA_HEADER_SIZE
+ 4)) / 4;
427 for (size_t i
= 0; i
< cnt
; i
++) {
428 struct in_addr
*nbr_id
= &nlsa
->routers
[i
];
430 /* Skip self in the pseudonode. */
431 if (IPV4_ADDR_SAME(nbr_id
, &ospf
->router_id
))
435 * Check if there's a fully formed adjacency with this
438 if (!ospf_gr_check_adj_id(area
, nbr_id
))
442 struct ospf_neighbor
*nbr
;
444 /* Check if there's a fully formed adjacency with the DR. */
445 nbr
= ospf_area_nbr_lookup_by_addr(area
, link_id
);
446 if (!nbr
|| nbr
->state
< NSM_Full
) {
447 if (IS_DEBUG_OSPF_GR
)
449 "GR: missing adjacency to DR router %pI4",
458 static bool ospf_gr_check_adjs_lsa(struct ospf_area
*area
, struct ospf_lsa
*lsa
)
460 struct router_lsa
*rl
= (struct router_lsa
*)lsa
->data
;
462 for (int i
= 0; i
< ntohs(rl
->links
); i
++) {
463 struct in_addr
*link_id
= &rl
->link
[i
].link_id
;
465 switch (rl
->link
[i
].type
) {
466 case LSA_LINK_TYPE_POINTOPOINT
:
467 if (!ospf_gr_check_adj_id(area
, link_id
))
470 case LSA_LINK_TYPE_TRANSIT
:
471 if (!ospf_gr_check_adjs_lsa_transit(area
, link_id
))
483 * Check if all adjacencies prior to the restart were reestablished.
485 * This is done using pre-restart Router LSAs and pre-restart Network LSAs
486 * received from the helping neighbors.
488 void ospf_gr_check_adjs(struct ospf
*ospf
)
490 struct ospf_area
*area
;
491 struct listnode
*node
;
493 for (ALL_LIST_ELEMENTS_RO(ospf
->areas
, node
, area
)) {
494 struct ospf_lsa
*lsa_self
;
496 lsa_self
= ospf_lsa_lookup_by_id(area
, OSPF_ROUTER_LSA
,
498 if (!lsa_self
|| !ospf_gr_check_adjs_lsa(area
, lsa_self
)) {
499 if (IS_DEBUG_OSPF_GR
)
501 "GR: not all adjacencies were reestablished yet [area %pI4]",
507 ospf_gr_restart_exit(ospf
, "all adjacencies were reestablished");
510 /* Handling of grace period expiry. */
511 static void ospf_gr_grace_period_expired(struct thread
*thread
)
513 struct ospf
*ospf
= THREAD_ARG(thread
);
515 ospf
->gr_info
.t_grace_period
= NULL
;
516 ospf_gr_restart_exit(ospf
, "grace period has expired");
520 * Returns the path of the file (non-volatile memory) that contains GR status
523 static char *ospf_gr_nvm_filepath(struct ospf
*ospf
)
525 static char filepath
[MAXPATHLEN
];
526 char instance
[16] = "";
529 snprintf(instance
, sizeof(instance
), "-%d", ospf
->instance
);
530 snprintf(filepath
, sizeof(filepath
), OSPFD_GR_STATE
, instance
);
535 * Record in non-volatile memory that the given OSPF instance is attempting to
536 * perform a graceful restart.
538 static void ospf_gr_nvm_update(struct ospf
*ospf
)
541 const char *inst_name
;
543 json_object
*json_instances
;
544 json_object
*json_instance
;
546 filepath
= ospf_gr_nvm_filepath(ospf
);
547 inst_name
= ospf_get_name(ospf
);
549 json
= json_object_from_file(filepath
);
551 json
= json_object_new_object();
553 json_object_object_get_ex(json
, "instances", &json_instances
);
554 if (!json_instances
) {
555 json_instances
= json_object_new_object();
556 json_object_object_add(json
, "instances", json_instances
);
559 json_object_object_get_ex(json_instances
, inst_name
, &json_instance
);
560 if (!json_instance
) {
561 json_instance
= json_object_new_object();
562 json_object_object_add(json_instances
, inst_name
,
567 * Record not only the grace period, but also a UNIX timestamp
568 * corresponding to the end of that period. That way, once ospfd is
569 * restarted, it will be possible to take into account the time that
570 * passed while ospfd wasn't running.
572 json_object_int_add(json_instance
, "gracePeriod",
573 ospf
->gr_info
.grace_period
);
574 json_object_int_add(json_instance
, "timestamp",
575 time(NULL
) + ospf
->gr_info
.grace_period
);
577 json_object_to_file_ext(filepath
, json
, JSON_C_TO_STRING_PRETTY
);
578 json_object_free(json
);
582 * Delete GR status information about the given OSPF instance from non-volatile
585 static void ospf_gr_nvm_delete(struct ospf
*ospf
)
588 const char *inst_name
;
590 json_object
*json_instances
;
592 filepath
= ospf_gr_nvm_filepath(ospf
);
593 inst_name
= ospf_get_name(ospf
);
595 json
= json_object_from_file(filepath
);
597 json
= json_object_new_object();
599 json_object_object_get_ex(json
, "instances", &json_instances
);
600 if (!json_instances
) {
601 json_instances
= json_object_new_object();
602 json_object_object_add(json
, "instances", json_instances
);
605 json_object_object_del(json_instances
, inst_name
);
607 json_object_to_file_ext(filepath
, json
, JSON_C_TO_STRING_PRETTY
);
608 json_object_free(json
);
612 * Fetch from non-volatile memory whether the given OSPF instance is performing
613 * a graceful shutdown or not.
615 void ospf_gr_nvm_read(struct ospf
*ospf
)
618 const char *inst_name
;
620 json_object
*json_instances
;
621 json_object
*json_instance
;
622 json_object
*json_timestamp
;
623 time_t timestamp
= 0;
625 filepath
= ospf_gr_nvm_filepath(ospf
);
626 inst_name
= ospf_get_name(ospf
);
628 json
= json_object_from_file(filepath
);
630 json
= json_object_new_object();
632 json_object_object_get_ex(json
, "instances", &json_instances
);
633 if (!json_instances
) {
634 json_instances
= json_object_new_object();
635 json_object_object_add(json
, "instances", json_instances
);
638 json_object_object_get_ex(json_instances
, inst_name
, &json_instance
);
639 if (!json_instance
) {
640 json_instance
= json_object_new_object();
641 json_object_object_add(json_instances
, inst_name
,
645 json_object_object_get_ex(json_instance
, "timestamp", &json_timestamp
);
646 if (json_timestamp
) {
648 unsigned long remaining_time
;
650 /* Check if the grace period has already expired. */
652 timestamp
= json_object_get_int(json_timestamp
);
653 if (now
> timestamp
) {
654 ospf_gr_restart_exit(
655 ospf
, "grace period has expired already");
657 /* Schedule grace period timeout. */
658 ospf
->gr_info
.restart_in_progress
= true;
659 remaining_time
= timestamp
- time(NULL
);
660 if (IS_DEBUG_OSPF_GR
)
662 "GR: remaining time until grace period expires: %lu(s)",
664 thread_add_timer(master
, ospf_gr_grace_period_expired
,
665 ospf
, remaining_time
,
666 &ospf
->gr_info
.t_grace_period
);
670 json_object_object_del(json_instances
, inst_name
);
672 json_object_to_file_ext(filepath
, json
, JSON_C_TO_STRING_PRETTY
);
673 json_object_free(json
);
676 /* Prepare to start a Graceful Restart. */
677 static void ospf_gr_prepare(void)
680 struct ospf_interface
*oi
;
681 struct listnode
*onode
;
683 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, onode
, ospf
)) {
684 struct listnode
*inode
;
686 if (!ospf
->gr_info
.restart_support
687 || ospf
->gr_info
.prepare_in_progress
)
690 if (IS_DEBUG_OSPF_GR
)
692 "GR: preparing to perform a graceful restart [period %u second(s)] [vrf %s]",
693 ospf
->gr_info
.grace_period
,
694 ospf_vrf_id_to_name(ospf
->vrf_id
));
696 if (!CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
698 "%s: failed to activate graceful restart: opaque capability not enabled",
703 /* Freeze OSPF routes in the RIB. */
704 if (ospf_zebra_gr_enable(ospf
, ospf
->gr_info
.grace_period
)) {
706 "%s: failed to activate graceful restart: not connected to zebra",
711 /* Send a Grace-LSA to all neighbors. */
712 for (ALL_LIST_ELEMENTS_RO(ospf
->oiflist
, inode
, oi
))
713 ospf_gr_lsa_originate(oi
, false);
715 /* Record end of the grace period in non-volatile memory. */
716 ospf_gr_nvm_update(ospf
);
719 * Mark that a Graceful Restart preparation is in progress, to
720 * prevent ospfd from flushing its self-originated LSAs on exit.
722 ospf
->gr_info
.prepare_in_progress
= true;
726 DEFPY(graceful_restart_prepare
, graceful_restart_prepare_cmd
,
727 "graceful-restart prepare ip ospf",
728 "Graceful Restart commands\n"
729 "Prepare upcoming graceful restart\n"
731 "Prepare to restart the OSPF process\n")
734 struct listnode
*node
;
736 for (ALL_LIST_ELEMENTS_RO(om
->ospf
, node
, ospf
)) {
737 if (!CHECK_FLAG(ospf
->config
, OSPF_OPAQUE_CAPABLE
)) {
739 "%% Can't start graceful restart: opaque capability not enabled (VRF %s)\n\n",
740 ospf_get_name(ospf
));
750 DEFPY(graceful_restart
, graceful_restart_cmd
,
751 "graceful-restart [grace-period (1-1800)$grace_period]",
753 "Maximum length of the 'grace period'\n"
754 "Maximum length of the 'grace period' in seconds\n")
756 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
758 /* Check and get restart period if present. */
759 if (!grace_period_str
)
760 grace_period
= OSPF_DFLT_GRACE_INTERVAL
;
762 ospf
->gr_info
.restart_support
= true;
763 ospf
->gr_info
.grace_period
= grace_period
;
768 DEFPY(no_graceful_restart
, no_graceful_restart_cmd
,
769 "no graceful-restart [grace-period (1-1800)]",
771 "Maximum length of the 'grace period'\n"
772 "Maximum length of the 'grace period' in seconds\n")
774 VTY_DECLVAR_INSTANCE_CONTEXT(ospf
, ospf
);
776 if (!ospf
->gr_info
.restart_support
)
779 if (ospf
->gr_info
.prepare_in_progress
) {
781 "%% Error: Graceful Restart preparation in progress\n");
785 ospf
->gr_info
.restart_support
= false;
786 ospf
->gr_info
.grace_period
= OSPF_DFLT_GRACE_INTERVAL
;
791 void ospf_gr_init(void)
793 install_element(ENABLE_NODE
, &graceful_restart_prepare_cmd
);
794 install_element(OSPF_NODE
, &graceful_restart_cmd
);
795 install_element(OSPF_NODE
, &no_graceful_restart_cmd
);