Skip to content

Commit

Permalink
ripngd: use correct autocompletion for distribute-list commands
Browse files Browse the repository at this point in the history
Currently, we always use access-list autocompletion, even if configuring
prefix-lists. We should differentiate. Also, fix missing "IPv6"
docstring and use correct address family.

Signed-off-by: Igor Ryzhov <[email protected]>
  • Loading branch information
idryzhov committed Jan 22, 2024
1 parent bdbe43a commit 160ece9
Showing 1 changed file with 67 additions and 8 deletions.
75 changes: 67 additions & 8 deletions ripngd/ripng_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,31 +518,88 @@ DEFPY_YANG (clear_ipv6_rip,

DEFPY_YANG(
ripng_ipv6_distribute_list, ripng_ipv6_distribute_list_cmd,
"ipv6 distribute-list [prefix]$prefix ACCESSLIST4_NAME$name <in|out>$dir [WORD$ifname]",
"ipv6 distribute-list ACCESSLIST6_NAME$name <in|out>$dir [WORD$ifname]",
"IPv6\n"
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
char xpath[XPATH_MAXLEN];

snprintf(xpath, sizeof(xpath),
"./distribute-list[interface='%s']/%s/access-list",
ifname ? ifname : "", dir);
/* 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);
}

DEFPY_YANG(
ripng_ipv6_distribute_list_prefix, ripng_ipv6_distribute_list_prefix_cmd,
"ipv6 distribute-list prefix PREFIXLIST6_NAME$name <in|out>$dir [WORD$ifname]",
"IPv6\n"
"Filter networks in routing updates\n"
"Specify a prefix list\n"
"access-list or prefix-list name\n"
"Prefix-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
char xpath[XPATH_MAXLEN];

snprintf(xpath, sizeof(xpath),
"./distribute-list[interface='%s']/%s/%s-list",
ifname ? ifname : "", dir, prefix ? "prefix" : "access");
"./distribute-list[interface='%s']/%s/prefix-list",
ifname ? ifname : "", dir);
/* 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);
}

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 ipv6 distribute-list [ACCESSLIST6_NAME$name] <in|out>$dir [WORD$ifname]",
NO_STR
"IPv6\n"
"Filter networks in routing updates\n"
"Access-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
{
const struct lyd_node *value_node;
char xpath[XPATH_MAXLEN];

snprintf(xpath, sizeof(xpath),
"./distribute-list[interface='%s']/%s/access-list",
ifname ? ifname : "", dir);
/*
* 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);
}

DEFPY_YANG(no_ripng_ipv6_distribute_list_prefix,
no_ripng_ipv6_distribute_list_prefix_cmd,
"no ipv6 distribute-list prefix [PREFIXLIST6_NAME$name] <in|out>$dir [WORD$ifname]",
NO_STR
"IPv6\n"
"Filter networks in routing updates\n"
"Specify a prefix list\n"
"access-list or prefix-list name\n"
"Prefix-list name\n"
"Filter incoming routing updates\n"
"Filter outgoing routing updates\n"
"Interface name\n")
Expand All @@ -551,8 +608,8 @@ DEFPY_YANG(no_ripng_ipv6_distribute_list,
char xpath[XPATH_MAXLEN];

snprintf(xpath, sizeof(xpath),
"./distribute-list[interface='%s']/%s/%s-list",
ifname ? ifname : "", dir, prefix ? "prefix" : "access");
"./distribute-list[interface='%s']/%s/prefix-list",
ifname ? ifname : "", dir);
/*
* See if the user has specified specific list so check it exists.
*
Expand All @@ -577,7 +634,9 @@ 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_ipv6_distribute_list_prefix_cmd);
install_element(RIPNG_NODE, &no_ripng_ipv6_distribute_list_cmd);
install_element(RIPNG_NODE, &no_ripng_ipv6_distribute_list_prefix_cmd);

install_element(RIPNG_NODE, &ripng_allow_ecmp_cmd);
install_element(RIPNG_NODE, &no_ripng_allow_ecmp_cmd);
Expand Down

0 comments on commit 160ece9

Please sign in to comment.