diff options
author | Olivier Dugeon <olivier.dugeon@orange.com> | 2021-06-09 09:06:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-09 09:06:42 +0200 |
commit | 3898a4522f0d4e54f23ff76a05ad877743c10587 (patch) | |
tree | ee3f1226240c86a7875b623f5b0457cb18c33c17 /ospfd | |
parent | Merge pull request #8593 from idryzhov/cmd-ambiguous (diff) | |
parent | ospfd: fix crash when displaying neighbor data in JSON (diff) | |
download | frr-3898a4522f0d4e54f23ff76a05ad877743c10587.tar.xz frr-3898a4522f0d4e54f23ff76a05ad877743c10587.zip |
Merge pull request #8798 from opensourcerouting/ospfd-fixes
ospfd: assorted fixes
Diffstat (limited to 'ospfd')
-rw-r--r-- | ospfd/ospf_flood.c | 7 | ||||
-rw-r--r-- | ospfd/ospf_gr_helper.c | 176 | ||||
-rw-r--r-- | ospfd/ospf_gr_helper.h | 6 | ||||
-rw-r--r-- | ospfd/ospf_lsa.c | 16 | ||||
-rw-r--r-- | ospfd/ospf_main.c | 1 | ||||
-rw-r--r-- | ospfd/ospf_opaque.c | 13 | ||||
-rw-r--r-- | ospfd/ospf_packet.c | 8 | ||||
-rw-r--r-- | ospfd/ospf_spf.c | 14 | ||||
-rw-r--r-- | ospfd/ospf_vty.c | 28 | ||||
-rw-r--r-- | ospfd/ospfd.c | 9 |
10 files changed, 177 insertions, 101 deletions
diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index 7eb587899..6c1ac6761 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -597,7 +597,7 @@ static int ospf_flood_through_interface(struct ospf_interface *oi, Designated Router, chances are that all the neighbors have received the LSA already. */ if (NBR_IS_DR(inbr) || NBR_IS_BDR(inbr)) { - if (IS_DEBUG_OSPF_NSSA) + if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) zlog_debug("%s: DR/BDR NOT SEND to int %s (%s)", __func__, IF_NAME(oi), ospf_get_name(oi->ospf)); @@ -611,7 +611,7 @@ static int ospf_flood_through_interface(struct ospf_interface *oi, end up retransmitting the updates. */ if (oi->state == ISM_Backup) { - if (IS_DEBUG_OSPF_NSSA) + if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) zlog_debug( "%s: ISM_Backup NOT SEND to int %s (%s)", __func__, IF_NAME(oi), @@ -626,8 +626,7 @@ static int ospf_flood_through_interface(struct ospf_interface *oi, (which must be > 0) when it is copied into the outgoing Link State Update packet (until the LS age field reaches the maximum value of MaxAge). */ - /* XXX HASSO: Is this IS_DEBUG_OSPF_NSSA really correct? */ - if (IS_DEBUG_OSPF_NSSA) + if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) zlog_debug("%s: DR/BDR sending upd to int %s (%s)", __func__, IF_NAME(oi), ospf_get_name(oi->ospf)); diff --git a/ospfd/ospf_gr_helper.c b/ospfd/ospf_gr_helper.c index a25057a27..b32318b83 100644 --- a/ospfd/ospf_gr_helper.c +++ b/ospfd/ospf_gr_helper.c @@ -52,7 +52,7 @@ static const char * const ospf_exit_reason_desc[] = { "Unknown reason", - "Helper inprogress", + "Helper in progress", "Topology Change", "Grace timer expiry", "Successful graceful restart", @@ -159,10 +159,8 @@ const char *ospf_rejected_reason2str(unsigned int reason) * Returns: * Nothing */ -void ospf_gr_helper_init(struct ospf *ospf) +void ospf_gr_helper_instance_init(struct ospf *ospf) { - int rc; - if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug("%s, GR Helper init.", __func__); @@ -176,6 +174,37 @@ void ospf_gr_helper_init(struct ospf *ospf) ospf->enable_rtr_list = hash_create(ospf_enable_rtr_hash_key, ospf_enable_rtr_hash_cmp, "OSPF enable router hash"); +} + +/* + * De-Initialize GR helper config data structures. + * + * OSPF + * OSPF pointer + * + * Returns: + * Nothing + */ +void ospf_gr_helper_instance_stop(struct ospf *ospf) +{ + if (IS_DEBUG_OSPF_GR_HELPER) + zlog_debug("%s, GR helper deinit.", __func__); + + ospf_enable_rtr_hash_destroy(ospf); +} + +/* + * Initialize GR helper config data structures. + * + * Returns: + * Nothing + */ +void ospf_gr_helper_init(void) +{ + int rc; + + if (IS_DEBUG_OSPF_GR_HELPER) + zlog_debug("%s, GR Helper init.", __func__); rc = ospf_register_opaque_functab( OSPF_OPAQUE_LINK_LSA, OPAQUE_TYPE_GRACE_LSA, NULL, NULL, NULL, @@ -191,20 +220,15 @@ void ospf_gr_helper_init(struct ospf *ospf) /* * De-Initialize GR helper config data structures. * - * OSPF - * OSPF pointer - * * Returns: * Nothing */ -void ospf_gr_helper_stop(struct ospf *ospf) +void ospf_gr_helper_stop(void) { if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug("%s, GR helper deinit.", __func__); - ospf_enable_rtr_hash_destroy(ospf); - ospf_delete_opaque_functab(OSPF_OPAQUE_LINK_LSA, OPAQUE_TYPE_GRACE_LSA); } @@ -342,7 +366,7 @@ static int ospf_handle_grace_timer_expiry(struct thread *thread) * Grace LSA received from RESTARTER. * * nbr - * ospf neighbour which requets the router to act as + * OSPF neighbour which requests the router to act as * HELPER. * * Returns: @@ -374,11 +398,11 @@ int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug( - "%s, Grace LSA received from %pI4, grace interval:%u, restartreason :%s", + "%s, Grace LSA received from %pI4, grace interval:%u, restart reason:%s", __func__, &restart_addr, grace_interval, ospf_restart_reason2str(restart_reason)); - /* Incase of broadcast links, if RESTARTER is DR_OTHER, + /* In case of broadcast links, if RESTARTER is DR_OTHER, * grace LSA might be received from DR, so need to get * actual neighbour info , here RESTARTER. */ @@ -441,7 +465,7 @@ int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, return OSPF_GR_NOT_HELPER; } - /* Check the retranmission list of this + /* Check the retransmission list of this * neighbour, check any change in lsas. */ if (ospf->strict_lsa_check && !ospf_ls_retransmit_isempty(restarter) @@ -459,7 +483,7 @@ int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, if (ntohs(lsa->data->ls_age) >= grace_interval) { if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug( - "%s, Grace LSA age(%d) is more than the graceinterval(%d)", + "%s, Grace LSA age(%d) is more than the grace interval(%d)", __func__, lsa->data->ls_age, grace_interval); restarter->gr_helper_info.rejected_reason = OSPF_HELPER_LSA_AGE_MORE; @@ -508,7 +532,7 @@ int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, restarter->gr_helper_info.gr_restart_reason = restart_reason; restarter->gr_helper_info.rejected_reason = OSPF_HELPER_REJECTED_NONE; - /* Incremnet the active restarer count */ + /* Increment the active restarter count */ ospf->active_restarter_cnt++; if (IS_DEBUG_OSPF_GR_HELPER) @@ -528,7 +552,7 @@ int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, * retransmission list. * * nbr - * ospf neighbor + * OSPF neighbor * * Returns: * TRUE - if any change in the lsa. @@ -579,7 +603,7 @@ static bool ospf_check_change_in_rxmt_list(struct ospf_neighbor *nbr) * ospf * ospf pointer * lsa - * topo change occured due to this lsa type (1 to 5 and 7) + * topo change occurred due to this lsa type (1 to 5 and 7) * * Returns: * Nothing @@ -593,7 +617,7 @@ void ospf_helper_handle_topo_chg(struct ospf *ospf, struct ospf_lsa *lsa) return; /* Topo change not required to be handled if strict - * LSA check is disbaled for this router. + * LSA check is disabled for this router. */ if (!ospf->strict_lsa_check) return; @@ -683,25 +707,26 @@ void ospf_gr_helper_exit(struct ospf_neighbor *nbr, ospf->active_restarter_cnt--; /* If the exit not triggered due to grace timer - * expairy , stop the grace timer. + * expiry, stop the grace timer. */ if (reason != OSPF_GR_HELPER_GRACE_TIMEOUT) THREAD_OFF(nbr->gr_helper_info.t_grace_timer); /* check exit triggered due to successful completion * of graceful restart. - * If no, bringdown the neighbour. + * If no, bring down the neighbour. */ if (reason != OSPF_GR_HELPER_COMPLETED) { if (IS_DEBUG_OSPF_GR_HELPER) zlog_debug( "%s, Failed GR exit, so bringing down the neighbour", __func__); - OSPF_NSM_EVENT_EXECUTE(nbr, NSM_KillNbr); + OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_KillNbr); } /*Recalculate the DR for the network segment */ - ospf_dr_election(oi); + if (oi->type == OSPF_IFTYPE_BROADCAST || oi->type == OSPF_IFTYPE_NBMA) + ospf_dr_election(oi); /* Originate a router LSA */ ospf_router_lsa_update_area(oi->area); @@ -712,7 +737,7 @@ void ospf_gr_helper_exit(struct ospf_neighbor *nbr, } /* - * Process Maxage Grace LSA. + * Process MaxAge Grace LSA. * It is a indication for successful completion of GR. * If router acting as HELPER, It exits from helper role. * @@ -723,7 +748,7 @@ void ospf_gr_helper_exit(struct ospf_neighbor *nbr, * Grace LSA received from RESTARTER. * * nbr - * ospf neighbour which requets the router to act as + * OSPF neighbour which requests the router to act as * HELPER. * * Returns: @@ -778,7 +803,7 @@ void ospf_process_maxage_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, * Disable/Enable HELPER support on router level. * * ospf - * OSPFpointer. + * OSPF pointer. * * status * TRUE/FALSE @@ -819,7 +844,7 @@ void ospf_gr_helper_support_set(struct ospf *ospf, bool support) lookup.advRtrAddr.s_addr = nbr->router_id.s_addr; /* check if helper support enabled for the - * correspodning routerid.If enabled, dont + * corresponding routerid.If enabled, dont * dont exit from helper role. */ if (hash_lookup(ospf->enable_rtr_list, &lookup)) @@ -995,72 +1020,115 @@ static void show_ospf_grace_lsa_info(struct vty *vty, struct ospf_lsa *lsa) lsah = (struct lsa_header *)lsa->data; if (lsa->size <= OSPF_LSA_HEADER_SIZE) { - vty_out(vty, "%% Invalid LSA length: %d\n", length); + if (vty) + vty_out(vty, "%% Invalid LSA length: %d\n", length); + else + zlog_debug("%% Invalid LSA length: %d", length); return; } length = lsa->size - OSPF_LSA_HEADER_SIZE; - vty_out(vty, " TLV info:\n"); + if (vty) + vty_out(vty, " TLV info:\n"); + else + zlog_debug(" TLV info:"); for (tlvh = TLV_HDR_TOP(lsah); sum < length && tlvh; tlvh = TLV_HDR_NEXT(tlvh)) { /* Check TLV len */ if (sum + TLV_SIZE(tlvh) > length) { - vty_out(vty, "%% Invalid TLV length: %u\n", - TLV_SIZE(tlvh)); + if (vty) + vty_out(vty, "%% Invalid TLV length: %u\n", + TLV_SIZE(tlvh)); + else + zlog_debug("%% Invalid TLV length: %u", + TLV_SIZE(tlvh)); return; } switch (ntohs(tlvh->type)) { case GRACE_PERIOD_TYPE: - if (TLV_SIZE(tlvh) < - sizeof(struct grace_tlv_graceperiod)) { - vty_out(vty, - "%% Invalid grace TLV length %u\n", - TLV_SIZE(tlvh)); + if (TLV_SIZE(tlvh) + < sizeof(struct grace_tlv_graceperiod)) { + if (vty) + vty_out(vty, + "%% Invalid grace TLV length %u\n", + TLV_SIZE(tlvh)); + else + zlog_debug( + "%% Invalid grace TLV length %u", + TLV_SIZE(tlvh)); return; } gracePeriod = (struct grace_tlv_graceperiod *)tlvh; sum += TLV_SIZE(tlvh); - vty_out(vty, " Grace period:%d\n", - ntohl(gracePeriod->interval)); + if (vty) + vty_out(vty, " Grace period:%d\n", + ntohl(gracePeriod->interval)); + else + zlog_debug(" Grace period:%d", + ntohl(gracePeriod->interval)); break; case RESTART_REASON_TYPE: - if (TLV_SIZE(tlvh) < - sizeof(struct grace_tlv_restart_reason)) { - vty_out(vty, - "%% Invalid reason TLV length %u\n", - TLV_SIZE(tlvh)); + if (TLV_SIZE(tlvh) + < sizeof(struct grace_tlv_restart_reason)) { + if (vty) + vty_out(vty, + "%% Invalid reason TLV length %u\n", + TLV_SIZE(tlvh)); + else + zlog_debug( + "%% Invalid reason TLV length %u", + TLV_SIZE(tlvh)); return; } grReason = (struct grace_tlv_restart_reason *)tlvh; sum += TLV_SIZE(tlvh); - vty_out(vty, " Restart reason:%s\n", - ospf_restart_reason2str(grReason->reason)); + if (vty) + vty_out(vty, " Restart reason:%s\n", + ospf_restart_reason2str( + grReason->reason)); + else + zlog_debug(" Restart reason:%s", + ospf_restart_reason2str( + grReason->reason)); break; case RESTARTER_IP_ADDR_TYPE: - if (TLV_SIZE(tlvh) < - sizeof(struct grace_tlv_restart_addr)) { - vty_out(vty, - "%% Invalid addr TLV length %u\n", - TLV_SIZE(tlvh)); + if (TLV_SIZE(tlvh) + < sizeof(struct grace_tlv_restart_addr)) { + if (vty) + vty_out(vty, + "%% Invalid addr TLV length %u\n", + TLV_SIZE(tlvh)); + else + zlog_debug( + "%% Invalid addr TLV length %u", + TLV_SIZE(tlvh)); return; } restartAddr = (struct grace_tlv_restart_addr *)tlvh; sum += TLV_SIZE(tlvh); - vty_out(vty, " Restarter address:%pI4\n", - &restartAddr->addr); + if (vty) + vty_out(vty, " Restarter address:%pI4\n", + &restartAddr->addr); + else + zlog_debug(" Restarter address:%pI4", + &restartAddr->addr); break; default: - vty_out(vty, " Unknown TLV type %d\n", - ntohs(tlvh->type)); + if (vty) + vty_out(vty, " Unknown TLV type %d\n", + ntohs(tlvh->type)); + else + zlog_debug(" Unknown TLV type %d", + ntohs(tlvh->type)); break; } diff --git a/ospfd/ospf_gr_helper.h b/ospfd/ospf_gr_helper.h index c355bb4f3..bd6d1d746 100644 --- a/ospfd/ospf_gr_helper.h +++ b/ospfd/ospf_gr_helper.h @@ -156,8 +156,10 @@ const char *ospf_exit_reason2str(unsigned int reason); const char *ospf_restart_reason2str(unsigned int reason); const char *ospf_rejected_reason2str(unsigned int reason); -extern void ospf_gr_helper_init(struct ospf *ospf); -extern void ospf_gr_helper_stop(struct ospf *ospf); +extern void ospf_gr_helper_instance_init(struct ospf *ospf); +extern void ospf_gr_helper_instance_stop(struct ospf *ospf); +extern void ospf_gr_helper_init(void); +extern void ospf_gr_helper_stop(void); extern int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, struct ospf_neighbor *nbr); extern void ospf_gr_helper_exit(struct ospf_neighbor *nbr, diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 72dc699bd..49829d86f 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -2670,15 +2670,16 @@ struct ospf_lsa *ospf_lsa_install(struct ospf *ospf, struct ospf_interface *oi, if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) { zlog_debug( - "ospf_lsa_install() Premature Aging lsa 0x%p, seqnum 0x%x", - (void *)lsa, + "%s() Premature Aging lsa %p, seqnum 0x%x", + __func__, lsa, ntohl(lsa->data->ls_seqnum)); ospf_lsa_header_dump(lsa->data); } } else { if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) { zlog_debug( - "ospf_lsa_install() got an lsa with seq 0x80000000 that was not self originated. Ignoring"); + "%s() got an lsa with seq 0x80000000 that was not self originated. Ignoring", + __func__); ospf_lsa_header_dump(lsa->data); } return old; @@ -2764,9 +2765,8 @@ struct ospf_lsa *ospf_lsa_install(struct ospf *ospf, struct ospf_interface *oi, */ if (IS_LSA_MAXAGE(new)) { if (IS_DEBUG_OSPF(lsa, LSA_INSTALL)) - zlog_debug("LSA[Type%d:%pI4]: Install LSA 0x%p, MaxAge", - new->data->type, &new->data->id, - (void *)lsa); + zlog_debug("LSA[Type%d:%pI4]: Install LSA %p, MaxAge", + new->data->type, &new->data->id, lsa); ospf_lsa_maxage(ospf, lsa); } @@ -2855,8 +2855,8 @@ static int ospf_maxage_lsa_remover(struct thread *thread) if (CHECK_FLAG(lsa->flags, OSPF_LSA_PREMATURE_AGE)) { if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) zlog_debug( - "originating new lsa for lsa 0x%p", - (void *)lsa); + "originating new lsa for lsa %p", + lsa); ospf_lsa_refresh(ospf, lsa); } diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 91ba3044f..d94de1299 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -225,6 +225,7 @@ int main(int argc, char **argv) ospf_route_map_init(); ospf_opaque_init(); + ospf_gr_helper_init(); /* OSPF errors init */ ospf_error_init(); diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index 42bf914f6..fac2f9714 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -2119,15 +2119,12 @@ void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa0) goto out; } + /* This lsa will be flushed and removed eventually. */ + ospf_lsa_flush(top, lsa); + /* Dequeue listnode entry from the list. */ listnode_delete(oipt->id_list, oipi); - /* Disassociate internal control information with the given lsa. */ - free_opaque_info_per_id((void *)oipi); - - /* Force given lsa's age to MaxAge. */ - lsa->data->ls_age = htons(OSPF_LSA_MAXAGE); - if (IS_DEBUG_OSPF_EVENT) zlog_debug( "Schedule Type-%u Opaque-LSA to FLUSH: [opaque-type=%u, opaque-id=%x]", @@ -2135,8 +2132,8 @@ void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa0) GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr)), GET_OPAQUE_ID(ntohl(lsa->data->id.s_addr))); - /* This lsa will be flushed and removed eventually. */ - ospf_lsa_flush(top, lsa); + /* Disassociate internal control information with the given lsa. */ + free_opaque_info_per_id((void *)oipi); out: return; diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 2de673175..580eee13c 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -1862,9 +1862,9 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph, return; } - /* Get list of LSAs from Link State Update packet. - Also perorms Stages - * 1 (validate LSA checksum) and 2 (check for LSA consistent type) - * of section 13. + /* Get list of LSAs from Link State Update packet. - Also performs + * Stages 1 (validate LSA checksum) and 2 (check for LSA consistent + * type) of section 13. */ lsas = ospf_ls_upd_list_lsa(nbr, s, oi, size); @@ -1890,7 +1890,7 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph, struct ospf_lsa *ls_ret, *current; int ret = 1; - if (IS_DEBUG_OSPF_NSSA) + if (IS_DEBUG_OSPF(lsa, LSA)) zlog_debug("LSA Type-%d from %pI4, ID: %pI4, ADV: %pI4", lsa->data->type, &ospfh->router_id, &lsa->data->id, &lsa->data->adv_router); diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index 3849d4b7e..43d6ff44b 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -1889,19 +1889,19 @@ static int ospf_spf_calculate_schedule_worker(struct thread *thread) rbuf[0] = '\0'; if (spf_reason_flags) { - if (spf_reason_flags & SPF_FLAG_ROUTER_LSA_INSTALL) + if (spf_reason_flags & (1 << SPF_FLAG_ROUTER_LSA_INSTALL)) strlcat(rbuf, "R, ", sizeof(rbuf)); - if (spf_reason_flags & SPF_FLAG_NETWORK_LSA_INSTALL) + if (spf_reason_flags & (1 << SPF_FLAG_NETWORK_LSA_INSTALL)) strlcat(rbuf, "N, ", sizeof(rbuf)); - if (spf_reason_flags & SPF_FLAG_SUMMARY_LSA_INSTALL) + if (spf_reason_flags & (1 << SPF_FLAG_SUMMARY_LSA_INSTALL)) strlcat(rbuf, "S, ", sizeof(rbuf)); - if (spf_reason_flags & SPF_FLAG_ASBR_SUMMARY_LSA_INSTALL) + if (spf_reason_flags & (1 << SPF_FLAG_ASBR_SUMMARY_LSA_INSTALL)) strlcat(rbuf, "AS, ", sizeof(rbuf)); - if (spf_reason_flags & SPF_FLAG_ABR_STATUS_CHANGE) + if (spf_reason_flags & (1 << SPF_FLAG_ABR_STATUS_CHANGE)) strlcat(rbuf, "ABR, ", sizeof(rbuf)); - if (spf_reason_flags & SPF_FLAG_ASBR_STATUS_CHANGE) + if (spf_reason_flags & (1 << SPF_FLAG_ASBR_STATUS_CHANGE)) strlcat(rbuf, "ASBR, ", sizeof(rbuf)); - if (spf_reason_flags & SPF_FLAG_MAXAGE) + if (spf_reason_flags & (1 << SPF_FLAG_MAXAGE)) strlcat(rbuf, "M, ", sizeof(rbuf)); size_t rbuflen = strlen(rbuf); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 3186eabea..cb64187d7 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -4407,21 +4407,27 @@ static void show_ip_ospf_neighbor_sub(struct vty *vty, ospf_nbr_state_message(nbr, msgbuf, 16); - long time_store; - - time_store = - monotime_until( - &nbr->t_inactivity->u.sands, - NULL) - / 1000LL; - json_object_int_add(json_neighbor, "priority", nbr->priority); json_object_string_add(json_neighbor, "state", msgbuf); - json_object_int_add(json_neighbor, - "deadTimeMsecs", - time_store); + + if (nbr->t_inactivity) { + long time_store; + + time_store = monotime_until( + &nbr->t_inactivity + ->u.sands, + NULL) + / 1000LL; + json_object_int_add(json_neighbor, + "deadTimeMsecs", + time_store); + } else { + json_object_string_add(json_neighbor, + "deadTimeMsecs", + "inactive"); + } json_object_string_add( json_neighbor, "address", inet_ntop(AF_INET, &nbr->src, diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 2f088aa81..e95ee55e6 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -386,7 +386,7 @@ struct ospf *ospf_new_alloc(unsigned short instance, const char *name) new->proactive_arp = OSPF_PROACTIVE_ARP_DEFAULT; - ospf_gr_helper_init(new); + ospf_gr_helper_instance_init(new); ospf_asbr_external_aggregator_init(new); @@ -651,6 +651,9 @@ void ospf_terminate(void) for (ALL_LIST_ELEMENTS(om->ospf, node, nnode, ospf)) ospf_finish(ospf); + /* Cleanup GR */ + ospf_gr_helper_stop(); + /* Cleanup route maps */ route_map_finish(); @@ -815,8 +818,8 @@ static void ospf_finish_final(struct ospf *ospf) if ((lsa = rn->info) != NULL) { ospf_lsa_unlock(&lsa); rn->info = NULL; + route_unlock_node(rn); } - route_unlock_node(rn); } route_table_finish(ospf->maxage_lsa); @@ -890,7 +893,7 @@ static void ospf_finish_final(struct ospf *ospf) list_delete(&ospf->oi_write_q); /* Reset GR helper data structers */ - ospf_gr_helper_stop(ospf); + ospf_gr_helper_instance_stop(ospf); close(ospf->fd); stream_free(ospf->ibuf); |