diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index d28af98a08..b66be8f614 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -735,6 +735,34 @@ void cli_show_isis_lsp_max_lifetime(struct vty *vty, struct lyd_node *dnode, } } +/* + * XPath: /frr-isisd:isis/instance/lsp/mtu + */ +DEFPY(area_lsp_mtu, area_lsp_mtu_cmd, "lsp-mtu (128-4352)$val", + "Configure the maximum size of generated LSPs\n" + "Maximum size of generated LSPs\n") +{ + nb_cli_enqueue_change(vty, "./lsp/mtu", NB_OP_MODIFY, val_str); + + return nb_cli_apply_changes(vty, NULL); +} + +DEFPY(no_area_lsp_mtu, no_area_lsp_mtu_cmd, "no lsp-mtu [(128-4352)]", + NO_STR + "Configure the maximum size of generated LSPs\n" + "Maximum size of generated LSPs\n") +{ + nb_cli_enqueue_change(vty, "./lsp/mtu", NB_OP_MODIFY, NULL); + + return nb_cli_apply_changes(vty, NULL); +} + +void cli_show_isis_lsp_mtu(struct vty *vty, struct lyd_node *dnode, + bool show_defaults) +{ + vty_out(vty, " lsp-mtu %s\n", yang_dnode_get_string(dnode, NULL)); +} + void isis_cli_init(void) { install_element(CONFIG_NODE, &router_isis_cmd); @@ -767,6 +795,8 @@ void isis_cli_init(void) install_element(ISIS_NODE, &no_lsp_refresh_interval_cmd); install_element(ISIS_NODE, &max_lsp_lifetime_cmd); install_element(ISIS_NODE, &no_max_lsp_lifetime_cmd); + install_element(ISIS_NODE, &area_lsp_mtu_cmd); + install_element(ISIS_NODE, &no_area_lsp_mtu_cmd); } #endif /* ifndef FABRICD */ diff --git a/isisd/isis_cli.h b/isisd/isis_cli.h index a8fc7f1ce4..80ef82940a 100644 --- a/isisd/isis_cli.h +++ b/isisd/isis_cli.h @@ -49,5 +49,7 @@ void cli_show_isis_lsp_ref_interval(struct vty *vty, struct lyd_node *dnode, bool show_defaults); void cli_show_isis_lsp_max_lifetime(struct vty *vty, struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_lsp_mtu(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); #endif /* ISISD_ISIS_CLI_H_ */ diff --git a/isisd/isis_northbound.c b/isisd/isis_northbound.c index 11cc9c2302..2480a3c266 100644 --- a/isisd/isis_northbound.c +++ b/isisd/isis_northbound.c @@ -361,7 +361,39 @@ static int isis_instance_lsp_mtu_modify(enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource) { - /* TODO: implement me. */ + struct listnode *node; + struct isis_circuit *circuit; + uint16_t lsp_mtu = yang_dnode_get_uint16(dnode, NULL); + struct isis_area *area; + + switch (event) { + case NB_EV_VALIDATE: + area = yang_dnode_get_entry(dnode, false); + if (!area) + break; + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + if (circuit->state != C_STATE_INIT + && circuit->state != C_STATE_UP) + continue; + if (lsp_mtu > isis_circuit_pdu_size(circuit)) { + flog_warn( + EC_LIB_NB_CB_CONFIG_VALIDATE, + "ISIS area contains circuit %s, which has a maximum PDU size of %zu", + circuit->interface->name, + isis_circuit_pdu_size(circuit)); + return NB_ERR_VALIDATION; + } + } + break; + case NB_EV_PREPARE: + case NB_EV_ABORT: + break; + case NB_EV_APPLY: + area = yang_dnode_get_entry(dnode, true); + isis_area_lsp_mtu_set(area, lsp_mtu); + break; + } + return NB_OK; } @@ -1898,6 +1930,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/lsp/mtu", .cbs.modify = isis_instance_lsp_mtu_modify, + .cbs.cli_show = cli_show_isis_lsp_mtu, }, { .xpath = "/frr-isisd:isis/instance/lsp/refresh-interval", diff --git a/isisd/isis_vty_common.c b/isisd/isis_vty_common.c index 03432df4cd..d9a0b52f98 100644 --- a/isisd/isis_vty_common.c +++ b/isisd/isis_vty_common.c @@ -440,53 +440,6 @@ DEFUN (no_isis_bfd, return CMD_SUCCESS; } -static int isis_vty_lsp_mtu_set(struct vty *vty, unsigned int lsp_mtu) -{ - VTY_DECLVAR_CONTEXT(isis_area, area); - struct listnode *node; - struct isis_circuit *circuit; - - for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { - if (circuit->state != C_STATE_INIT - && circuit->state != C_STATE_UP) - continue; - if (lsp_mtu > isis_circuit_pdu_size(circuit)) { - vty_out(vty, - "ISIS area contains circuit %s, which has a maximum PDU size of %zu.\n", - circuit->interface->name, - isis_circuit_pdu_size(circuit)); - return CMD_WARNING_CONFIG_FAILED; - } - } - - isis_area_lsp_mtu_set(area, lsp_mtu); - return CMD_SUCCESS; -} - -DEFUN (area_lsp_mtu, - area_lsp_mtu_cmd, - "lsp-mtu (128-4352)", - "Configure the maximum size of generated LSPs\n" - "Maximum size of generated LSPs\n") -{ - int idx_number = 1; - unsigned int lsp_mtu; - - lsp_mtu = strtoul(argv[idx_number]->arg, NULL, 10); - - return isis_vty_lsp_mtu_set(vty, lsp_mtu); -} - -DEFUN (no_area_lsp_mtu, - no_area_lsp_mtu_cmd, - "no lsp-mtu [(128-4352)]", - NO_STR - "Configure the maximum size of generated LSPs\n" - "Maximum size of generated LSPs\n") -{ - return isis_vty_lsp_mtu_set(vty, DEFAULT_LSP_MTU); -} - DEFUN (area_purge_originator, area_purge_originator_cmd, "[no] purge-originator", @@ -616,9 +569,6 @@ void isis_vty_init(void) install_element(INTERFACE_NODE, &isis_bfd_cmd); install_element(INTERFACE_NODE, &no_isis_bfd_cmd); - install_element(ROUTER_NODE, &area_lsp_mtu_cmd); - install_element(ROUTER_NODE, &no_area_lsp_mtu_cmd); - install_element(ROUTER_NODE, &area_purge_originator_cmd); install_element(ROUTER_NODE, &spf_interval_cmd); diff --git a/isisd/isis_vty_fabricd.c b/isisd/isis_vty_fabricd.c index a507c0d244..a763925ffc 100644 --- a/isisd/isis_vty_fabricd.c +++ b/isisd/isis_vty_fabricd.c @@ -544,6 +544,54 @@ DEFUN (no_max_lsp_lifetime, DEFAULT_LSP_LIFETIME); } + +static int isis_vty_lsp_mtu_set(struct vty *vty, unsigned int lsp_mtu) +{ + VTY_DECLVAR_CONTEXT(isis_area, area); + struct listnode *node; + struct isis_circuit *circuit; + + for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) { + if (circuit->state != C_STATE_INIT + && circuit->state != C_STATE_UP) + continue; + if (lsp_mtu > isis_circuit_pdu_size(circuit)) { + vty_out(vty, + "ISIS area contains circuit %s, which has a maximum PDU size of %zu.\n", + circuit->interface->name, + isis_circuit_pdu_size(circuit)); + return CMD_WARNING_CONFIG_FAILED; + } + } + + isis_area_lsp_mtu_set(area, lsp_mtu); + return CMD_SUCCESS; +} + +DEFUN (area_lsp_mtu, + area_lsp_mtu_cmd, + "lsp-mtu (128-4352)", + "Configure the maximum size of generated LSPs\n" + "Maximum size of generated LSPs\n") +{ + int idx_number = 1; + unsigned int lsp_mtu; + + lsp_mtu = strtoul(argv[idx_number]->arg, NULL, 10); + + return isis_vty_lsp_mtu_set(vty, lsp_mtu); +} + +DEFUN (no_area_lsp_mtu, + no_area_lsp_mtu_cmd, + "no lsp-mtu [(128-4352)]", + NO_STR + "Configure the maximum size of generated LSPs\n" + "Maximum size of generated LSPs\n") +{ + return isis_vty_lsp_mtu_set(vty, DEFAULT_LSP_MTU); +} + void isis_vty_daemon_init(void) { install_element(ROUTER_NODE, &fabric_tier_cmd); @@ -571,4 +619,7 @@ void isis_vty_daemon_init(void) install_element(ROUTER_NODE, &max_lsp_lifetime_cmd); install_element(ROUTER_NODE, &no_max_lsp_lifetime_cmd); + + install_element(ROUTER_NODE, &area_lsp_mtu_cmd); + install_element(ROUTER_NODE, &no_area_lsp_mtu_cmd); }