diff options
author | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2023-08-04 08:11:46 +0200 |
---|---|---|
committer | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2023-09-11 22:11:50 +0200 |
commit | bdbbb26d556ccfb2ee0e3c7bf9418825f0f19f16 (patch) | |
tree | c386803e984e3e21ef0baeaf8c21539ae26819c6 /isisd | |
parent | yang: Add SRv6 MSDs to IS-IS YANG model (diff) | |
download | frr-bdbbb26d556ccfb2ee0e3c7bf9418825f0f19f16.tar.xz frr-bdbbb26d556ccfb2ee0e3c7bf9418825f0f19f16.zip |
isisd: Make SRv6 Node MSDs customizable
Add CLI commands to customize SRv6 Node MSD values.
Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
Diffstat (limited to 'isisd')
-rw-r--r-- | isisd/isis_cli.c | 139 | ||||
-rw-r--r-- | isisd/isis_nb.c | 34 | ||||
-rw-r--r-- | isisd/isis_nb.h | 18 | ||||
-rw-r--r-- | isisd/isis_nb_config.c | 156 | ||||
-rw-r--r-- | isisd/isis_srv6.c | 15 | ||||
-rw-r--r-- | isisd/isis_srv6.h | 7 | ||||
-rw-r--r-- | isisd/isisd.c | 10 |
7 files changed, 367 insertions, 12 deletions
diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index c024422d6..328f76b35 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -2109,6 +2109,136 @@ void cli_show_isis_srv6_enabled(struct vty *vty, const struct lyd_node *dnode, } /* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd + */ +DEFPY_YANG_NOSH (isis_srv6_node_msd, + isis_srv6_node_msd_cmd, + "[no] node-msd", + NO_STR + "Segment Routing over IPv6 (SRv6) Maximum SRv6 SID Depths\n") +{ + int ret = CMD_SUCCESS; + char xpath[XPATH_MAXLEN + 37]; + + snprintf(xpath, sizeof(xpath), "%s/msd/node-msd", VTY_CURR_XPATH); + + if (no) { + nb_cli_enqueue_change(vty, "./msd/node_msd/max-segs-left", + NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./msd/node_msd/end-pop", + NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./msd/node_msd/h-encaps", + NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./msd/node_msd/end-d", + NB_OP_DESTROY, NULL); + ret = nb_cli_apply_changes(vty, NULL); + } else + VTY_PUSH_XPATH(ISIS_SRV6_NODE_MSD_NODE, xpath); + + return ret; +} + +/* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-segs-left + */ +DEFPY (isis_srv6_node_msd_max_segs_left, + isis_srv6_node_msd_max_segs_left_cmd, + "[no] max-segs-left (0-255)$max_segs_left", + NO_STR + "Specify Maximum Segments Left MSD\n" + "Specify Maximum Segments Left MSD\n") +{ + if (no) + nb_cli_enqueue_change(vty, "./max-segs-left", NB_OP_DESTROY, + NULL); + else + nb_cli_enqueue_change(vty, "./max-segs-left", NB_OP_MODIFY, + max_segs_left_str); + + return nb_cli_apply_changes(vty, NULL); +} + +/* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-end-pop + */ +DEFPY (isis_srv6_node_msd_max_end_pop, + isis_srv6_node_msd_max_end_pop_cmd, + "[no] max-end-pop (0-255)$max_end_pop", + NO_STR + "Specify Maximum End Pop MSD\n" + "Specify Maximum End Pop MSD\n") +{ + if (no) + nb_cli_enqueue_change(vty, "./max-end-pop", NB_OP_DESTROY, NULL); + else + nb_cli_enqueue_change(vty, "./max-end-pop", NB_OP_MODIFY, + max_end_pop_str); + + return nb_cli_apply_changes(vty, NULL); +} + +/* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-h-encaps + */ +DEFPY (isis_srv6_node_msd_max_h_encaps, + isis_srv6_node_msd_max_h_encaps_cmd, + "[no] max-h-encaps (0-255)$max_h_encaps", + NO_STR + "Specify Maximum H.Encaps MSD\n" + "Specify Maximum H.Encaps MSD\n") +{ + if (no) + nb_cli_enqueue_change(vty, "./max-h-encaps", NB_OP_DESTROY, + NULL); + else + nb_cli_enqueue_change(vty, "./max-h-encaps", NB_OP_MODIFY, + max_h_encaps_str); + + return nb_cli_apply_changes(vty, NULL); +} + +/* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-end-d + */ +DEFPY (isis_srv6_node_msd_max_end_d, + isis_srv6_node_msd_max_end_d_cmd, + "[no] max-end-d (0-255)$max_end_d", + NO_STR + "Specify Maximum End D MSD\n" + "Specify Maximum End D MSD\n") +{ + if (no) + nb_cli_enqueue_change(vty, "./max-end-d", NB_OP_DESTROY, NULL); + else + nb_cli_enqueue_change(vty, "./max-end-d", NB_OP_MODIFY, + max_end_d_str); + + return nb_cli_apply_changes(vty, NULL); +} + +void cli_show_isis_srv6_node_msd(struct vty *vty, const struct lyd_node *dnode, + bool show_defaults) +{ + vty_out(vty, " node-msd\n"); + if (yang_dnode_get_uint8(dnode, "./max-segs-left") != + yang_get_default_uint8("%s/msd/node-msd/max-segs-left", ISIS_SRV6)) + vty_out(vty, " max-segs-left %u\n", + yang_dnode_get_uint8(dnode, "./max-segs-left")); + if (yang_dnode_get_uint8(dnode, "./max-end-pop") != + yang_get_default_uint8("%s/msd/node-msd/max-end-pop", ISIS_SRV6)) + vty_out(vty, " max-end-pop %u\n", + yang_dnode_get_uint8(dnode, "./max-end-pop")); + if (yang_dnode_get_uint8(dnode, "./max-h-encaps") != + yang_get_default_uint8("%s/msd/node-msd/max-h-encaps", ISIS_SRV6)) + vty_out(vty, " max-h-encaps %u\n", + yang_dnode_get_uint8(dnode, "./max-h-encaps")); + if (yang_dnode_get_uint8(dnode, "./max-end-d") != + yang_get_default_uint8("%s/msd/node-msd/max-end-d", ISIS_SRV6)) + vty_out(vty, " max-end-d %u\n", + yang_dnode_get_uint8(dnode, "./max-end-d")); +} + +/* * XPath: /frr-isisd:isis/instance/fast-reroute/level-{1,2}/lfa/priority-limit */ DEFPY_YANG (isis_frr_lfa_priority_limit, @@ -3880,6 +4010,15 @@ void isis_cli_init(void) install_element(ISIS_NODE, &isis_srv6_enable_cmd); install_element(ISIS_NODE, &no_isis_srv6_enable_cmd); install_element(ISIS_SRV6_NODE, &isis_srv6_locator_cmd); + install_element(ISIS_SRV6_NODE, &isis_srv6_node_msd_cmd); + install_element(ISIS_SRV6_NODE_MSD_NODE, + &isis_srv6_node_msd_max_segs_left_cmd); + install_element(ISIS_SRV6_NODE_MSD_NODE, + &isis_srv6_node_msd_max_end_pop_cmd); + install_element(ISIS_SRV6_NODE_MSD_NODE, + &isis_srv6_node_msd_max_h_encaps_cmd); + install_element(ISIS_SRV6_NODE_MSD_NODE, + &isis_srv6_node_msd_max_end_d_cmd); install_element(INTERFACE_NODE, &isis_passive_cmd); diff --git a/isisd/isis_nb.c b/isisd/isis_nb.c index 9833a1a42..528ba4a1a 100644 --- a/isisd/isis_nb.c +++ b/isisd/isis_nb.c @@ -876,6 +876,40 @@ const struct frr_yang_module_info frr_isisd_info = { }, }, { + .xpath = "/frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-segs-left", + .cbs = { + .modify = isis_instance_segment_routing_srv6_msd_node_msd_max_segs_left_modify, + .destroy = isis_instance_segment_routing_srv6_msd_node_msd_max_segs_left_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-end-pop", + .cbs = { + .modify = isis_instance_segment_routing_srv6_msd_node_msd_max_end_pop_modify, + .destroy = isis_instance_segment_routing_srv6_msd_node_msd_max_end_pop_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-h-encaps", + .cbs = { + .modify = isis_instance_segment_routing_srv6_msd_node_msd_max_h_encaps_modify, + .destroy = isis_instance_segment_routing_srv6_msd_node_msd_max_h_encaps_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-end-d", + .cbs = { + .modify = isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_modify, + .destroy = isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_destroy, + }, + }, + { + .xpath = "/frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd", + .cbs = { + .cli_show = cli_show_isis_srv6_node_msd, + }, + }, + { .xpath = "/frr-isisd:isis/instance/mpls/ldp-sync", .cbs = { .cli_show = cli_show_isis_mpls_ldp_sync, diff --git a/isisd/isis_nb.h b/isisd/isis_nb.h index a9733910e..f200c52f0 100644 --- a/isisd/isis_nb.h +++ b/isisd/isis_nb.h @@ -332,6 +332,24 @@ int isis_instance_segment_routing_srv6_locator_destroy( struct nb_cb_destroy_args *args); void cli_show_isis_srv6_locator(struct vty *vty, const struct lyd_node *dnode, bool show_defaults); +int isis_instance_segment_routing_srv6_msd_node_msd_max_segs_left_modify( + struct nb_cb_modify_args *args); +int isis_instance_segment_routing_srv6_msd_node_msd_max_segs_left_destroy( + struct nb_cb_destroy_args *args); +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_pop_modify( + struct nb_cb_modify_args *args); +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_pop_destroy( + struct nb_cb_destroy_args *args); +int isis_instance_segment_routing_srv6_msd_node_msd_max_h_encaps_modify( + struct nb_cb_modify_args *args); +int isis_instance_segment_routing_srv6_msd_node_msd_max_h_encaps_destroy( + struct nb_cb_destroy_args *args); +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_modify( + struct nb_cb_modify_args *args); +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_destroy( + struct nb_cb_destroy_args *args); +void cli_show_isis_srv6_node_msd(struct vty *vty, const struct lyd_node *dnode, + bool show_defaults); int isis_instance_mpls_ldp_sync_destroy(struct nb_cb_destroy_args *args); int isis_instance_mpls_ldp_sync_create(struct nb_cb_create_args *args); int isis_instance_mpls_ldp_sync_holddown_modify(struct nb_cb_modify_args *args); diff --git a/isisd/isis_nb_config.c b/isisd/isis_nb_config.c index 4b754c727..08eb91448 100644 --- a/isisd/isis_nb_config.c +++ b/isisd/isis_nb_config.c @@ -3563,6 +3563,162 @@ int isis_instance_segment_routing_srv6_locator_destroy( } /* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-segs-left + */ +int isis_instance_segment_routing_srv6_msd_node_msd_max_segs_left_modify( + struct nb_cb_modify_args *args) +{ + struct isis_area *area; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(args->dnode, NULL, true); + area->srv6db.config.max_seg_left_msd = yang_dnode_get_uint8(args->dnode, + NULL); + + /* Update and regenerate LSP */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +int isis_instance_segment_routing_srv6_msd_node_msd_max_segs_left_destroy( + struct nb_cb_destroy_args *args) +{ + struct isis_area *area; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(args->dnode, NULL, true); + area->srv6db.config.max_seg_left_msd = + yang_get_default_uint8("./msd/node-msd/max-segs-left"); + + /* Update and regenerate LSP */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-end-pop + */ +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_pop_modify( + struct nb_cb_modify_args *args) +{ + struct isis_area *area; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(args->dnode, NULL, true); + area->srv6db.config.max_end_pop_msd = yang_dnode_get_uint8(args->dnode, + NULL); + + /* Update and regenerate LSP */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_pop_destroy( + struct nb_cb_destroy_args *args) +{ + struct isis_area *area; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(args->dnode, NULL, true); + area->srv6db.config.max_end_pop_msd = + yang_get_default_uint8("./msd/node-msd/max-end-pop"); + + /* Update and regenerate LSP */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-h-encaps + */ +int isis_instance_segment_routing_srv6_msd_node_msd_max_h_encaps_modify( + struct nb_cb_modify_args *args) +{ + struct isis_area *area; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(args->dnode, NULL, true); + area->srv6db.config.max_h_encaps_msd = yang_dnode_get_uint8(args->dnode, + NULL); + + /* Update and regenerate LSP */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +int isis_instance_segment_routing_srv6_msd_node_msd_max_h_encaps_destroy( + struct nb_cb_destroy_args *args) +{ + struct isis_area *area; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(args->dnode, NULL, true); + area->srv6db.config.max_h_encaps_msd = + yang_get_default_uint8("./msd/node-msd/max-h-encaps"); + + /* Update and regenerate LSP */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +/* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/msd/node-msd/max-end-d + */ +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_modify( + struct nb_cb_modify_args *args) +{ + struct isis_area *area; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(args->dnode, NULL, true); + area->srv6db.config.max_end_d_msd = yang_dnode_get_uint8(args->dnode, + NULL); + + /* Update and regenerate LSP */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +int isis_instance_segment_routing_srv6_msd_node_msd_max_end_d_destroy( + struct nb_cb_destroy_args *args) +{ + struct isis_area *area; + + if (args->event != NB_EV_APPLY) + return NB_OK; + + area = nb_running_get_entry(args->dnode, NULL, true); + area->srv6db.config.max_end_d_msd = + yang_get_default_uint8("./msd/node-msd/max-end-d"); + + /* Update and regenerate LSP */ + lsp_regenerate_schedule(area, area->is_type, 0); + + return NB_OK; +} + +/* * XPath: /frr-isisd:isis/instance/mpls/ldp-sync */ int isis_instance_mpls_ldp_sync_create(struct nb_cb_create_args *args) diff --git a/isisd/isis_srv6.c b/isisd/isis_srv6.c index 398c487fb..f6c05b3af 100644 --- a/isisd/isis_srv6.c +++ b/isisd/isis_srv6.c @@ -706,11 +706,16 @@ void isis_srv6_area_init(struct isis_area *area) /* Pull defaults from the YANG module */ srv6db->config.enabled = yang_get_default_bool("%s/enabled", ISIS_SRV6); - - srv6db->config.max_seg_left_msd = SRV6_MAX_SEG_LEFT; - srv6db->config.max_end_pop_msd = SRV6_MAX_END_POP; - srv6db->config.max_h_encaps_msd = SRV6_MAX_H_ENCAPS; - srv6db->config.max_end_d_msd = SRV6_MAX_END_D; + srv6db->config.max_seg_left_msd = + yang_get_default_uint8("%s/msd/node-msd/max-segs-left", + ISIS_SRV6); + srv6db->config.max_end_pop_msd = + yang_get_default_uint8("%s/msd/node-msd/max-end-pop", ISIS_SRV6); + srv6db->config.max_h_encaps_msd = + yang_get_default_uint8("%s/msd/node-msd/max-h-encaps", + ISIS_SRV6); + srv6db->config.max_end_d_msd = + yang_get_default_uint8("%s/msd/node-msd/max-end-d", ISIS_SRV6); /* Initialize SRv6 Locator chunks list */ srv6db->srv6_locator_chunks = list_new(); diff --git a/isisd/isis_srv6.h b/isisd/isis_srv6.h index c6eb0739e..c0f4a477d 100644 --- a/isisd/isis_srv6.h +++ b/isisd/isis_srv6.h @@ -11,15 +11,8 @@ #define _FRR_ISIS_SRV6_H #include "lib/srv6.h" - #include "isisd/isis_tlvs.h" -/* Maximum SRv6 SID Depths supported by the router */ -#define SRV6_MAX_SEG_LEFT 3 -#define SRV6_MAX_END_POP 3 -#define SRV6_MAX_H_ENCAPS 2 -#define SRV6_MAX_END_D 5 - /* Name of the interface used for installing SRv6 SIDs into the data plane */ #define SRV6_IFNAME "sr0" diff --git a/isisd/isisd.c b/isisd/isisd.c index f9c12bc7c..b1064d894 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -3839,6 +3839,13 @@ struct cmd_node isis_srv6_node = { .prompt = "%s(config-router-srv6)# ", }; +struct cmd_node isis_srv6_node_msd_node = { + .name = "isis-srv6-node-msd", + .node = ISIS_SRV6_NODE_MSD_NODE, + .parent_node = ISIS_SRV6_NODE, + .prompt = "%s(config-router-srv6-node-msd)# ", +}; + void isis_init(void) { /* Install IS-IS top node */ @@ -3954,5 +3961,8 @@ void isis_init(void) install_node(&isis_srv6_node); install_default(ISIS_SRV6_NODE); + install_node(&isis_srv6_node_msd_node); + install_default(ISIS_SRV6_NODE_MSD_NODE); + spf_backoff_cmd_init(); } |