diff options
Diffstat (limited to 'isisd/isis_cli.c')
| -rw-r--r-- | isisd/isis_cli.c | 620 |
1 files changed, 485 insertions, 135 deletions
diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index 7c7a8d2389..2b19cbba84 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -85,13 +85,13 @@ void cli_show_router_isis(struct vty *vty, const struct lyd_node *dnode, { const char *vrf = NULL; - vrf = yang_dnode_get_string(dnode, "./vrf"); + vrf = yang_dnode_get_string(dnode, "vrf"); vty_out(vty, "!\n"); vty_out(vty, "router isis %s", - yang_dnode_get_string(dnode, "./area-tag")); + yang_dnode_get_string(dnode, "area-tag")); if (!strmatch(vrf, VRF_DEFAULT_NAME)) - vty_out(vty, " vrf %s", yang_dnode_get_string(dnode, "./vrf")); + vty_out(vty, " vrf %s", yang_dnode_get_string(dnode, "vrf")); vty_out(vty, "\n"); } @@ -172,7 +172,7 @@ DEFPY_YANG(no_ip_router_isis, no_ip_router_isis_cmd, * If both ipv4 and ipv6 are off delete the interface isis container. */ if (strmatch(ip, "ipv6")) { - if (!yang_dnode_get_bool(dnode, "./ipv4-routing")) + if (!yang_dnode_get_bool(dnode, "ipv4-routing")) nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_DESTROY, NULL); else @@ -180,7 +180,7 @@ DEFPY_YANG(no_ip_router_isis, no_ip_router_isis_cmd, "./frr-isisd:isis/ipv6-routing", NB_OP_MODIFY, "false"); } else { - if (!yang_dnode_get_bool(dnode, "./ipv6-routing")) + if (!yang_dnode_get_bool(dnode, "ipv6-routing")) nb_cli_enqueue_change(vty, "./frr-isisd:isis", NB_OP_DESTROY, NULL); else @@ -280,16 +280,16 @@ void cli_show_ip_isis_bfd_monitoring(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - if (!yang_dnode_get_bool(dnode, "./enabled")) { + if (!yang_dnode_get_bool(dnode, "enabled")) { if (show_defaults) vty_out(vty, " no isis bfd\n"); } else { vty_out(vty, " isis bfd\n"); } - if (yang_dnode_exists(dnode, "./profile")) + if (yang_dnode_exists(dnode, "profile")) vty_out(vty, " isis bfd profile %s\n", - yang_dnode_get_string(dnode, "./profile")); + yang_dnode_get_string(dnode, "profile")); } /* @@ -300,8 +300,12 @@ DEFPY_YANG(net, net_cmd, "[no] net WORD", "A Network Entity Title for this process (OSI only)\n" "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") { - nb_cli_enqueue_change(vty, "./area-address", - no ? NB_OP_DESTROY : NB_OP_CREATE, net); + char xpath[XPATH_MAXLEN]; + + snprintf(xpath, XPATH_MAXLEN, "./area-address[.='%s']", net); + + nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE, + NULL); return nb_cli_apply_changes(vty, NULL); } @@ -588,9 +592,9 @@ void cli_show_isis_area_pwd(struct vty *vty, const struct lyd_node *dnode, const char *snp; vty_out(vty, " area-password %s %s", - yang_dnode_get_string(dnode, "./password-type"), - yang_dnode_get_string(dnode, "./password")); - snp = yang_dnode_get_string(dnode, "./authenticate-snp"); + yang_dnode_get_string(dnode, "password-type"), + yang_dnode_get_string(dnode, "password")); + snp = yang_dnode_get_string(dnode, "authenticate-snp"); if (!strmatch("none", snp)) vty_out(vty, " authenticate snp %s", snp); vty_out(vty, "\n"); @@ -638,9 +642,9 @@ void cli_show_isis_domain_pwd(struct vty *vty, const struct lyd_node *dnode, const char *snp; vty_out(vty, " domain-password %s %s", - yang_dnode_get_string(dnode, "./password-type"), - yang_dnode_get_string(dnode, "./password")); - snp = yang_dnode_get_string(dnode, "./authenticate-snp"); + yang_dnode_get_string(dnode, "password-type"), + yang_dnode_get_string(dnode, "password")); + snp = yang_dnode_get_string(dnode, "authenticate-snp"); if (!strmatch("none", snp)) vty_out(vty, " authenticate snp %s", snp); vty_out(vty, "\n"); @@ -861,17 +865,17 @@ void cli_show_isis_lsp_timers(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { const char *l1_refresh = - yang_dnode_get_string(dnode, "./level-1/refresh-interval"); + yang_dnode_get_string(dnode, "level-1/refresh-interval"); const char *l2_refresh = - yang_dnode_get_string(dnode, "./level-2/refresh-interval"); + yang_dnode_get_string(dnode, "level-2/refresh-interval"); const char *l1_lifetime = - yang_dnode_get_string(dnode, "./level-1/maximum-lifetime"); + yang_dnode_get_string(dnode, "level-1/maximum-lifetime"); const char *l2_lifetime = - yang_dnode_get_string(dnode, "./level-2/maximum-lifetime"); + yang_dnode_get_string(dnode, "level-2/maximum-lifetime"); const char *l1_gen = - yang_dnode_get_string(dnode, "./level-1/generation-interval"); + yang_dnode_get_string(dnode, "level-1/generation-interval"); const char *l2_gen = - yang_dnode_get_string(dnode, "./level-2/generation-interval"); + yang_dnode_get_string(dnode, "level-2/generation-interval"); if (strmatch(l1_refresh, l2_refresh) && strmatch(l1_lifetime, l2_lifetime) && strmatch(l1_gen, l2_gen)) vty_out(vty, @@ -980,8 +984,8 @@ void cli_show_isis_spf_min_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - const char *l1 = yang_dnode_get_string(dnode, "./level-1"); - const char *l2 = yang_dnode_get_string(dnode, "./level-2"); + const char *l1 = yang_dnode_get_string(dnode, "level-1"); + const char *l2 = yang_dnode_get_string(dnode, "level-2"); if (strmatch(l1, l2)) vty_out(vty, " spf-interval %s\n", l1); @@ -1051,11 +1055,11 @@ void cli_show_isis_spf_ietf_backoff(struct vty *vty, { vty_out(vty, " spf-delay-ietf init-delay %s short-delay %s long-delay %s holddown %s time-to-learn %s\n", - yang_dnode_get_string(dnode, "./init-delay"), - yang_dnode_get_string(dnode, "./short-delay"), - yang_dnode_get_string(dnode, "./long-delay"), - yang_dnode_get_string(dnode, "./hold-down"), - yang_dnode_get_string(dnode, "./time-to-learn")); + yang_dnode_get_string(dnode, "init-delay"), + yang_dnode_get_string(dnode, "short-delay"), + yang_dnode_get_string(dnode, "long-delay"), + yang_dnode_get_string(dnode, "hold-down"), + yang_dnode_get_string(dnode, "time-to-learn")); } /* @@ -1364,15 +1368,15 @@ static void vty_print_def_origin(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " default-information originate %s %s", family, level); - if (yang_dnode_get_bool(dnode, "./always")) + if (yang_dnode_get_bool(dnode, "always")) vty_out(vty, " always"); - if (yang_dnode_exists(dnode, "./route-map")) + if (yang_dnode_exists(dnode, "route-map")) vty_out(vty, " route-map %s", - yang_dnode_get_string(dnode, "./route-map")); - if (show_defaults || !yang_dnode_is_default(dnode, "./metric")) + yang_dnode_get_string(dnode, "route-map")); + if (show_defaults || !yang_dnode_is_default(dnode, "metric")) vty_out(vty, " metric %s", - yang_dnode_get_string(dnode, "./metric")); + yang_dnode_get_string(dnode, "metric")); vty_out(vty, "\n"); } @@ -1381,7 +1385,7 @@ void cli_show_isis_def_origin_ipv4(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - const char *level = yang_dnode_get_string(dnode, "./level"); + const char *level = yang_dnode_get_string(dnode, "level"); vty_print_def_origin(vty, dnode, "ipv4", level, show_defaults); } @@ -1390,7 +1394,7 @@ void cli_show_isis_def_origin_ipv6(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - const char *level = yang_dnode_get_string(dnode, "./level"); + const char *level = yang_dnode_get_string(dnode, "level"); vty_print_def_origin(vty, dnode, "ipv6", level, show_defaults); } @@ -1430,20 +1434,99 @@ DEFPY_YANG(isis_redistribute, isis_redistribute_cmd, level); } -static void vty_print_redistribute(struct vty *vty, - const struct lyd_node *dnode, - bool show_defaults, const char *family) -{ - const char *level = yang_dnode_get_string(dnode, "./level"); - const char *protocol = yang_dnode_get_string(dnode, "./protocol"); +/* + * XPath: /frr-isisd:isis/instance/redistribute/table + */ +DEFPY_YANG(isis_redistribute_table, isis_redistribute_table_cmd, + "[no] redistribute <ipv4|ipv6>$ip table (1-65535)$table" + "<level-1|level-2>$level [{metric (0-16777215)|route-map WORD}]", + NO_STR REDIST_STR "Redistribute IPv4 routes\n" + "Redistribute IPv6 routes\n" + "Non-main Kernel Routing Table\n" + "Table Id\n" + "Redistribute into level-1\n" + "Redistribute into level-2\n" + "Metric for redistributed routes\n" + "IS-IS default metric\n" + "Route map reference\n" + "Pointer to route-map entries\n") +{ + struct isis_redist_table_present_args rtda = {}; + char xpath[XPATH_MAXLEN]; + char xpath_entry[XPATH_MAXLEN + 128]; + int rv; - vty_out(vty, " redistribute %s %s %s", family, protocol, level); - if (show_defaults || !yang_dnode_is_default(dnode, "./metric")) + rtda.rtda_table = table_str; + rtda.rtda_ip = ip; + rtda.rtda_level = level; + + if (no) { + if (!isis_redist_table_is_present(vty, &rtda)) + return CMD_WARNING_CONFIG_FAILED; + + snprintf(xpath, sizeof(xpath), "./table[table='%s']", table_str); + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + rv = nb_cli_apply_changes(vty, + "./redistribute/%s[protocol='table'][level='%s']", + ip, level); + if (rv == CMD_SUCCESS) { + if (isis_redist_table_get_first(vty, &rtda) > 0) + return CMD_SUCCESS; + nb_cli_enqueue_change(vty, "./table", NB_OP_DESTROY, + NULL); + nb_cli_apply_changes(vty, + "./redistribute/%s[protocol='table'][level='%s']", + ip, level); + } + return CMD_SUCCESS; + } + if (isis_redist_table_is_present(vty, &rtda)) + return CMD_SUCCESS; + + snprintf(xpath, sizeof(xpath), "./table[table='%s']", table_str); + nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); + snprintf(xpath_entry, sizeof(xpath_entry), "%s/route-map", xpath); + nb_cli_enqueue_change(vty, xpath_entry, + route_map ? NB_OP_MODIFY : NB_OP_DESTROY, + route_map ? route_map : NULL); + snprintf(xpath_entry, sizeof(xpath_entry), "%s/metric", xpath); + nb_cli_enqueue_change(vty, xpath_entry, NB_OP_MODIFY, + metric_str ? metric_str : NULL); + return nb_cli_apply_changes(vty, + "./redistribute/%s[protocol='table'][level='%s']", + ip, level); +} + +static void vty_print_redistribute(struct vty *vty, const struct lyd_node *dnode, + bool show_defaults, const char *family, + bool table) +{ + const char *level; + const char *protocol = NULL; + const char *routemap = NULL; + uint16_t tableid; + + if (table) { + level = yang_dnode_get_string(dnode, "../level"); + tableid = yang_dnode_get_uint16(dnode, "table"); + vty_out(vty, " redistribute %s table %d ", family, tableid); + } else { + protocol = yang_dnode_get_string(dnode, "protocol"); + if (!table && strmatch(protocol, "table")) + return; + level = yang_dnode_get_string(dnode, "level"); + vty_out(vty, " redistribute %s %s ", family, protocol); + } + vty_out(vty, "%s", level); + if (show_defaults || !yang_dnode_is_default(dnode, "metric")) vty_out(vty, " metric %s", - yang_dnode_get_string(dnode, "./metric")); - if (yang_dnode_exists(dnode, "./route-map")) - vty_out(vty, " route-map %s", - yang_dnode_get_string(dnode, "./route-map")); + yang_dnode_get_string(dnode, "%s", "metric")); + + if (yang_dnode_exists(dnode, "route-map")) + routemap = yang_dnode_get_string(dnode, "route-map"); + if (routemap) + vty_out(vty, " route-map %s", routemap); vty_out(vty, "\n"); } @@ -1451,13 +1534,37 @@ void cli_show_isis_redistribute_ipv4(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_print_redistribute(vty, dnode, show_defaults, "ipv4"); + vty_print_redistribute(vty, dnode, show_defaults, "ipv4", false); } + void cli_show_isis_redistribute_ipv6(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - vty_print_redistribute(vty, dnode, show_defaults, "ipv6"); + vty_print_redistribute(vty, dnode, show_defaults, "ipv6", false); +} + +void cli_show_isis_redistribute_ipv4_table(struct vty *vty, + const struct lyd_node *dnode, + bool show_defaults) +{ + vty_print_redistribute(vty, dnode, show_defaults, "ipv4", true); +} + +void cli_show_isis_redistribute_ipv6_table(struct vty *vty, + const struct lyd_node *dnode, + bool show_defaults) +{ + vty_print_redistribute(vty, dnode, show_defaults, "ipv6", true); +} + +int cli_cmp_isis_redistribute_table(const struct lyd_node *dnode1, + const struct lyd_node *dnode2) +{ + uint16_t table1 = yang_dnode_get_uint16(dnode1, "table"); + uint16_t table2 = yang_dnode_get_uint16(dnode2, "table"); + + return table1 - table2; } /* @@ -1516,7 +1623,7 @@ void cli_show_isis_mt_ipv4_multicast(struct vty *vty, bool show_defaults) { vty_out(vty, " topology ipv4-multicast"); - if (yang_dnode_get_bool(dnode, "./overload")) + if (yang_dnode_get_bool(dnode, "overload")) vty_out(vty, " overload"); vty_out(vty, "\n"); } @@ -1525,7 +1632,7 @@ void cli_show_isis_mt_ipv4_mgmt(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " topology ipv4-mgmt"); - if (yang_dnode_get_bool(dnode, "./overload")) + if (yang_dnode_get_bool(dnode, "overload")) vty_out(vty, " overload"); vty_out(vty, "\n"); } @@ -1535,7 +1642,7 @@ void cli_show_isis_mt_ipv6_unicast(struct vty *vty, bool show_defaults) { vty_out(vty, " topology ipv6-unicast"); - if (yang_dnode_get_bool(dnode, "./overload")) + if (yang_dnode_get_bool(dnode, "overload")) vty_out(vty, " overload"); vty_out(vty, "\n"); } @@ -1545,7 +1652,7 @@ void cli_show_isis_mt_ipv6_multicast(struct vty *vty, bool show_defaults) { vty_out(vty, " topology ipv6-multicast"); - if (yang_dnode_get_bool(dnode, "./overload")) + if (yang_dnode_get_bool(dnode, "overload")) vty_out(vty, " overload"); vty_out(vty, "\n"); } @@ -1554,7 +1661,7 @@ void cli_show_isis_mt_ipv6_mgmt(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " topology ipv6-mgmt"); - if (yang_dnode_get_bool(dnode, "./overload")) + if (yang_dnode_get_bool(dnode, "overload")) vty_out(vty, " overload"); vty_out(vty, "\n"); } @@ -1563,7 +1670,7 @@ void cli_show_isis_mt_ipv6_dstsrc(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " topology ipv6-dstsrc"); - if (yang_dnode_get_bool(dnode, "./overload")) + if (yang_dnode_get_bool(dnode, "overload")) vty_out(vty, " overload"); vty_out(vty, "\n"); } @@ -1668,13 +1775,13 @@ void cli_show_isis_label_blocks(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " segment-routing global-block %s %s", - yang_dnode_get_string(dnode, "./srgb/lower-bound"), - yang_dnode_get_string(dnode, "./srgb/upper-bound")); - if (!yang_dnode_is_default(dnode, "./srlb/lower-bound") - || !yang_dnode_is_default(dnode, "./srlb/upper-bound")) + yang_dnode_get_string(dnode, "srgb/lower-bound"), + yang_dnode_get_string(dnode, "srgb/upper-bound")); + if (!yang_dnode_is_default(dnode, "srlb/lower-bound") + || !yang_dnode_is_default(dnode, "srlb/upper-bound")) vty_out(vty, " local-block %s %s", - yang_dnode_get_string(dnode, "./srlb/lower-bound"), - yang_dnode_get_string(dnode, "./srlb/upper-bound")); + yang_dnode_get_string(dnode, "srlb/lower-bound"), + yang_dnode_get_string(dnode, "srlb/upper-bound")); vty_out(vty, "\n"); } @@ -1796,11 +1903,11 @@ void cli_show_isis_prefix_sid(struct vty *vty, const struct lyd_node *dnode, const char *sid_value; bool n_flag_clear; - prefix = yang_dnode_get_string(dnode, "./prefix"); - lh_behavior = yang_dnode_get_string(dnode, "./last-hop-behavior"); - sid_value_type = yang_dnode_get_string(dnode, "./sid-value-type"); - sid_value = yang_dnode_get_string(dnode, "./sid-value"); - n_flag_clear = yang_dnode_get_bool(dnode, "./n-flag-clear"); + prefix = yang_dnode_get_string(dnode, "prefix"); + lh_behavior = yang_dnode_get_string(dnode, "last-hop-behavior"); + sid_value_type = yang_dnode_get_string(dnode, "sid-value-type"); + sid_value = yang_dnode_get_string(dnode, "sid-value"); + n_flag_clear = yang_dnode_get_bool(dnode, "n-flag-clear"); vty_out(vty, " segment-routing prefix %s", prefix); if (strmatch(sid_value_type, "absolute")) @@ -1910,12 +2017,12 @@ void cli_show_isis_prefix_sid_algorithm(struct vty *vty, bool n_flag_clear; uint32_t algorithm; - prefix = yang_dnode_get_string(dnode, "./prefix"); - sid_value_type = yang_dnode_get_string(dnode, "./sid-value-type"); - sid_value = yang_dnode_get_string(dnode, "./sid-value"); - algorithm = yang_dnode_get_uint32(dnode, "./algo"); - lh_behavior = yang_dnode_get_string(dnode, "./last-hop-behavior"); - n_flag_clear = yang_dnode_get_bool(dnode, "./n-flag-clear"); + prefix = yang_dnode_get_string(dnode, "prefix"); + sid_value_type = yang_dnode_get_string(dnode, "sid-value-type"); + sid_value = yang_dnode_get_string(dnode, "sid-value"); + algorithm = yang_dnode_get_uint32(dnode, "algo"); + lh_behavior = yang_dnode_get_string(dnode, "last-hop-behavior"); + n_flag_clear = yang_dnode_get_bool(dnode, "n-flag-clear"); vty_out(vty, " segment-routing prefix %s", prefix); vty_out(vty, " algorithm %u", algorithm); @@ -1935,6 +2042,234 @@ void cli_show_isis_prefix_sid_algorithm(struct vty *vty, } /* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/locator + */ +DEFPY (isis_srv6_locator, + isis_srv6_locator_cmd, + "[no] locator NAME$loc_name", + NO_STR + "Specify SRv6 locator\n" + "Specify SRv6 locator\n") +{ + if (no) + nb_cli_enqueue_change(vty, "./locator", NB_OP_DESTROY, loc_name); + else + nb_cli_enqueue_change(vty, "./locator", NB_OP_MODIFY, loc_name); + + return nb_cli_apply_changes(vty, NULL); +} + +void cli_show_isis_srv6_locator(struct vty *vty, const struct lyd_node *dnode, + bool show_defaults) +{ + vty_out(vty, " locator %s\n", yang_dnode_get_string(dnode, NULL)); +} + +/* + * XPath: /frr-isisd:isis/instance/segment-routing-srv6/enabled + */ +DEFPY_YANG_NOSH (isis_srv6_enable, + isis_srv6_enable_cmd, + "segment-routing srv6", + SR_STR + "Enable Segment Routing over IPv6 (SRv6)\n") +{ + int ret; + char xpath[XPATH_MAXLEN + 37]; + + snprintf(xpath, sizeof(xpath), "%s/segment-routing-srv6", + VTY_CURR_XPATH); + + nb_cli_enqueue_change(vty, "./segment-routing-srv6/enabled", + NB_OP_MODIFY, "true"); + + ret = nb_cli_apply_changes(vty, NULL); + if (ret == CMD_SUCCESS) + VTY_PUSH_XPATH(ISIS_SRV6_NODE, xpath); + + return ret; +} + +DEFPY_YANG (no_isis_srv6_enable, + no_isis_srv6_enable_cmd, + "no segment-routing srv6", + NO_STR + SR_STR + "Disable Segment Routing over IPv6 (SRv6)\n") +{ + nb_cli_enqueue_change(vty, "./segment-routing-srv6", NB_OP_DESTROY, + NULL); + + return nb_cli_apply_changes(vty, NULL); +} + +void cli_show_isis_srv6_enabled(struct vty *vty, const struct lyd_node *dnode, + bool show_defaults) +{ + if (!yang_dnode_get_bool(dnode, NULL)) + vty_out(vty, " no"); + + vty_out(vty, " segment-routing srv6\n"); +} + +/* + * 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/segment-routing-srv6/interface + */ +DEFPY (isis_srv6_interface, + isis_srv6_interface_cmd, + "[no] interface WORD$interface", + NO_STR + "Interface for Segment Routing over IPv6 (SRv6)\n" + "Interface for Segment Routing over IPv6 (SRv6)\n") +{ + if (no) { + nb_cli_enqueue_change(vty, "./interface", + NB_OP_MODIFY, NULL); + } else { + nb_cli_enqueue_change(vty, "./interface", + NB_OP_MODIFY, interface); + } + + return nb_cli_apply_changes(vty, NULL); +} + +void cli_show_isis_srv6_interface(struct vty *vty, const struct lyd_node *dnode, + bool show_defaults) +{ + vty_out(vty, " interface %s\n", yang_dnode_get_string(dnode, NULL)); +} + +/* * XPath: /frr-isisd:isis/instance/fast-reroute/level-{1,2}/lfa/priority-limit */ DEFPY_YANG (isis_frr_lfa_priority_limit, @@ -2050,8 +2385,8 @@ void cli_show_isis_frr_lfa_tiebreaker(struct vty *vty, bool show_defaults) { vty_out(vty, " fast-reroute lfa tiebreaker %s index %s %s\n", - yang_dnode_get_string(dnode, "./type"), - yang_dnode_get_string(dnode, "./index"), + yang_dnode_get_string(dnode, "type"), + yang_dnode_get_string(dnode, "index"), dnode->parent->parent->schema->name); } @@ -2223,8 +2558,8 @@ void cli_show_ip_isis_password(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { vty_out(vty, " isis password %s %s\n", - yang_dnode_get_string(dnode, "./password-type"), - yang_dnode_get_string(dnode, "./password")); + yang_dnode_get_string(dnode, "password-type"), + yang_dnode_get_string(dnode, "password")); } /* @@ -2270,8 +2605,8 @@ DEFPY_YANG(no_isis_metric, no_isis_metric_cmd, void cli_show_ip_isis_metric(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - const char *l1 = yang_dnode_get_string(dnode, "./level-1"); - const char *l2 = yang_dnode_get_string(dnode, "./level-2"); + const char *l1 = yang_dnode_get_string(dnode, "level-1"); + const char *l2 = yang_dnode_get_string(dnode, "level-2"); if (strmatch(l1, l2)) vty_out(vty, " isis metric %s\n", l1); @@ -2329,8 +2664,8 @@ void cli_show_ip_isis_hello_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - const char *l1 = yang_dnode_get_string(dnode, "./level-1"); - const char *l2 = yang_dnode_get_string(dnode, "./level-2"); + const char *l1 = yang_dnode_get_string(dnode, "level-1"); + const char *l2 = yang_dnode_get_string(dnode, "level-2"); if (strmatch(l1, l2)) vty_out(vty, " isis hello-interval %s\n", l1); @@ -2387,8 +2722,8 @@ DEFPY_YANG(no_isis_hello_multiplier, no_isis_hello_multiplier_cmd, void cli_show_ip_isis_hello_multi(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - const char *l1 = yang_dnode_get_string(dnode, "./level-1"); - const char *l2 = yang_dnode_get_string(dnode, "./level-2"); + const char *l1 = yang_dnode_get_string(dnode, "level-1"); + const char *l2 = yang_dnode_get_string(dnode, "level-2"); if (strmatch(l1, l2)) vty_out(vty, " isis hello-multiplier %s\n", l1); @@ -2506,8 +2841,8 @@ void cli_show_ip_isis_csnp_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - const char *l1 = yang_dnode_get_string(dnode, "./level-1"); - const char *l2 = yang_dnode_get_string(dnode, "./level-2"); + const char *l1 = yang_dnode_get_string(dnode, "level-1"); + const char *l2 = yang_dnode_get_string(dnode, "level-2"); if (strmatch(l1, l2)) vty_out(vty, " isis csnp-interval %s\n", l1); @@ -2565,8 +2900,8 @@ void cli_show_ip_isis_psnp_interval(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - const char *l1 = yang_dnode_get_string(dnode, "./level-1"); - const char *l2 = yang_dnode_get_string(dnode, "./level-2"); + const char *l1 = yang_dnode_get_string(dnode, "level-1"); + const char *l2 = yang_dnode_get_string(dnode, "level-2"); if (strmatch(l1, l2)) vty_out(vty, " isis psnp-interval %s\n", l1); @@ -2723,12 +3058,16 @@ void cli_show_ip_isis_circ_type(struct vty *vty, const struct lyd_node *dnode, } static int ag_change(struct vty *vty, int argc, struct cmd_token **argv, - const char *xpath, bool no, int start_idx) + const char *xpath_base, bool no, int start_idx) { - for (int i = start_idx; i < argc; i++) + char xpath[XPATH_MAXLEN]; + + for (int i = start_idx; i < argc; i++) { + snprintf(xpath, XPATH_MAXLEN, "%s[.='%s']", xpath_base, + argv[i]->arg); nb_cli_enqueue_change(vty, xpath, - no ? NB_OP_DESTROY : NB_OP_CREATE, - argv[i]->arg); + no ? NB_OP_DESTROY : NB_OP_CREATE, NULL); + } return nb_cli_apply_changes(vty, NULL); } @@ -2809,8 +3148,8 @@ DEFPY_YANG(no_isis_priority, no_isis_priority_cmd, void cli_show_ip_isis_priority(struct vty *vty, const struct lyd_node *dnode, bool show_defaults) { - const char *l1 = yang_dnode_get_string(dnode, "./level-1"); - const char *l2 = yang_dnode_get_string(dnode, "./level-2"); + const char *l1 = yang_dnode_get_string(dnode, "level-1"); + const char *l2 = yang_dnode_get_string(dnode, "level-2"); if (strmatch(l1, l2)) vty_out(vty, " isis priority %s\n", l1); @@ -2831,8 +3170,8 @@ void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, bool l1_link_fallback, l2_link_fallback; /* Classic LFA */ - l1_enabled = yang_dnode_get_bool(dnode, "./level-1/lfa/enable"); - l2_enabled = yang_dnode_get_bool(dnode, "./level-2/lfa/enable"); + l1_enabled = yang_dnode_get_bool(dnode, "level-1/lfa/enable"); + l2_enabled = yang_dnode_get_bool(dnode, "level-2/lfa/enable"); if (l1_enabled || l2_enabled) { if (l1_enabled == l2_enabled) { @@ -2849,8 +3188,8 @@ void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, } /* Remote LFA */ - l1_enabled = yang_dnode_get_bool(dnode, "./level-1/remote-lfa/enable"); - l2_enabled = yang_dnode_get_bool(dnode, "./level-2/remote-lfa/enable"); + l1_enabled = yang_dnode_get_bool(dnode, "level-1/remote-lfa/enable"); + l2_enabled = yang_dnode_get_bool(dnode, "level-2/remote-lfa/enable"); if (l1_enabled || l2_enabled) { if (l1_enabled == l2_enabled) { @@ -2868,16 +3207,16 @@ void cli_show_ip_isis_frr(struct vty *vty, const struct lyd_node *dnode, } /* TI-LFA */ - l1_enabled = yang_dnode_get_bool(dnode, "./level-1/ti-lfa/enable"); - l2_enabled = yang_dnode_get_bool(dnode, "./level-2/ti-lfa/enable"); + l1_enabled = yang_dnode_get_bool(dnode, "level-1/ti-lfa/enable"); + l2_enabled = yang_dnode_get_bool(dnode, "level-2/ti-lfa/enable"); l1_node_protection = - yang_dnode_get_bool(dnode, "./level-1/ti-lfa/node-protection"); + yang_dnode_get_bool(dnode, "level-1/ti-lfa/node-protection"); l2_node_protection = - yang_dnode_get_bool(dnode, "./level-2/ti-lfa/node-protection"); + yang_dnode_get_bool(dnode, "level-2/ti-lfa/node-protection"); l1_link_fallback = - yang_dnode_get_bool(dnode, "./level-1/ti-lfa/link-fallback"); + yang_dnode_get_bool(dnode, "level-1/ti-lfa/link-fallback"); l2_link_fallback = - yang_dnode_get_bool(dnode, "./level-2/ti-lfa/link-fallback"); + yang_dnode_get_bool(dnode, "level-2/ti-lfa/link-fallback"); if (l1_enabled || l2_enabled) { @@ -2971,31 +3310,27 @@ DEFPY(isis_lfa_exclude_interface, isis_lfa_exclude_interface_cmd, "Exclude an interface from computation\n" "Interface name\n") { + char xpath[XPATH_MAXLEN]; + if (!level || strmatch(level, "level-1")) { - if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/lfa/exclude-interface", - NB_OP_DESTROY, ifname); - } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-1/lfa/exclude-interface", - NB_OP_CREATE, ifname); - } + snprintf(xpath, sizeof(xpath), + "./frr-isisd:isis/fast-reroute/level-1/lfa/exclude-interface[.='%s']", + ifname); + + if (no) + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + else + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); } if (!level || strmatch(level, "level-2")) { - if (no) { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/lfa/exclude-interface", - NB_OP_DESTROY, ifname); - } else { - nb_cli_enqueue_change( - vty, - "./frr-isisd:isis/fast-reroute/level-2/lfa/exclude-interface", - NB_OP_CREATE, ifname); - } + snprintf(xpath, sizeof(xpath), + "./frr-isisd:isis/fast-reroute/level-2/lfa/exclude-interface[.='%s']", + ifname); + + if (no) + nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL); + else + nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); } return nb_cli_apply_changes(vty, NULL); @@ -3543,24 +3878,24 @@ void cli_show_isis_flex_algo(struct vty *vty, const struct lyd_node *dnode, uint32_t priority; char type_str[10]; - algorithm = yang_dnode_get_uint32(dnode, "./flex-algo"); + algorithm = yang_dnode_get_uint32(dnode, "flex-algo"); vty_out(vty, " flex-algo %u\n", algorithm); - if (yang_dnode_exists(dnode, "./advertise-definition")) + if (yang_dnode_exists(dnode, "advertise-definition")) vty_out(vty, " advertise-definition\n"); - if (yang_dnode_exists(dnode, "./dplane-sr-mpls")) + if (yang_dnode_exists(dnode, "dplane-sr-mpls")) vty_out(vty, " dataplane sr-mpls\n"); - if (yang_dnode_exists(dnode, "./dplane-srv6")) + if (yang_dnode_exists(dnode, "dplane-srv6")) vty_out(vty, " dataplane srv6\n"); - if (yang_dnode_exists(dnode, "./dplane-ip")) + if (yang_dnode_exists(dnode, "dplane-ip")) vty_out(vty, " dataplane ip\n"); - if (yang_dnode_exists(dnode, "./prefix-metric")) + if (yang_dnode_exists(dnode, "prefix-metric")) vty_out(vty, " prefix-metric\n"); - if (yang_dnode_exists(dnode, "./metric-type")) { - metric_type = yang_dnode_get_enum(dnode, "./metric-type"); + if (yang_dnode_exists(dnode, "metric-type")) { + metric_type = yang_dnode_get_enum(dnode, "metric-type"); if (metric_type != MT_IGP) { flex_algo_metric_type_print(type_str, sizeof(type_str), metric_type); @@ -3568,8 +3903,8 @@ void cli_show_isis_flex_algo(struct vty *vty, const struct lyd_node *dnode, } } - if (yang_dnode_exists(dnode, "./priority")) { - priority = yang_dnode_get_uint32(dnode, "./priority"); + if (yang_dnode_exists(dnode, "priority")) { + priority = yang_dnode_get_uint32(dnode, "priority"); if (priority != FLEX_ALGO_PRIO_DEFAULT) vty_out(vty, " priority %u\n", priority); } @@ -3681,6 +4016,7 @@ void isis_cli_init(void) install_element(ISIS_NODE, &isis_default_originate_cmd); install_element(ISIS_NODE, &isis_redistribute_cmd); + install_element(ISIS_NODE, &isis_redistribute_table_cmd); install_element(ISIS_NODE, &isis_topology_cmd); @@ -3702,6 +4038,20 @@ void isis_cli_init(void) install_element(ISIS_NODE, &isis_frr_remote_lfa_plist_cmd); install_element(ISIS_NODE, &no_isis_frr_remote_lfa_plist_cmd); + 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, &isis_srv6_interface_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); install_element(INTERFACE_NODE, &isis_passwd_cmd); |
