vty_out(vty, " set-attached-bit\n");
}
+/*
+ * XPath: /frr-isisd:isis/instance/metric-style
+ */
+DEFPY(metric_style, metric_style_cmd,
+ "metric-style <narrow|transition|wide>$style",
+ "Use old-style (ISO 10589) or new-style packet formats\n"
+ "Use old style of TLVs with narrow metric\n"
+ "Send and accept both styles of TLVs during transition\n"
+ "Use new style of TLVs to carry wider metric\n")
+{
+ nb_cli_enqueue_change(vty, "./metric-style", NB_OP_MODIFY, style);
+
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFPY(no_metric_style, no_metric_style_cmd,
+ "no metric-style [narrow|transition|wide]",
+ NO_STR
+ "Use old-style (ISO 10589) or new-style packet formats\n"
+ "Use old style of TLVs with narrow metric\n"
+ "Send and accept both styles of TLVs during transition\n"
+ "Use new style of TLVs to carry wider metric\n")
+{
+ nb_cli_enqueue_change(vty, "./metric-style", NB_OP_MODIFY, "narrow");
+
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+void cli_show_isis_metric_style(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults)
+{
+ int metric = yang_dnode_get_enum(dnode, NULL);
+
+ switch (metric) {
+ case ISIS_NARROW_METRIC:
+ vty_out(vty, " metric-style narrow\n");
+ break;
+ case ISIS_WIDE_METRIC:
+ vty_out(vty, " metric-style wide\n");
+ break;
+ case ISIS_TRANSITION_METRIC:
+ vty_out(vty, " metric-style transition\n");
+ break;
+ }
+}
+
void isis_cli_init(void)
{
install_element(CONFIG_NODE, &router_isis_cmd);
install_element(ISIS_NODE, &set_overload_bit_cmd);
install_element(ISIS_NODE, &set_attached_bit_cmd);
+
+ install_element(ISIS_NODE, &metric_style_cmd);
+ install_element(ISIS_NODE, &no_metric_style_cmd);
}
#endif /* ifndef FABRICD */
bool show_defaults);
void cli_show_isis_overload(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
+void cli_show_isis_metric_style(struct vty *vty, struct lyd_node *dnode,
+ bool show_defaults);
#endif /* ISISD_ISIS_CLI_H_ */
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
+ struct isis_area *area;
+ bool old_metric, new_metric;
+ enum isis_metric_style metric_style = yang_dnode_get_enum(dnode, NULL);
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ area = yang_dnode_get_entry(dnode, true);
+ old_metric = (metric_style == ISIS_WIDE_METRIC) ? false : true;
+ new_metric = (metric_style == ISIS_NARROW_METRIC) ? false : true;
+ isis_area_metricstyle_set(area, old_metric, new_metric);
+
return NB_OK;
}
{
.xpath = "/frr-isisd:isis/instance/metric-style",
.cbs.modify = isis_instance_metric_style_modify,
+ .cbs.cli_show = cli_show_isis_metric_style,
},
{
.xpath = "/frr-isisd:isis/instance/purge-originator",
return CMD_SUCCESS;
}
-static int validate_metric_style_narrow(struct vty *vty, struct isis_area *area)
-{
- struct isis_circuit *circuit;
- struct listnode *node;
-
- if (!vty)
- return CMD_WARNING_CONFIG_FAILED;
-
- if (!area) {
- vty_out(vty, "ISIS area is invalid\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- for (ALL_LIST_ELEMENTS_RO(area->circuit_list, node, circuit)) {
- if ((area->is_type & IS_LEVEL_1)
- && (circuit->is_type & IS_LEVEL_1)
- && (circuit->te_metric[0] > MAX_NARROW_LINK_METRIC)) {
- vty_out(vty, "ISIS circuit %s metric is invalid\n",
- circuit->interface->name);
- return CMD_WARNING_CONFIG_FAILED;
- }
- if ((area->is_type & IS_LEVEL_2)
- && (circuit->is_type & IS_LEVEL_2)
- && (circuit->te_metric[1] > MAX_NARROW_LINK_METRIC)) {
- vty_out(vty, "ISIS circuit %s metric is invalid\n",
- circuit->interface->name);
- return CMD_WARNING_CONFIG_FAILED;
- }
- }
-
- return CMD_SUCCESS;
-}
-
-DEFUN (metric_style,
- metric_style_cmd,
- "metric-style <narrow|transition|wide>",
- "Use old-style (ISO 10589) or new-style packet formats\n"
- "Use old style of TLVs with narrow metric\n"
- "Send and accept both styles of TLVs during transition\n"
- "Use new style of TLVs to carry wider metric\n")
-{
- int idx_metric_style = 1;
- VTY_DECLVAR_CONTEXT(isis_area, area);
- int ret;
-
- if (strncmp(argv[idx_metric_style]->arg, "w", 1) == 0) {
- isis_area_metricstyle_set(area, false, true);
- return CMD_SUCCESS;
- }
-
- if (area_is_mt(area)) {
- vty_out(vty,
- "Narrow metrics cannot be used while multi topology IS-IS is active\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- ret = validate_metric_style_narrow(vty, area);
- if (ret != CMD_SUCCESS)
- return ret;
-
- if (strncmp(argv[idx_metric_style]->arg, "t", 1) == 0)
- isis_area_metricstyle_set(area, true, true);
- else if (strncmp(argv[idx_metric_style]->arg, "n", 1) == 0)
- isis_area_metricstyle_set(area, true, false);
- return CMD_SUCCESS;
-
- return CMD_SUCCESS;
-}
-
-DEFUN (no_metric_style,
- no_metric_style_cmd,
- "no metric-style",
- NO_STR
- "Use old-style (ISO 10589) or new-style packet formats\n")
-{
- VTY_DECLVAR_CONTEXT(isis_area, area);
- int ret;
-
- if (area_is_mt(area)) {
- vty_out(vty,
- "Narrow metrics cannot be used while multi topology IS-IS is active\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- ret = validate_metric_style_narrow(vty, area);
- if (ret != CMD_SUCCESS)
- return ret;
-
- isis_area_metricstyle_set(area, true, false);
- return CMD_SUCCESS;
-}
-
DEFUN (lsp_gen_interval_level,
lsp_gen_interval_level_cmd,
"lsp-gen-interval <level-1|level-2> (1-120)",
install_element(INTERFACE_NODE, &psnp_interval_level_cmd);
install_element(INTERFACE_NODE, &no_psnp_interval_level_cmd);
- install_element(ROUTER_NODE, &metric_style_cmd);
- install_element(ROUTER_NODE, &no_metric_style_cmd);
-
install_element(ROUTER_NODE, &lsp_gen_interval_level_cmd);
install_element(ROUTER_NODE, &no_lsp_gen_interval_level_cmd);
void isis_area_metricstyle_set(struct isis_area *area, bool old_metric,
bool new_metric)
{
- if (area->oldmetric != old_metric || area->newmetric != new_metric) {
- area->oldmetric = old_metric;
- area->newmetric = new_metric;
- lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
- }
+ area->oldmetric = old_metric;
+ area->newmetric = new_metric;
+ lsp_regenerate_schedule(area, IS_LEVEL_1 | IS_LEVEL_2, 1);
}
void isis_area_overload_bit_set(struct isis_area *area, bool overload_bit)
int level;
};
+/* for yang configuration */
+enum isis_metric_style {
+ ISIS_NARROW_METRIC = 0,
+ ISIS_WIDE_METRIC,
+ ISIS_TRANSITION_METRIC,
+};
+
struct isis_area {
struct isis *isis; /* back pointer */
dict_t *lspdb[ISIS_LEVELS]; /* link-state dbs */