From e6aab613952cef68ab5396fea1d0b49dc3fb9b17 Mon Sep 17 00:00:00 2001 From: sarita patra Date: Mon, 28 Feb 2022 18:18:42 -0800 Subject: [PATCH] pim6d: Adding "ipv6 pim hello (1-65535) [(1-65535)]" CLI This cli used to configure PIMV6 hello and hold timer on interface. Signed-off-by: sarita patra --- pimd/pim6_cmd.c | 27 +++++++++++++++++++++++++++ pimd/pim6_cmd.h | 3 +++ pimd/pim_cmd.c | 34 ++++++---------------------------- pimd/pim_cmd_common.c | 37 +++++++++++++++++++++++++++++++++++++ pimd/pim_cmd_common.h | 3 +++ 5 files changed, 76 insertions(+), 28 deletions(-) diff --git a/pimd/pim6_cmd.c b/pimd/pim6_cmd.c index 3c796930de..330cff755f 100644 --- a/pimd/pim6_cmd.c +++ b/pimd/pim6_cmd.c @@ -252,6 +252,31 @@ DEFPY (interface_no_ipv6_pim_drprio, return pim_process_no_ip_pim_drprio_cmd(vty); } +DEFPY (interface_ipv6_pim_hello, + interface_ipv6_pim_hello_cmd, + "ipv6 pim hello (1-65535) [(1-65535)]$hold", + IPV6_STR + PIM_STR + IFACE_PIM_HELLO_STR + IFACE_PIM_HELLO_TIME_STR + IFACE_PIM_HELLO_HOLD_STR) +{ + return pim_process_ip_pim_hello_cmd(vty, hello_str, hold_str); +} + +DEFPY (interface_no_ipv6_pim_hello, + interface_no_ipv6_pim_hello_cmd, + "no ipv6 pim hello [(1-65535) [(1-65535)]]", + NO_STR + IPV6_STR + PIM_STR + IFACE_PIM_HELLO_STR + IGNORED_IN_NO_STR + IGNORED_IN_NO_STR) +{ + return pim_process_no_ip_pim_hello_cmd(vty); +} + void pim_cmd_init(void) { if_cmd_init(pim_interface_config_write); @@ -274,4 +299,6 @@ void pim_cmd_init(void) install_element(INTERFACE_NODE, &interface_no_ipv6_pim_cmd); install_element(INTERFACE_NODE, &interface_ipv6_pim_drprio_cmd); install_element(INTERFACE_NODE, &interface_no_ipv6_pim_drprio_cmd); + install_element(INTERFACE_NODE, &interface_ipv6_pim_hello_cmd); + install_element(INTERFACE_NODE, &interface_no_ipv6_pim_hello_cmd); } diff --git a/pimd/pim6_cmd.h b/pimd/pim6_cmd.h index e49045a1b5..68b185c25b 100644 --- a/pimd/pim6_cmd.h +++ b/pimd/pim6_cmd.h @@ -33,6 +33,9 @@ #define IFACE_MLD_LAST_MEMBER_QUERY_INTERVAL_STR \ "MLD last member query interval\n" #define IFACE_MLD_LAST_MEMBER_QUERY_COUNT_STR "MLD last member query count\n" +#define IFACE_PIM_HELLO_STR "Hello Interval\n" +#define IFACE_PIM_HELLO_TIME_STR "Time in seconds for Hello Interval\n" +#define IFACE_PIM_HELLO_HOLD_STR "Time in seconds for Hold Interval\n" #define MROUTE_STR "IP multicast routing table\n" #define DEBUG_MLD_STR "MLD protocol activity\n" #define DEBUG_MLD_EVENTS_STR "MLD protocol events\n" diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 5aa1797223..19044064f3 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -8324,31 +8324,14 @@ DEFUN (interface_ip_pim_hello, { int idx_time = 3; int idx_hold = 4; - const struct lyd_node *igmp_enable_dnode; - - igmp_enable_dnode = - yang_dnode_getf(vty->candidate_config->dnode, - FRR_GMP_ENABLE_XPATH, VTY_CURR_XPATH, - "frr-routing:ipv4"); - if (!igmp_enable_dnode) { - nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY, - "true"); - } else { - if (!yang_dnode_get_bool(igmp_enable_dnode, ".")) - nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY, - "true"); - } - - nb_cli_enqueue_change(vty, "./hello-interval", NB_OP_MODIFY, - argv[idx_time]->arg); if (argc == idx_hold + 1) - nb_cli_enqueue_change(vty, "./hello-holdtime", NB_OP_MODIFY, - argv[idx_hold]->arg); + return pim_process_ip_pim_hello_cmd(vty, argv[idx_time]->arg, + argv[idx_hold]->arg); - return nb_cli_apply_changes(vty, - FRR_PIM_INTERFACE_XPATH, - "frr-routing:ipv4"); + else + return pim_process_ip_pim_hello_cmd(vty, argv[idx_time]->arg, + NULL); } DEFUN (interface_no_ip_pim_hello, @@ -8361,12 +8344,7 @@ DEFUN (interface_no_ip_pim_hello, IGNORED_IN_NO_STR IGNORED_IN_NO_STR) { - nb_cli_enqueue_change(vty, "./hello-interval", NB_OP_DESTROY, NULL); - nb_cli_enqueue_change(vty, "./hello-holdtime", NB_OP_DESTROY, NULL); - - return nb_cli_apply_changes(vty, - FRR_PIM_INTERFACE_XPATH, - "frr-routing:ipv4"); + return pim_process_no_ip_pim_hello_cmd(vty); } DEFUN (debug_igmp, diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 2355a5cd0e..386a837548 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -388,3 +388,40 @@ int pim_process_no_ip_pim_drprio_cmd(struct vty *vty) return nb_cli_apply_changes(vty, FRR_PIM_INTERFACE_XPATH, FRR_PIM_AF_XPATH_VAL); } + +int pim_process_ip_pim_hello_cmd(struct vty *vty, const char *hello_str, + const char *hold_str) +{ + const struct lyd_node *mld_enable_dnode; + + mld_enable_dnode = yang_dnode_getf(vty->candidate_config->dnode, + FRR_GMP_ENABLE_XPATH, VTY_CURR_XPATH, + FRR_PIM_AF_XPATH_VAL); + + if (!mld_enable_dnode) { + nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY, + "true"); + } else { + if (!yang_dnode_get_bool(mld_enable_dnode, ".")) + nb_cli_enqueue_change(vty, "./pim-enable", NB_OP_MODIFY, + "true"); + } + + nb_cli_enqueue_change(vty, "./hello-interval", NB_OP_MODIFY, hello_str); + + if (hold_str) + nb_cli_enqueue_change(vty, "./hello-holdtime", NB_OP_MODIFY, + hold_str); + + return nb_cli_apply_changes(vty, FRR_PIM_INTERFACE_XPATH, + FRR_PIM_AF_XPATH_VAL); +} + +int pim_process_no_ip_pim_hello_cmd(struct vty *vty) +{ + nb_cli_enqueue_change(vty, "./hello-interval", NB_OP_DESTROY, NULL); + nb_cli_enqueue_change(vty, "./hello-holdtime", NB_OP_DESTROY, NULL); + + return nb_cli_apply_changes(vty, FRR_PIM_INTERFACE_XPATH, + FRR_PIM_AF_XPATH_VAL); +} diff --git a/pimd/pim_cmd_common.h b/pimd/pim_cmd_common.h index aaf10734f5..44c70e1cb6 100644 --- a/pimd/pim_cmd_common.h +++ b/pimd/pim_cmd_common.h @@ -40,5 +40,8 @@ int pim_process_ip_pim_cmd(struct vty *vty); int pim_process_no_ip_pim_cmd(struct vty *vty); int pim_process_ip_pim_drprio_cmd(struct vty *vty, const char *drpriority_str); int pim_process_no_ip_pim_drprio_cmd(struct vty *vty); +int pim_process_ip_pim_hello_cmd(struct vty *vty, const char *hello_str, + const char *hold_str); +int pim_process_no_ip_pim_hello_cmd(struct vty *vty); #endif /* PIM_CMD_COMMON_H */ -- 2.39.5