diff options
Diffstat (limited to 'ospfd/ospf_interface.c')
| -rw-r--r-- | ospfd/ospf_interface.c | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 0161f05d71..334ed33ee0 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -35,6 +35,7 @@ #include "ldp_sync.h" #include "ospfd/ospfd.h" +#include "ospfd/ospf_bfd.h" #include "ospfd/ospf_spf.h" #include "ospfd/ospf_interface.h" #include "ospfd/ospf_ism.h" @@ -542,13 +543,16 @@ static struct ospf_if_params *ospf_new_if_params(void) oip->network_lsa_seqnum = htonl(OSPF_INITIAL_SEQUENCE_NUMBER); oip->is_v_wait_set = false; + oip->ptp_dmvpn = 0; + return oip; } -void ospf_del_if_params(struct ospf_if_params *oip) +static void ospf_del_if_params(struct interface *ifp, + struct ospf_if_params *oip) { list_delete(&oip->auth_crypt); - bfd_info_free(&(oip->bfd_info)); + ospf_interface_disable_bfd(ifp, oip); ldp_sync_info_free(&(oip->ldp_sync_info)); XFREE(MTYPE_OSPF_IF_PARAMS, oip); } @@ -582,7 +586,7 @@ void ospf_free_if_params(struct interface *ifp, struct in_addr addr) && !OSPF_IF_PARAM_CONFIGURED(oip, auth_type) && !OSPF_IF_PARAM_CONFIGURED(oip, if_area) && listcount(oip->auth_crypt) == 0) { - ospf_del_if_params(oip); + ospf_del_if_params(ifp, oip); rn->info = NULL; route_unlock_node(rn); } @@ -692,14 +696,20 @@ static int ospf_if_delete_hook(struct interface *ifp) struct route_node *rn; rc = ospf_opaque_del_if(ifp); + /* + * This function must be called before `route_table_finish` due to + * BFD integration need to iterate over the interface neighbors to + * remove all registrations. + */ + ospf_del_if_params(ifp, IF_DEF_PARAMS(ifp)); + route_table_finish(IF_OIFS(ifp)); for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn)) if (rn->info) - ospf_del_if_params(rn->info); + ospf_del_if_params(ifp, rn->info); route_table_finish(IF_OIFS_PARAMS(ifp)); - ospf_del_if_params((struct ospf_if_params *)IF_DEF_PARAMS(ifp)); XFREE(MTYPE_OSPF_IF_INFO, ifp->info); return rc; @@ -1270,12 +1280,27 @@ void ospf_if_interface(struct interface *ifp) hook_call(ospf_if_update, ifp); } -static int ospf_ifp_create(struct interface *ifp) +uint32_t ospf_if_count_area_params(struct interface *ifp) { - struct ospf *ospf = NULL; struct ospf_if_params *params; struct route_node *rn; uint32_t count = 0; + + params = IF_DEF_PARAMS(ifp); + if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) + count++; + + for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn)) + if ((params = rn->info) + && OSPF_IF_PARAM_CONFIGURED(params, if_area)) + count++; + + return count; +} + +static int ospf_ifp_create(struct interface *ifp) +{ + struct ospf *ospf = NULL; struct ospf_if_info *oii; if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) @@ -1301,18 +1326,8 @@ static int ospf_ifp_create(struct interface *ifp) if (!ospf) return 0; - params = IF_DEF_PARAMS(ifp); - if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) - count++; - - for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn)) - if ((params = rn->info) && OSPF_IF_PARAM_CONFIGURED(params, if_area)) - count++; - - if (count > 0) { - ospf->if_ospf_cli_count += count; + if (ospf_if_count_area_params(ifp) > 0) ospf_interface_area_set(ospf, ifp); - } ospf_if_recalculate_output_cost(ifp); @@ -1380,9 +1395,7 @@ static int ospf_ifp_down(struct interface *ifp) static int ospf_ifp_destroy(struct interface *ifp) { struct ospf *ospf; - struct ospf_if_params *params; struct route_node *rn; - uint32_t count = 0; if (IS_DEBUG_OSPF(zebra, ZEBRA_INTERFACE)) zlog_debug( @@ -1395,18 +1408,8 @@ static int ospf_ifp_destroy(struct interface *ifp) ospf = ospf_lookup_by_vrf_id(ifp->vrf_id); if (ospf) { - params = IF_DEF_PARAMS(ifp); - if (OSPF_IF_PARAM_CONFIGURED(params, if_area)) - count++; - - for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn)) - if ((params = rn->info) && OSPF_IF_PARAM_CONFIGURED(params, if_area)) - count++; - - if (count > 0) { - ospf->if_ospf_cli_count -= count; + if (ospf_if_count_area_params(ifp) > 0) ospf_interface_area_unset(ospf, ifp); - } } for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) |
