]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripd/rip_cli.c
Merge pull request #13601 from opensourcerouting/build-yang-embed-20230525
[mirror_frr.git] / ripd / rip_cli.c
index ac9fc4b1a818ba651e60f633bdbc5dee2bd0ddb5..097c708ab1c718e6a15f933305f08fdc60892a84 100644 (file)
@@ -85,14 +85,33 @@ void cli_show_router_rip(struct vty *vty, const struct lyd_node *dnode,
 /*
  * XPath: /frr-ripd:ripd/instance/allow-ecmp
  */
-DEFPY_YANG (rip_allow_ecmp,
+DEFUN_YANG (rip_allow_ecmp,
        rip_allow_ecmp_cmd,
-       "[no] allow-ecmp",
+       "allow-ecmp [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]",
+       "Allow Equal Cost MultiPath\n"
+       "Number of paths\n")
+{
+       int idx_number = 0;
+       char mpaths[3] = {};
+       uint32_t paths = MULTIPATH_NUM;
+
+       if (argv_find(argv, argc, CMD_RANGE_STR(1, MULTIPATH_NUM), &idx_number))
+               paths = strtol(argv[idx_number]->arg, NULL, 10);
+       snprintf(mpaths, sizeof(mpaths), "%u", paths);
+
+       nb_cli_enqueue_change(vty, "./allow-ecmp", NB_OP_MODIFY, mpaths);
+
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFUN_YANG (no_rip_allow_ecmp,
+       no_rip_allow_ecmp_cmd,
+       "no allow-ecmp [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]",
        NO_STR
-       "Allow Equal Cost MultiPath\n")
+       "Allow Equal Cost MultiPath\n"
+       "Number of paths\n")
 {
-       nb_cli_enqueue_change(vty, "./allow-ecmp", NB_OP_MODIFY,
-                             no ? "false" : "true");
+       nb_cli_enqueue_change(vty, "./allow-ecmp", NB_OP_MODIFY, 0);
 
        return nb_cli_apply_changes(vty, NULL);
 }
@@ -100,10 +119,14 @@ DEFPY_YANG (rip_allow_ecmp,
 void cli_show_rip_allow_ecmp(struct vty *vty, const struct lyd_node *dnode,
                             bool show_defaults)
 {
-       if (!yang_dnode_get_bool(dnode, NULL))
-               vty_out(vty, " no");
+       uint8_t paths;
+
+       paths = yang_dnode_get_uint8(dnode, NULL);
 
-       vty_out(vty, " allow-ecmp\n");
+       if (!paths)
+               vty_out(vty, " no allow-ecmp\n");
+       else
+               vty_out(vty, " allow-ecmp %d\n", paths);
 }
 
 /*
@@ -1156,6 +1179,7 @@ void rip_cli_init(void)
        install_element(RIP_NODE, &rip_no_distribute_list_cmd);
 
        install_element(RIP_NODE, &rip_allow_ecmp_cmd);
+       install_element(RIP_NODE, &no_rip_allow_ecmp_cmd);
        install_element(RIP_NODE, &rip_default_information_originate_cmd);
        install_element(RIP_NODE, &rip_default_metric_cmd);
        install_element(RIP_NODE, &no_rip_default_metric_cmd);