summaryrefslogtreecommitdiff
path: root/ripngd/ripng_cli.c
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2024-01-22 16:52:45 +0200
committerGitHub <noreply@github.com>2024-01-22 16:52:45 +0200
commit22d1ad786f6961bf4f685599b5fb16a84b802346 (patch)
tree345dfb75b81fa4a7115c9751a9e3bd63b6e1901b /ripngd/ripng_cli.c
parent20ec72d7ca84c38894ac8799c4f86bc0fe914a3d (diff)
parentcc9f4029cb49e7bee1cda416ae8dc790769cc333 (diff)
Merge pull request #15185 from LabNConsulting/chopps/distlist
add northbound support to distribute-list code.
Diffstat (limited to 'ripngd/ripng_cli.c')
-rw-r--r--ripngd/ripng_cli.c85
1 files changed, 48 insertions, 37 deletions
diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c
index 88b9354d95..3212229ac6 100644
--- a/ripngd/ripng_cli.c
+++ b/ripngd/ripng_cli.c
@@ -516,48 +516,59 @@ DEFPY_YANG (clear_ipv6_rip,
return ret;
}
-DEFUN (ripng_ipv6_distribute_list,
- ripng_ipv6_distribute_list_cmd,
- "ipv6 distribute-list [prefix] ACCESSLIST6_NAME <in|out> [WORD]",
- "IPv6\n"
- "Filter networks in routing updates\n"
- "Specify a prefix\n"
- "Access-list name\n"
- "Filter incoming routing updates\n"
- "Filter outgoing routing updates\n"
- "Interface name\n")
+DEFPY_YANG(
+ ripng_ipv6_distribute_list, ripng_ipv6_distribute_list_cmd,
+ "ipv6 distribute-list [prefix]$prefix ACCESSLIST4_NAME$name <in|out>$dir [WORD$ifname]",
+ "Filter networks in routing updates\n"
+ "Specify a prefix list\n"
+ "access-list or prefix-list name\n"
+ "Filter incoming routing updates\n"
+ "Filter outgoing routing updates\n"
+ "Interface name\n")
{
- const char *ifname = NULL;
- int prefix = (argv[2]->type == WORD_TKN) ? 1 : 0;
-
- if (argv[argc - 1]->type == VARIABLE_TKN)
- ifname = argv[argc - 1]->arg;
+ char xpath[XPATH_MAXLEN];
- return distribute_list_parser(prefix, false, argv[3 + prefix]->text,
- argv[2 + prefix]->arg, ifname);
+ snprintf(xpath, sizeof(xpath),
+ "./distribute-list[interface='%s']/%s/%s-list",
+ ifname ? ifname : "", dir, prefix ? "prefix" : "access");
+ /* nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); */
+ nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, name);
+ return nb_cli_apply_changes(vty, NULL);
}
-DEFUN (ripng_no_ipv6_distribute_list,
- ripng_no_ipv6_distribute_list_cmd,
- "no ipv6 distribute-list [prefix] ACCESSLIST6_NAME <in|out> [WORD]",
- NO_STR
- "IPv6\n"
- "Filter networks in routing updates\n"
- "Specify a prefix\n"
- "Access-list name\n"
- "Filter incoming routing updates\n"
- "Filter outgoing routing updates\n"
- "Interface name\n")
+DEFPY_YANG(no_ripng_ipv6_distribute_list,
+ no_ripng_ipv6_distribute_list_cmd,
+ "no ipv6 distribute-list [prefix]$prefix [ACCESSLIST4_NAME$name] <in|out>$dir [WORD$ifname]",
+ NO_STR
+ "Filter networks in routing updates\n"
+ "Specify a prefix list\n"
+ "access-list or prefix-list name\n"
+ "Filter incoming routing updates\n"
+ "Filter outgoing routing updates\n"
+ "Interface name\n")
{
- const char *ifname = NULL;
- int prefix = (argv[3]->type == WORD_TKN) ? 1 : 0;
-
- if (argv[argc - 1]->type == VARIABLE_TKN)
- ifname = argv[argc - 1]->arg;
+ const struct lyd_node *value_node;
+ char xpath[XPATH_MAXLEN];
- return distribute_list_no_parser(vty, prefix, false,
- argv[4 + prefix]->text,
- argv[3 + prefix]->arg, ifname);
+ snprintf(xpath, sizeof(xpath),
+ "./distribute-list[interface='%s']/%s/%s-list",
+ ifname ? ifname : "", dir, prefix ? "prefix" : "access");
+ /*
+ * See if the user has specified specific list so check it exists.
+ *
+ * NOTE: Other FRR CLI commands do not do this sort of verification and
+ * there may be an official decision not to.
+ */
+ if (name) {
+ value_node = yang_dnode_getf(vty->candidate_config->dnode, "%s/%s",
+ VTY_CURR_XPATH, xpath);
+ if (!value_node || strcmp(name, lyd_get_value(value_node))) {
+ vty_out(vty, "distribute list doesn't exist\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+ }
+ nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+ return nb_cli_apply_changes(vty, NULL);
}
void ripng_cli_init(void)
@@ -566,7 +577,7 @@ void ripng_cli_init(void)
install_element(CONFIG_NODE, &no_router_ripng_cmd);
install_element(RIPNG_NODE, &ripng_ipv6_distribute_list_cmd);
- install_element(RIPNG_NODE, &ripng_no_ipv6_distribute_list_cmd);
+ install_element(RIPNG_NODE, &no_ripng_ipv6_distribute_list_cmd);
install_element(RIPNG_NODE, &ripng_allow_ecmp_cmd);
install_element(RIPNG_NODE, &no_ripng_allow_ecmp_cmd);