diff options
Diffstat (limited to 'ospfd')
| -rw-r--r-- | ospfd/ospf_abr.c | 67 | ||||
| -rw-r--r-- | ospfd/ospf_apiserver.c | 33 | ||||
| -rw-r--r-- | ospfd/ospf_ase.c | 7 | ||||
| -rw-r--r-- | ospfd/ospf_ia.c | 4 | ||||
| -rw-r--r-- | ospfd/ospf_interface.c | 22 | ||||
| -rw-r--r-- | ospfd/ospf_interface.h | 2 | ||||
| -rw-r--r-- | ospfd/ospf_lsa.c | 33 | ||||
| -rw-r--r-- | ospfd/ospf_nsm.c | 18 | ||||
| -rw-r--r-- | ospfd/ospf_opaque.c | 24 | ||||
| -rw-r--r-- | ospfd/ospf_vty.c | 100 | ||||
| -rw-r--r-- | ospfd/ospf_zebra.c | 4 | ||||
| -rw-r--r-- | ospfd/ospfd.c | 51 |
12 files changed, 214 insertions, 151 deletions
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c index f7aa94ad18..ea94bab6b3 100644 --- a/ospfd/ospf_abr.c +++ b/ospfd/ospf_abr.c @@ -327,8 +327,7 @@ static int ospf_abr_nssa_am_elected(struct ospf_area *area) struct router_lsa *rlsa; struct in_addr *best = NULL; - LSDB_LOOP(ROUTER_LSDB(area), rn, lsa) - { + LSDB_LOOP (ROUTER_LSDB(area), rn, lsa) { /* sanity checks */ if (!lsa || (lsa->data->type != OSPF_ROUTER_LSA) || IS_LSA_SELF(lsa)) @@ -978,7 +977,7 @@ static void ospf_abr_process_nssa_translates(struct ospf *ospf) inet_ntoa(area->area_id)); LSDB_LOOP(NSSA_LSDB(area), rn, lsa) - ospf_abr_translate_nssa(area, lsa); + ospf_abr_translate_nssa(area, lsa); } if (IS_DEBUG_OSPF_NSSA) @@ -1325,14 +1324,14 @@ ospf_abr_unapprove_translates(struct ospf *ospf) /* For NSSA Translations */ and we would want to flush any residuals anyway */ LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) - if (CHECK_FLAG(lsa->flags, OSPF_LSA_LOCAL_XLT)) { - UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); - if (IS_DEBUG_OSPF_NSSA) - zlog_debug( - "ospf_abr_unapprove_translates(): " - "approved unset on link id %s", - inet_ntoa(lsa->data->id)); - } + if (CHECK_FLAG(lsa->flags, OSPF_LSA_LOCAL_XLT)) { + UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); + if (IS_DEBUG_OSPF_NSSA) + zlog_debug( + "ospf_abr_unapprove_translates(): " + "approved unset on link id %s", + inet_ntoa(lsa->data->id)); + } if (IS_DEBUG_OSPF_NSSA) zlog_debug("ospf_abr_unapprove_translates(): Stop"); @@ -1355,24 +1354,24 @@ static void ospf_abr_unapprove_summaries(struct ospf *ospf) "considering area %s", inet_ntoa(area->area_id)); LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) - if (ospf_lsa_is_self_originated(ospf, lsa)) { - if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_abr_unapprove_summaries(): " - "approved unset on summary link id %s", - inet_ntoa(lsa->data->id)); - UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); - } + if (ospf_lsa_is_self_originated(ospf, lsa)) { + if (IS_DEBUG_OSPF_EVENT) + zlog_debug( + "ospf_abr_unapprove_summaries(): " + "approved unset on summary link id %s", + inet_ntoa(lsa->data->id)); + UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); + } LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) - if (ospf_lsa_is_self_originated(ospf, lsa)) { - if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_abr_unapprove_summaries(): " - "approved unset on asbr-summary link id %s", - inet_ntoa(lsa->data->id)); - UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); - } + if (ospf_lsa_is_self_originated(ospf, lsa)) { + if (IS_DEBUG_OSPF_EVENT) + zlog_debug( + "ospf_abr_unapprove_summaries(): " + "approved unset on asbr-summary link id %s", + inet_ntoa(lsa->data->id)); + UNSET_FLAG(lsa->flags, OSPF_LSA_APPROVED); + } } if (IS_DEBUG_OSPF_EVENT) @@ -1633,7 +1632,7 @@ static void ospf_abr_remove_unapproved_translates(struct ospf *ospf) zlog_debug("ospf_abr_remove_unapproved_translates(): Start"); LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) - ospf_abr_remove_unapproved_translates_apply(ospf, lsa); + ospf_abr_remove_unapproved_translates_apply(ospf, lsa); if (IS_DEBUG_OSPF_NSSA) zlog_debug("ospf_abr_remove_unapproved_translates(): Stop"); @@ -1657,14 +1656,14 @@ static void ospf_abr_remove_unapproved_summaries(struct ospf *ospf) inet_ntoa(area->area_id)); LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) - if (ospf_lsa_is_self_originated(ospf, lsa)) - if (!CHECK_FLAG(lsa->flags, OSPF_LSA_APPROVED)) - ospf_lsa_flush_area(lsa, area); + if (ospf_lsa_is_self_originated(ospf, lsa)) + if (!CHECK_FLAG(lsa->flags, OSPF_LSA_APPROVED)) + ospf_lsa_flush_area(lsa, area); LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) - if (ospf_lsa_is_self_originated(ospf, lsa)) - if (!CHECK_FLAG(lsa->flags, OSPF_LSA_APPROVED)) - ospf_lsa_flush_area(lsa, area); + if (ospf_lsa_is_self_originated(ospf, lsa)) + if (!CHECK_FLAG(lsa->flags, OSPF_LSA_APPROVED)) + ospf_lsa_flush_area(lsa, area); } if (IS_DEBUG_OSPF_EVENT) diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index 8c1ad5ff0c..9ebaeffa69 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -1313,22 +1313,28 @@ int ospf_apiserver_handle_sync_lsdb(struct ospf_apiserver *apiserv, /* Check msg type. */ if (mask & Power2[OSPF_ROUTER_LSA]) LSDB_LOOP(ROUTER_LSDB(area), rn, lsa) - apiserver_sync_callback(lsa, (void *)¶m, seqnum); + apiserver_sync_callback( + lsa, (void *)¶m, seqnum); if (mask & Power2[OSPF_NETWORK_LSA]) LSDB_LOOP(NETWORK_LSDB(area), rn, lsa) - apiserver_sync_callback(lsa, (void *)¶m, seqnum); + apiserver_sync_callback( + lsa, (void *)¶m, seqnum); if (mask & Power2[OSPF_SUMMARY_LSA]) LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) - apiserver_sync_callback(lsa, (void *)¶m, seqnum); + apiserver_sync_callback( + lsa, (void *)¶m, seqnum); if (mask & Power2[OSPF_ASBR_SUMMARY_LSA]) LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) - apiserver_sync_callback(lsa, (void *)¶m, seqnum); + apiserver_sync_callback( + lsa, (void *)¶m, seqnum); if (mask & Power2[OSPF_OPAQUE_LINK_LSA]) LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) - apiserver_sync_callback(lsa, (void *)¶m, seqnum); + apiserver_sync_callback( + lsa, (void *)¶m, seqnum); if (mask & Power2[OSPF_OPAQUE_AREA_LSA]) LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) - apiserver_sync_callback(lsa, (void *)¶m, seqnum); + apiserver_sync_callback( + lsa, (void *)¶m, seqnum); } } @@ -1336,14 +1342,16 @@ int ospf_apiserver_handle_sync_lsdb(struct ospf_apiserver *apiserv, if (ospf->lsdb) { if (mask & Power2[OSPF_AS_EXTERNAL_LSA]) LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) - apiserver_sync_callback(lsa, (void *)¶m, seqnum); + apiserver_sync_callback(lsa, (void *)¶m, + seqnum); } /* For AS-external opaque LSAs */ if (ospf->lsdb) { if (mask & Power2[OSPF_OPAQUE_AS_LSA]) LSDB_LOOP(OPAQUE_AS_LSDB(ospf), rn, lsa) - apiserver_sync_callback(lsa, (void *)¶m, seqnum); + apiserver_sync_callback(lsa, (void *)¶m, + seqnum); } /* Send a reply back to client with return code */ @@ -1945,16 +1953,19 @@ void ospf_apiserver_flush_opaque_lsa(struct ospf_apiserver *apiserv, case OSPF_OPAQUE_LINK_LSA: for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) - apiserver_flush_opaque_type_callback(lsa, (void *)¶m, 0); + apiserver_flush_opaque_type_callback( + lsa, (void *)¶m, 0); break; case OSPF_OPAQUE_AREA_LSA: for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) - apiserver_flush_opaque_type_callback(lsa, (void *)¶m, 0); + apiserver_flush_opaque_type_callback( + lsa, (void *)¶m, 0); break; case OSPF_OPAQUE_AS_LSA: LSDB_LOOP(OPAQUE_LINK_LSDB(ospf), rn, lsa) - apiserver_flush_opaque_type_callback(lsa, (void *)¶m, 0); + apiserver_flush_opaque_type_callback(lsa, + (void *)¶m, 0); break; default: break; diff --git a/ospfd/ospf_ase.c b/ospfd/ospf_ase.c index 368987a2ba..d2af974833 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -649,7 +649,7 @@ static int ospf_ase_calculate_timer(struct thread *t) /* Calculate external route for each AS-external-LSA */ LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) - ospf_ase_calculate_route(ospf, lsa); + ospf_ase_calculate_route(ospf, lsa); /* This version simple adds to the table all NSSA areas */ if (ospf->anyNSSA) @@ -661,11 +661,12 @@ static int ospf_ase_calculate_timer(struct thread *t) if (area->external_routing == OSPF_AREA_NSSA) LSDB_LOOP(NSSA_LSDB(area), rn, lsa) - ospf_ase_calculate_route(ospf, lsa); + ospf_ase_calculate_route(ospf, + lsa); } /* kevinm: And add the NSSA routes in ospf_top */ LSDB_LOOP(NSSA_LSDB(ospf), rn, lsa) - ospf_ase_calculate_route(ospf, lsa); + ospf_ase_calculate_route(ospf, lsa); /* Compare old and new external routing table and install the difference info zebra/kernel */ diff --git a/ospfd/ospf_ia.c b/ospfd/ospf_ia.c index c65d8b8743..e570f3337a 100644 --- a/ospfd/ospf_ia.c +++ b/ospfd/ospf_ia.c @@ -283,7 +283,7 @@ static void ospf_examine_summaries(struct ospf_area *area, struct route_node *rn; LSDB_LOOP(lsdb_rt, rn, lsa) - process_summary_lsa(area, rt, rtrs, lsa); + process_summary_lsa(area, rt, rtrs, lsa); } int ospf_area_is_transit(struct ospf_area *area) @@ -583,7 +583,7 @@ static void ospf_examine_transit_summaries(struct ospf_area *area, struct route_node *rn; LSDB_LOOP(lsdb_rt, rn, lsa) - process_transit_summary_lsa(area, rt, rtrs, lsa); + process_transit_summary_lsa(area, rt, rtrs, lsa); } void ospf_ia_routing(struct ospf *ospf, struct route_table *rt, diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index e8700e7eb0..c8f758525e 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -51,6 +51,28 @@ DEFINE_QOBJ_TYPE(ospf_interface) DEFINE_HOOK(ospf_vl_add, (struct ospf_vl_data * vd), (vd)) DEFINE_HOOK(ospf_vl_delete, (struct ospf_vl_data * vd), (vd)) +int ospf_interface_neighbor_count(struct ospf_interface *oi) +{ + int count = 0; + struct route_node *rn; + struct ospf_neighbor *nbr = NULL; + + for (rn = route_top(oi->nbrs); rn; rn = route_next(rn)) { + nbr = rn->info; + if (nbr) { + /* Do not show myself. */ + if (nbr == oi->nbr_self) + continue; + /* Down state is not shown. */ + if (nbr->state == NSM_Down) + continue; + count++; + } + } + + return count; +} + int ospf_if_get_output_cost(struct ospf_interface *oi) { /* If all else fails, use default OSPF cost */ diff --git a/ospfd/ospf_interface.h b/ospfd/ospf_interface.h index 829a3f4297..ab02444f7d 100644 --- a/ospfd/ospf_interface.h +++ b/ospfd/ospf_interface.h @@ -314,8 +314,8 @@ extern struct crypt_key *ospf_crypt_key_lookup(struct list *, u_char); extern struct crypt_key *ospf_crypt_key_new(void); extern void ospf_crypt_key_add(struct list *, struct crypt_key *); extern int ospf_crypt_key_delete(struct list *, u_char); - extern u_char ospf_default_iftype(struct interface *ifp); +extern int ospf_interface_neighbor_count(struct ospf_interface *oi); /* Set all multicast memberships appropriately based on the type and state of the interface. */ diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index a2961992de..0f1dd63dfb 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -1872,8 +1872,7 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, if (area->external_routing != OSPF_AREA_NSSA && !type7) continue; - LSDB_LOOP(NSSA_LSDB(area), rn, lsa) - { + LSDB_LOOP (NSSA_LSDB(area), rn, lsa) { if (lsa->data->id.s_addr == type5->data->id.s_addr) { type7 = lsa; @@ -3007,27 +3006,27 @@ int ospf_lsa_maxage_walker(struct thread *thread) for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) { LSDB_LOOP(ROUTER_LSDB(area), rn, lsa) - ospf_lsa_maxage_walker_remover(ospf, lsa); + ospf_lsa_maxage_walker_remover(ospf, lsa); LSDB_LOOP(NETWORK_LSDB(area), rn, lsa) - ospf_lsa_maxage_walker_remover(ospf, lsa); + ospf_lsa_maxage_walker_remover(ospf, lsa); LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) - ospf_lsa_maxage_walker_remover(ospf, lsa); + ospf_lsa_maxage_walker_remover(ospf, lsa); LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) - ospf_lsa_maxage_walker_remover(ospf, lsa); + ospf_lsa_maxage_walker_remover(ospf, lsa); LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) - ospf_lsa_maxage_walker_remover(ospf, lsa); + ospf_lsa_maxage_walker_remover(ospf, lsa); LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) - ospf_lsa_maxage_walker_remover(ospf, lsa); + ospf_lsa_maxage_walker_remover(ospf, lsa); LSDB_LOOP(NSSA_LSDB(area), rn, lsa) - ospf_lsa_maxage_walker_remover(ospf, lsa); + ospf_lsa_maxage_walker_remover(ospf, lsa); } /* for AS-external-LSAs. */ if (ospf->lsdb) { LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) - ospf_lsa_maxage_walker_remover(ospf, lsa); + ospf_lsa_maxage_walker_remover(ospf, lsa); LSDB_LOOP(OPAQUE_AS_LSDB(ospf), rn, lsa) - ospf_lsa_maxage_walker_remover(ospf, lsa); + ospf_lsa_maxage_walker_remover(ospf, lsa); } OSPF_TIMER_ON(ospf->t_maxage_walker, ospf_lsa_maxage_walker, @@ -3350,20 +3349,20 @@ void ospf_flush_self_originated_lsas_now(struct ospf *ospf) } LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) - ospf_lsa_flush_schedule(ospf, lsa); + ospf_lsa_flush_schedule(ospf, lsa); LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) - ospf_lsa_flush_schedule(ospf, lsa); + ospf_lsa_flush_schedule(ospf, lsa); LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) - ospf_lsa_flush_schedule(ospf, lsa); + ospf_lsa_flush_schedule(ospf, lsa); LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) - ospf_lsa_flush_schedule(ospf, lsa); + ospf_lsa_flush_schedule(ospf, lsa); } if (need_to_flush_ase) { LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) - ospf_lsa_flush_schedule(ospf, lsa); + ospf_lsa_flush_schedule(ospf, lsa); LSDB_LOOP(OPAQUE_AS_LSDB(ospf), rn, lsa) - ospf_lsa_flush_schedule(ospf, lsa); + ospf_lsa_flush_schedule(ospf, lsa); } /* diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index c87001294d..54d5dd5d16 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -280,37 +280,37 @@ static int nsm_negotiation_done(struct ospf_neighbor *nbr) ospf_proactively_arp(nbr); LSDB_LOOP(ROUTER_LSDB(area), rn, lsa) - ospf_db_summary_add(nbr, lsa); + ospf_db_summary_add(nbr, lsa); LSDB_LOOP(NETWORK_LSDB(area), rn, lsa) - ospf_db_summary_add(nbr, lsa); + ospf_db_summary_add(nbr, lsa); LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) - ospf_db_summary_add(nbr, lsa); + ospf_db_summary_add(nbr, lsa); LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) - ospf_db_summary_add(nbr, lsa); + ospf_db_summary_add(nbr, lsa); /* Process only if the neighbor is opaque capable. */ if (CHECK_FLAG(nbr->options, OSPF_OPTION_O)) { LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) - ospf_db_summary_add(nbr, lsa); + ospf_db_summary_add(nbr, lsa); LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) - ospf_db_summary_add(nbr, lsa); + ospf_db_summary_add(nbr, lsa); } if (CHECK_FLAG(nbr->options, OSPF_OPTION_NP)) { LSDB_LOOP(NSSA_LSDB(area), rn, lsa) - ospf_db_summary_add(nbr, lsa); + ospf_db_summary_add(nbr, lsa); } if (nbr->oi->type != OSPF_IFTYPE_VIRTUALLINK && area->external_routing == OSPF_AREA_DEFAULT) LSDB_LOOP(EXTERNAL_LSDB(nbr->oi->ospf), rn, lsa) - ospf_db_summary_add(nbr, lsa); + ospf_db_summary_add(nbr, lsa); if (CHECK_FLAG(nbr->options, OSPF_OPTION_O) && (nbr->oi->type != OSPF_IFTYPE_VIRTUALLINK && area->external_routing == OSPF_AREA_DEFAULT)) LSDB_LOOP(OPAQUE_AS_LSDB(nbr->oi->ospf), rn, lsa) - ospf_db_summary_add(nbr, lsa); + ospf_db_summary_add(nbr, lsa); return 0; } diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index 78d82f8a67..986c202d8e 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -607,30 +607,6 @@ static void free_opaque_info_per_type(void *val) ospf_opaque_lsa_flush_schedule(lsa); } - /* Remove "oipt" from its owner's self-originated LSA list. */ - switch (oipt->lsa_type) { - case OSPF_OPAQUE_LINK_LSA: { - struct ospf_interface *oi = - (struct ospf_interface *)(oipt->owner); - listnode_delete(oi->opaque_lsa_self, oipt); - break; - } - case OSPF_OPAQUE_AREA_LSA: { - struct ospf_area *area = (struct ospf_area *)(oipt->owner); - listnode_delete(area->opaque_lsa_self, oipt); - break; - } - case OSPF_OPAQUE_AS_LSA: { - struct ospf *top = (struct ospf *)(oipt->owner); - listnode_delete(top->opaque_lsa_self, oipt); - break; - } - default: - zlog_warn("free_opaque_info_per_type: Unexpected LSA-type(%u)", - oipt->lsa_type); - break; /* This case may not exist. */ - } - OSPF_TIMER_OFF(oipt->t_opaque_lsa_self); list_delete_and_null(&oipt->id_list); XFREE(MTYPE_OPAQUE_INFO_PER_TYPE, oipt); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 0541bfeee7..c923a6f35e 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -218,7 +218,7 @@ DEFUN_NOSH (router_ospf, if (ospf->vrf_id != VRF_UNKNOWN) ospf->oi_running = 1; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("Config command 'router ospf %d' received, vrf %s id %d oi_running %u", + zlog_debug("Config command 'router ospf %d' received, vrf %s id %u oi_running %u", instance, ospf->name ? ospf->name : "NIL", ospf->vrf_id, ospf->oi_running); VTY_PUSH_CONTEXT(OSPF_NODE, ospf); @@ -3693,14 +3693,15 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf, { struct interface *ifp; struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); - json_object *json_vrf = NULL; - json_object *json_interface_sub = NULL; + json_object *json_vrf = NULL, *json_intf_array = NULL; + json_object *json_interface_sub = NULL, *json_interface = NULL; if (use_json) { if (use_vrf) json_vrf = json_object_new_object(); else json_vrf = json; + json_intf_array = json_object_new_array(); } if (ospf->instance) { @@ -3714,21 +3715,29 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf, ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); if (intf_name == NULL) { + if (use_json) + json_object_object_add(json_vrf, "interfaces", + json_intf_array); /* Show All Interfaces.*/ FOR_ALL_INTERFACES (vrf, ifp) { if (ospf_oi_count(ifp)) { - if (use_json) + if (use_json) { + json_interface = + json_object_new_object(); json_interface_sub = json_object_new_object(); - + } show_ip_ospf_interface_sub(vty, ospf, ifp, json_interface_sub, use_json); - if (use_json) + if (use_json) { + json_object_array_add(json_intf_array, + json_interface); json_object_object_add( - json_vrf, ifp->name, + json_interface, ifp->name, json_interface_sub); + } } } } else { @@ -3741,15 +3750,23 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf, else vty_out(vty, "No such interface name\n"); } else { - if (use_json) + if (use_json) { json_interface_sub = json_object_new_object(); + json_interface = json_object_new_object(); + json_object_object_add(json_vrf, "interfaces", + json_intf_array); + } show_ip_ospf_interface_sub( vty, ospf, ifp, json_interface_sub, use_json); - if (use_json) - json_object_object_add(json_vrf, ifp->name, + if (use_json) { + json_object_array_add(json_intf_array, + json_interface); + json_object_object_add(json_interface, + ifp->name, json_interface_sub); + } } } @@ -4283,13 +4300,15 @@ static int show_ip_ospf_neighbor_common(struct vty *vty, struct ospf *ospf, { struct ospf_interface *oi; struct listnode *node; - json_object *json_vrf = NULL; + json_object *json_vrf = NULL, *json_nbr_array = NULL; + json_object *json_nbr_sub = NULL; if (use_json) { if (use_vrf) json_vrf = json_object_new_object(); else json_vrf = json; + json_nbr_array = json_object_new_array(); } if (ospf->instance) { @@ -4303,9 +4322,19 @@ static int show_ip_ospf_neighbor_common(struct vty *vty, struct ospf *ospf, ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf); if (!use_json) show_ip_ospf_neighbour_header(vty); + else + json_object_object_add(json_vrf, "neighbors", + json_nbr_array); - for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) - show_ip_ospf_neighbor_sub(vty, oi, json_vrf, use_json); + for (ALL_LIST_ELEMENTS_RO(ospf->oiflist, node, oi)) { + if (ospf_interface_neighbor_count(oi) == 0) + continue; + if (use_json) { + json_nbr_sub = json_object_new_object(); + json_object_array_add(json_nbr_array, json_nbr_sub); + } + show_ip_ospf_neighbor_sub(vty, oi, json_nbr_sub, use_json); + } if (use_json) { if (use_vrf) { @@ -4681,7 +4710,6 @@ static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf, ospf_show_vrf_name(ospf, vty, json, use_vrf); - /*ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id);*/ ifp = if_lookup_by_name_all_vrf(argv[arg_base]->arg); if (!ifp) { if (use_json) @@ -6167,7 +6195,7 @@ static void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf, show_database_header[type]); LSDB_LOOP(AREA_LSDB(area, type), rn, lsa) - show_lsa_summary(vty, lsa, self); + show_lsa_summary(vty, lsa, self); vty_out(vty, "\n"); } @@ -6189,7 +6217,7 @@ static void show_ip_ospf_database_summary(struct vty *vty, struct ospf *ospf, vty_out(vty, "%s\n", show_database_header[type]); LSDB_LOOP(AS_LSDB(ospf, type), rn, lsa) - show_lsa_summary(vty, lsa, self); + show_lsa_summary(vty, lsa, self); vty_out(vty, "\n"); } @@ -8099,7 +8127,7 @@ DEFUN (no_ip_ospf_area, DEFUN (ospf_redistribute_source, ospf_redistribute_source_cmd, - "redistribute " FRR_REDIST_STR_OSPFD " [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", + "redistribute " FRR_REDIST_STR_OSPFD " [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", REDIST_STR FRR_REDIST_HELP_STR_OSPFD "Metric for redistributed routes\n" @@ -8132,13 +8160,15 @@ DEFUN (ospf_redistribute_source, if (!str2metric(argv[idx]->arg, &metric)) return CMD_WARNING_CONFIG_FAILED; } + idx = 1; /* Get metric type. */ - else if (argv_find(argv, argc, "(1-2)", &idx)) { + if (argv_find(argv, argc, "(1-2)", &idx)) { if (!str2metric_type(argv[idx]->arg, &type)) return CMD_WARNING_CONFIG_FAILED; } + idx = 1; /* Get route-map */ - else if (argv_find(argv, argc, "WORD", &idx)) { + if (argv_find(argv, argc, "WORD", &idx)) { ospf_routemap_set(red, argv[idx]->arg); } else ospf_routemap_unset(red); @@ -8148,7 +8178,7 @@ DEFUN (ospf_redistribute_source, DEFUN (no_ospf_redistribute_source, no_ospf_redistribute_source_cmd, - "no redistribute " FRR_REDIST_STR_OSPFD " [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]", + "no redistribute " FRR_REDIST_STR_OSPFD " [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", NO_STR REDIST_STR FRR_REDIST_HELP_STR_OSPFD @@ -8338,7 +8368,7 @@ DEFUN (no_ospf_distribute_list_out, /* Default information originate. */ DEFUN (ospf_default_information_originate, ospf_default_information_originate_cmd, - "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]", + "default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]", "Control distribution of default information\n" "Distribute a default route\n" "Always advertise default route\n" @@ -8361,18 +8391,21 @@ DEFUN (ospf_default_information_originate, /* Check whether "always" was specified */ if (argv_find(argv, argc, "always", &idx)) default_originate = DEFAULT_ORIGINATE_ALWAYS; + idx = 1; /* Get metric value */ - else if (argv_find(argv, argc, "(0-16777214)", &idx)) { + if (argv_find(argv, argc, "(0-16777214)", &idx)) { if (!str2metric(argv[idx]->arg, &metric)) return CMD_WARNING_CONFIG_FAILED; } + idx = 1; /* Get metric type. */ - else if (argv_find(argv, argc, "(1-2)", &idx)) { + if (argv_find(argv, argc, "(1-2)", &idx)) { if (!str2metric_type(argv[idx]->arg, &type)) return CMD_WARNING_CONFIG_FAILED; } + idx = 1; /* Get route-map */ - else if (argv_find(argv, argc, "WORD", &idx)) + if (argv_find(argv, argc, "WORD", &idx)) ospf_routemap_set(red, argv[idx]->arg); else ospf_routemap_unset(red); @@ -8383,7 +8416,7 @@ DEFUN (ospf_default_information_originate, DEFUN (no_ospf_default_information_originate, no_ospf_default_information_originate_cmd, - "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]", + "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]", NO_STR "Control distribution of default information\n" "Distribute a default route\n" @@ -9496,9 +9529,9 @@ DEFUN (show_ip_ospf_route, } if (uj) { + /* Keep Non-pretty format */ vty_out(vty, "%s\n", - json_object_to_json_string_ext(json, - JSON_C_TO_STRING_PRETTY)); + json_object_to_json_string(json)); json_object_free(json); } @@ -9522,9 +9555,9 @@ DEFUN (show_ip_ospf_route, if (ospf) { ret = show_ip_ospf_route_common(vty, ospf, json, use_vrf); + /* Keep Non-pretty format */ if (uj) - vty_out(vty, "%s\n", json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); + vty_out(vty, "%s\n", json_object_to_json_string(json)); } if (uj) @@ -9583,7 +9616,7 @@ DEFUN (show_ip_ospf_vrfs, for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) { json_object *json_vrf = NULL; const char *name = NULL; - int vrf_id_ui = 0; + int64_t vrf_id_ui = 0; count++; @@ -9597,7 +9630,8 @@ DEFUN (show_ip_ospf_vrfs, else name = ospf->name; - vrf_id_ui = (ospf->vrf_id == VRF_UNKNOWN) ? -1 : ospf->vrf_id; + vrf_id_ui = (ospf->vrf_id == VRF_UNKNOWN) ? -1 : + (int64_t) ospf->vrf_id; if (uj) { json_object_int_add(json_vrf, "vrfId", vrf_id_ui); @@ -10202,8 +10236,12 @@ static int config_write_ospf_distribute(struct vty *vty, struct ospf *ospf) if (red->dmetric.value >= 0) vty_out(vty, " metric %d", red->dmetric.value); + if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1) vty_out(vty, " metric-type 1"); + else if (red->dmetric.type == + EXTERNAL_METRIC_TYPE_2) + vty_out(vty, " metric-type 2"); if (ROUTEMAP_NAME(red)) vty_out(vty, " route-map %s", diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index 66be29dbb4..58e8a921d5 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -389,6 +389,7 @@ void ospf_zebra_add(struct ospf *ospf, struct prefix_ipv4 *p, memset(&api, 0, sizeof(api)); api.vrf_id = ospf->vrf_id; + api.nh_vrf_id = ospf->vrf_id; api.type = ZEBRA_ROUTE_OSPF; api.instance = ospf->instance; api.safi = SAFI_UNICAST; @@ -466,6 +467,7 @@ void ospf_zebra_delete(struct ospf *ospf, struct prefix_ipv4 *p, memset(&api, 0, sizeof(api)); api.vrf_id = ospf->vrf_id; + api.nh_vrf_id = ospf->vrf_id; api.type = ZEBRA_ROUTE_OSPF; api.instance = ospf->instance; api.safi = SAFI_UNICAST; @@ -487,6 +489,7 @@ void ospf_zebra_add_discard(struct ospf *ospf, struct prefix_ipv4 *p) memset(&api, 0, sizeof(api)); api.vrf_id = ospf->vrf_id; + api.nh_vrf_id = ospf->vrf_id; api.type = ZEBRA_ROUTE_OSPF; api.instance = ospf->instance; api.safi = SAFI_UNICAST; @@ -506,6 +509,7 @@ void ospf_zebra_delete_discard(struct ospf *ospf, struct prefix_ipv4 *p) memset(&api, 0, sizeof(api)); api.vrf_id = ospf->vrf_id; + api.nh_vrf_id = ospf->vrf_id; api.type = ZEBRA_ROUTE_OSPF; api.instance = ospf->instance; api.safi = SAFI_UNICAST; diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index b60cdb3527..e53599462b 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -32,6 +32,7 @@ #include "log.h" #include "sockunion.h" /* for inet_aton () */ #include "zclient.h" +#include "routemap.h" #include "plist.h" #include "sockopt.h" #include "bfd.h" @@ -159,8 +160,8 @@ void ospf_router_id_update(struct ospf *ospf) struct ospf_lsa *lsa; LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) - if (IS_LSA_SELF(lsa)) - ospf_lsa_flush_schedule(ospf, lsa); + if (IS_LSA_SELF(lsa)) + ospf_lsa_flush_schedule(ospf, lsa); } ospf->router_id = router_id; @@ -183,8 +184,7 @@ void ospf_router_id_update(struct ospf *ospf) struct route_node *rn; struct ospf_lsa *lsa; - LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) - { + LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa) { /* AdvRouter and Router ID is the same. */ if (IPV4_ADDR_SAME(&lsa->data->adv_router, &ospf->router_id)) { @@ -241,7 +241,7 @@ static struct ospf *ospf_new(u_short instance, const char *name) new->name = XSTRDUP(MTYPE_OSPF_TOP, name); vrf = vrf_lookup_by_name(new->name); if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: Create new ospf instance with vrf_name %s vrf_id %d", + zlog_debug("%s: Create new ospf instance with vrf_name %s vrf_id %u", __PRETTY_FUNCTION__, name, new->vrf_id); if (vrf) ospf_vrf_link(new, vrf); @@ -555,6 +555,20 @@ void ospf_terminate(void) for (ALL_LIST_ELEMENTS(om->ospf, node, nnode, ospf)) ospf_finish(ospf); + /* Cleanup route maps */ + route_map_add_hook(NULL); + route_map_delete_hook(NULL); + route_map_event_hook(NULL); + route_map_finish(); + + /* reverse prefix_list_init */ + prefix_list_add_hook(NULL); + prefix_list_delete_hook(NULL); + prefix_list_reset(); + + /* Cleanup vrf info */ + ospf_vrf_terminate(); + /* Deliberately go back up, hopefully to thread scheduler, as * One or more ospf_finish()'s may have deferred shutdown to a timer * thread @@ -693,9 +707,9 @@ static void ospf_finish_final(struct ospf *ospf) stream_free(ospf->ibuf); LSDB_LOOP(OPAQUE_AS_LSDB(ospf), rn, lsa) - ospf_discard_from_db(ospf, ospf->lsdb, lsa); + ospf_discard_from_db(ospf, ospf->lsdb, lsa); LSDB_LOOP(EXTERNAL_LSDB(ospf), rn, lsa) - ospf_discard_from_db(ospf, ospf->lsdb, lsa); + ospf_discard_from_db(ospf, ospf->lsdb, lsa); ospf_lsdb_delete_all(ospf->lsdb); ospf_lsdb_free(ospf->lsdb); @@ -832,22 +846,21 @@ static void ospf_area_free(struct ospf_area *area) /* Free LSDBs. */ LSDB_LOOP(ROUTER_LSDB(area), rn, lsa) - ospf_discard_from_db(area->ospf, area->lsdb, lsa); + ospf_discard_from_db(area->ospf, area->lsdb, lsa); LSDB_LOOP(NETWORK_LSDB(area), rn, lsa) - ospf_discard_from_db(area->ospf, area->lsdb, lsa); + ospf_discard_from_db(area->ospf, area->lsdb, lsa); LSDB_LOOP(SUMMARY_LSDB(area), rn, lsa) - ospf_discard_from_db(area->ospf, area->lsdb, lsa); + ospf_discard_from_db(area->ospf, area->lsdb, lsa); LSDB_LOOP(ASBR_SUMMARY_LSDB(area), rn, lsa) - ospf_discard_from_db(area->ospf, area->lsdb, lsa); + ospf_discard_from_db(area->ospf, area->lsdb, lsa); LSDB_LOOP(NSSA_LSDB(area), rn, lsa) - ospf_discard_from_db(area->ospf, area->lsdb, lsa); + ospf_discard_from_db(area->ospf, area->lsdb, lsa); LSDB_LOOP(OPAQUE_AREA_LSDB(area), rn, lsa) - ospf_discard_from_db(area->ospf, area->lsdb, lsa); + ospf_discard_from_db(area->ospf, area->lsdb, lsa); LSDB_LOOP(OPAQUE_LINK_LSDB(area), rn, lsa) - ospf_discard_from_db(area->ospf, area->lsdb, lsa); + ospf_discard_from_db(area->ospf, area->lsdb, lsa); - ospf_opaque_type10_lsa_term(area); ospf_lsdb_delete_all(area->lsdb); ospf_lsdb_free(area->lsdb); @@ -2016,7 +2029,7 @@ void ospf_vrf_unlink(struct ospf *ospf, struct vrf *vrf) static int ospf_vrf_new(struct vrf *vrf) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: VRF Created: %s(%d)", __PRETTY_FUNCTION__, + zlog_debug("%s: VRF Created: %s(%u)", __PRETTY_FUNCTION__, vrf->name, vrf->vrf_id); return 0; @@ -2026,7 +2039,7 @@ static int ospf_vrf_new(struct vrf *vrf) static int ospf_vrf_delete(struct vrf *vrf) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: VRF Deletion: %s(%d)", __PRETTY_FUNCTION__, + zlog_debug("%s: VRF Deletion: %s(%u)", __PRETTY_FUNCTION__, vrf->name, vrf->vrf_id); return 0; @@ -2039,7 +2052,7 @@ static int ospf_vrf_enable(struct vrf *vrf) vrf_id_t old_vrf_id = VRF_DEFAULT; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: VRF %s id %d enabled", + zlog_debug("%s: VRF %s id %u enabled", __PRETTY_FUNCTION__, vrf->name, vrf->vrf_id); ospf = ospf_lookup_by_name(vrf->name); @@ -2048,7 +2061,7 @@ static int ospf_vrf_enable(struct vrf *vrf) /* We have instance configured, link to VRF and make it "up". */ ospf_vrf_link(ospf, vrf); if (IS_DEBUG_OSPF_EVENT) - zlog_debug("%s: ospf linked to vrf %s vrf_id %d (old id %d)", + zlog_debug("%s: ospf linked to vrf %s vrf_id %u (old id %u)", __PRETTY_FUNCTION__, vrf->name, ospf->vrf_id, old_vrf_id); |
