diff options
Diffstat (limited to 'isisd/isis_nb_config.c')
-rw-r--r-- | isisd/isis_nb_config.c | 197 |
1 files changed, 93 insertions, 104 deletions
diff --git a/isisd/isis_nb_config.c b/isisd/isis_nb_config.c index 763b8b73..fb391534 100644 --- a/isisd/isis_nb_config.c +++ b/isisd/isis_nb_config.c @@ -252,11 +252,12 @@ int isis_instance_area_address_destroy(struct nb_cb_destroy_args *args) return NB_ERR_INCONSISTENCY; listnode_delete(area->area_addrs, addrp); - XFREE(MTYPE_ISIS_AREA_ADDR, addrp); /* * Last area address - reset the SystemID for this router */ - if (listcount(area->area_addrs) == 0) { + if (!memcmp(addrp->area_addr + addrp->addr_len, area->isis->sysid, + ISIS_SYS_ID_LEN) && + listcount(area->area_addrs) == 0) { for (ALL_LIST_ELEMENTS_RO(area->circuit_list, cnode, circuit)) for (lvl = IS_LEVEL_1; lvl <= IS_LEVEL_2; ++lvl) { if (circuit->u.bc.is_dr[lvl - 1]) @@ -268,6 +269,8 @@ int isis_instance_area_address_destroy(struct nb_cb_destroy_args *args) zlog_debug("Router has no SystemID"); } + XFREE(MTYPE_ISIS_AREA_ADDR, addrp); + return NB_OK; } @@ -2630,14 +2633,14 @@ int isis_instance_segment_routing_algorithm_prefix_sid_create( struct isis_area *area; struct prefix prefix; struct sr_prefix_cfg *pcfg; - uint32_t algorithm; + uint8_t algorithm; if (args->event != NB_EV_APPLY) return NB_OK; area = nb_running_get_entry(args->dnode, NULL, true); yang_dnode_get_prefix(&prefix, args->dnode, "prefix"); - algorithm = yang_dnode_get_uint32(args->dnode, "algo"); + algorithm = yang_dnode_get_uint8(args->dnode, "algo"); pcfg = isis_sr_cfg_prefix_add(area, &prefix, algorithm); pcfg->algorithm = algorithm; @@ -2835,7 +2838,9 @@ int isis_instance_flex_algo_create(struct nb_cb_create_args *args) { struct isis_area *area; struct flex_algo *fa; - bool advertise; + bool advertise, update_te; + struct isis_circuit *circuit; + struct listnode *node; uint32_t algorithm; uint32_t priority = FLEX_ALGO_PRIO_DEFAULT; struct isis_flex_algo_alloc_arg arg; @@ -2848,6 +2853,7 @@ int isis_instance_flex_algo_create(struct nb_cb_create_args *args) area = nb_running_get_entry(args->dnode, NULL, true); arg.algorithm = algorithm; arg.area = area; + update_te = list_isempty(area->flex_algos->flex_algos); fa = flex_algo_alloc(area->flex_algos, algorithm, &arg); fa->priority = priority; fa->advertise_definition = advertise; @@ -2859,6 +2865,12 @@ int isis_instance_flex_algo_create(struct nb_cb_create_args *args) admin_group_allow_explicit_zero( &fa->admin_group_include_all); } + if (update_te) { + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, + circuit)) + isis_link_params_update_asla(circuit, + circuit->interface); + } lsp_regenerate_schedule(area, area->is_type, 0); break; case NB_EV_VALIDATE: @@ -2872,22 +2884,28 @@ int isis_instance_flex_algo_create(struct nb_cb_create_args *args) int isis_instance_flex_algo_destroy(struct nb_cb_destroy_args *args) { + struct isis_circuit *circuit; + struct listnode *node, *nnode; + struct flex_algo *fa; struct isis_area *area; uint32_t algorithm; + if (args->event != NB_EV_APPLY) + return NB_OK; + algorithm = yang_dnode_get_uint32(args->dnode, "flex-algo"); area = nb_running_get_entry(args->dnode, NULL, true); - switch (args->event) { - case NB_EV_APPLY: - flex_algo_delete(area->flex_algos, algorithm); - lsp_regenerate_schedule(area, area->is_type, 0); - break; - case NB_EV_VALIDATE: - case NB_EV_PREPARE: - case NB_EV_ABORT: - break; + for (ALL_LIST_ELEMENTS(area->flex_algos->flex_algos, node, nnode, fa)) { + if (fa->algorithm == algorithm) + flex_algo_free(area->flex_algos, fa); } + if (list_isempty(area->flex_algos->flex_algos)) { + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) + isis_link_params_update_asla(circuit, + circuit->interface); + } + lsp_regenerate_schedule(area, area->is_type, 0); return NB_OK; } @@ -2935,26 +2953,22 @@ int isis_instance_flex_algo_advertise_definition_destroy( struct flex_algo *fa; uint32_t algorithm; + + if (args->event != NB_EV_APPLY) + return NB_OK; + area = nb_running_get_entry(args->dnode, NULL, true); algorithm = yang_dnode_get_uint32(args->dnode, "../flex-algo"); - switch (args->event) { - case NB_EV_APPLY: - fa = flex_algo_lookup(area->flex_algos, algorithm); - if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); - return NB_ERR_RESOURCE; - } - fa->advertise_definition = false; - lsp_regenerate_schedule(area, area->is_type, 0); - break; - case NB_EV_VALIDATE: - case NB_EV_PREPARE: - case NB_EV_ABORT: - break; + fa = flex_algo_lookup(area->flex_algos, algorithm); + if (!fa) { + snprintf(args->errmsg, args->errmsg_len, + "flex-algo object not found"); + return NB_ERR_RESOURCE; } + fa->advertise_definition = false; + lsp_regenerate_schedule(area, area->is_type, 0); return NB_OK; } @@ -2962,27 +2976,23 @@ int isis_instance_flex_algo_advertise_definition_destroy( static int isis_instance_flex_algo_affinity_set(struct nb_cb_create_args *args, int type) { - struct affinity_map *map; + char xpathr[XPATH_MAXLEN]; + struct lyd_node *dnode; struct isis_area *area; struct admin_group *ag; + uint16_t bit_position; struct flex_algo *fa; uint32_t algorithm; const char *val; - algorithm = yang_dnode_get_uint32(args->dnode, "../../flex-algo"); - area = nb_running_get_entry(args->dnode, NULL, true); val = yang_dnode_get_string(args->dnode, "."); switch (args->event) { case NB_EV_VALIDATE: - fa = flex_algo_lookup(area->flex_algos, algorithm); - if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); - return NB_ERR_RESOURCE; - } - map = affinity_map_get(val); - if (!map) { + snprintf(xpathr, sizeof(xpathr), + "/frr-affinity-map:lib/affinity-maps/affinity-map[name='%s']/value", + val); + if (!yang_dnode_get(args->dnode, xpathr)) { snprintf(args->errmsg, args->errmsg_len, "affinity map %s isn't found", val); return NB_ERR_VALIDATION; @@ -2992,14 +3002,20 @@ static int isis_instance_flex_algo_affinity_set(struct nb_cb_create_args *args, case NB_EV_ABORT: break; case NB_EV_APPLY: + algorithm = yang_dnode_get_uint32(args->dnode, + "../../flex-algo"); + area = nb_running_get_entry(args->dnode, NULL, true); fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { snprintf(args->errmsg, args->errmsg_len, "flex-algo object not found"); return NB_ERR_RESOURCE; } - map = affinity_map_get(val); - if (!map) { + snprintf(xpathr, sizeof(xpathr), + "/frr-affinity-map:lib/affinity-maps/affinity-map[name='%s']/value", + val); + dnode = yang_dnode_get(args->dnode, xpathr); + if (!dnode) { snprintf(args->errmsg, args->errmsg_len, "affinity map %s isn't found", val); return NB_ERR_RESOURCE; @@ -3013,7 +3029,8 @@ static int isis_instance_flex_algo_affinity_set(struct nb_cb_create_args *args, else break; - admin_group_set(ag, map->bit_position); + bit_position = yang_dnode_get_uint16(dnode, NULL); + admin_group_set(ag, bit_position); lsp_regenerate_schedule(area, area->is_type, 0); break; } @@ -3032,18 +3049,10 @@ isis_instance_flex_algo_affinity_unset(struct nb_cb_destroy_args *args, uint32_t algorithm; const char *val; - algorithm = yang_dnode_get_uint32(args->dnode, "../../flex-algo"); - area = nb_running_get_entry(args->dnode, NULL, true); val = yang_dnode_get_string(args->dnode, "."); switch (args->event) { case NB_EV_VALIDATE: - fa = flex_algo_lookup(area->flex_algos, algorithm); - if (!fa) { - snprintf(args->errmsg, args->errmsg_len, - "flex-algo object not found"); - return NB_ERR_RESOURCE; - } map = affinity_map_get(val); if (!map) { snprintf(args->errmsg, args->errmsg_len, @@ -3055,6 +3064,9 @@ isis_instance_flex_algo_affinity_unset(struct nb_cb_destroy_args *args, case NB_EV_ABORT: break; case NB_EV_APPLY: + algorithm = yang_dnode_get_uint32(args->dnode, + "../../flex-algo"); + area = nb_running_get_entry(args->dnode, NULL, true); fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { snprintf(args->errmsg, args->errmsg_len, @@ -3144,19 +3156,16 @@ int isis_instance_flex_algo_affinity_exclude_any_destroy( int isis_instance_flex_algo_prefix_metric_create(struct nb_cb_create_args *args) { struct isis_area *area; - const char *area_tag; struct flex_algo *fa; uint32_t algorithm; - area_tag = yang_dnode_get_string(args->dnode, "../../../area-tag"); - area = isis_area_lookup(area_tag, VRF_DEFAULT); - if (!area) - return NB_ERR_RESOURCE; - algorithm = yang_dnode_get_uint32(args->dnode, "../flex-algo"); switch (args->event) { case NB_EV_APPLY: + area = nb_running_get_entry(args->dnode, NULL, true); + if (!area) + return NB_ERR_RESOURCE; fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { snprintf(args->errmsg, args->errmsg_len, @@ -3179,19 +3188,17 @@ int isis_instance_flex_algo_prefix_metric_destroy( struct nb_cb_destroy_args *args) { struct isis_area *area; - const char *area_tag; struct flex_algo *fa; uint32_t algorithm; - area_tag = yang_dnode_get_string(args->dnode, "../../../area-tag"); - area = isis_area_lookup(area_tag, VRF_DEFAULT); - if (!area) - return NB_ERR_RESOURCE; - algorithm = yang_dnode_get_uint32(args->dnode, "../flex-algo"); switch (args->event) { case NB_EV_APPLY: + area = nb_running_get_entry(args->dnode, NULL, true); + if (!area) + return NB_ERR_RESOURCE; + fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { snprintf(args->errmsg, args->errmsg_len, @@ -3214,19 +3221,17 @@ static int isis_instance_flex_algo_dplane_set(struct nb_cb_create_args *args, int type) { struct isis_area *area; - const char *area_tag; struct flex_algo *fa; uint32_t algorithm; - area_tag = yang_dnode_get_string(args->dnode, "../../../area-tag"); - area = isis_area_lookup(area_tag, VRF_DEFAULT); - if (!area) - return NB_ERR_RESOURCE; - algorithm = yang_dnode_get_uint32(args->dnode, "../flex-algo"); switch (args->event) { case NB_EV_APPLY: + area = nb_running_get_entry(args->dnode, NULL, true); + if (!area) + return NB_ERR_RESOURCE; + fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { snprintf(args->errmsg, args->errmsg_len, @@ -3256,19 +3261,17 @@ static int isis_instance_flex_algo_dplane_unset(struct nb_cb_destroy_args *args, int type) { struct isis_area *area; - const char *area_tag; struct flex_algo *fa; uint32_t algorithm; - area_tag = yang_dnode_get_string(args->dnode, "../../../area-tag"); - area = isis_area_lookup(area_tag, VRF_DEFAULT); - if (!area) - return NB_ERR_RESOURCE; - algorithm = yang_dnode_get_uint32(args->dnode, "../flex-algo"); switch (args->event) { case NB_EV_APPLY: + area = nb_running_get_entry(args->dnode, NULL, true); + if (!area) + return NB_ERR_RESOURCE; + fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { snprintf(args->errmsg, args->errmsg_len, @@ -3338,21 +3341,19 @@ int isis_instance_flex_algo_dplane_ip_destroy(struct nb_cb_destroy_args *args) int isis_instance_flex_algo_metric_type_modify(struct nb_cb_modify_args *args) { struct isis_area *area; - const char *area_tag; struct flex_algo *fa; uint32_t algorithm; enum flex_algo_metric_type metric_type; - area_tag = yang_dnode_get_string(args->dnode, "../../../area-tag"); - area = isis_area_lookup(area_tag, VRF_DEFAULT); - if (!area) - return NB_ERR_RESOURCE; - algorithm = yang_dnode_get_uint32(args->dnode, "../flex-algo"); metric_type = yang_dnode_get_enum(args->dnode, NULL); switch (args->event) { case NB_EV_APPLY: + area = nb_running_get_entry(args->dnode, NULL, true); + if (!area) + return NB_ERR_RESOURCE; + fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { snprintf(args->errmsg, args->errmsg_len, @@ -3378,21 +3379,19 @@ int isis_instance_flex_algo_metric_type_modify(struct nb_cb_modify_args *args) int isis_instance_flex_algo_priority_modify(struct nb_cb_modify_args *args) { struct isis_area *area; - const char *area_tag; struct flex_algo *fa; uint32_t algorithm; uint32_t priority; - area_tag = yang_dnode_get_string(args->dnode, "../../../area-tag"); - area = isis_area_lookup(area_tag, VRF_DEFAULT); - if (!area) - return NB_ERR_RESOURCE; - algorithm = yang_dnode_get_uint32(args->dnode, "../flex-algo"); priority = yang_dnode_get_uint32(args->dnode, NULL); switch (args->event) { case NB_EV_APPLY: + area = nb_running_get_entry(args->dnode, NULL, true); + if (!area) + return NB_ERR_RESOURCE; + fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { snprintf(args->errmsg, args->errmsg_len, @@ -3414,21 +3413,19 @@ int isis_instance_flex_algo_priority_modify(struct nb_cb_modify_args *args) int isis_instance_flex_algo_priority_destroy(struct nb_cb_destroy_args *args) { struct isis_area *area; - const char *area_tag; struct flex_algo *fa; uint32_t algorithm; uint32_t priority = FLEX_ALGO_PRIO_DEFAULT; - area_tag = yang_dnode_get_string(args->dnode, "../../../area-tag"); - area = isis_area_lookup(area_tag, VRF_DEFAULT); - if (!area) - return NB_ERR_RESOURCE; - algorithm = yang_dnode_get_uint32(args->dnode, "../flex-algo"); priority = yang_dnode_get_uint32(args->dnode, NULL); switch (args->event) { case NB_EV_APPLY: + area = nb_running_get_entry(args->dnode, NULL, true); + if (!area) + return NB_ERR_RESOURCE; + fa = flex_algo_lookup(area->flex_algos, algorithm); if (!fa) { snprintf(args->errmsg, args->errmsg_len, @@ -3518,10 +3515,10 @@ int isis_instance_segment_routing_srv6_locator_modify( sr_debug("Configured SRv6 locator %s for IS-IS area %s", loc_name, area->area_tag); - sr_debug("Trying to get a chunk from locator %s for IS-IS area %s", - loc_name, area->area_tag); + sr_debug("Trying to get locator %s for IS-IS area %s", loc_name, + area->area_tag); - if (isis_zebra_srv6_manager_get_locator_chunk(loc_name) < 0) + if (isis_zebra_srv6_manager_get_locator(loc_name) < 0) return NB_ERR; return NB_OK; @@ -4300,14 +4297,6 @@ static int lib_interface_isis_multi_topology_common( switch (event) { case NB_EV_VALIDATE: - circuit = nb_running_get_entry(dnode, NULL, false); - if (circuit && circuit->area && circuit->area->oldmetric) { - snprintf( - errmsg, errmsg_len, - "Multi topology IS-IS can only be used with wide metrics"); - return NB_ERR_VALIDATION; - } - break; case NB_EV_PREPARE: case NB_EV_ABORT: break; |