summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2024-01-21 21:19:28 +0000
committerChristian Hopps <chopps@labn.net>2024-01-22 11:33:40 +0000
commitcc9f4029cb49e7bee1cda416ae8dc790769cc333 (patch)
treeaf638267c31826db984ee210946af27bdb17e015
parent8f7a9355f216adbfb4c2727432e394b5bc8d5703 (diff)
ripngd: use new distribute-list northbound code.
Signed-off-by: Christian Hopps <chopps@labn.net>
-rw-r--r--ripngd/ripng_cli.c86
-rw-r--r--ripngd/ripng_nb.c44
-rw-r--r--ripngd/ripng_nb.h4
-rw-r--r--ripngd/ripng_nb_config.c16
-rw-r--r--ripngd/ripngd.c2
-rw-r--r--yang/frr-ripngd.yang11
6 files changed, 120 insertions, 43 deletions
diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c
index c5ffefe96b..3212229ac6 100644
--- a/ripngd/ripng_cli.c
+++ b/ripngd/ripng_cli.c
@@ -516,49 +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(NULL, 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(NULL, 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)
@@ -567,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);
diff --git a/ripngd/ripng_nb.c b/ripngd/ripng_nb.c
index 1c6d7191a3..583a4d08d0 100644
--- a/ripngd/ripng_nb.c
+++ b/ripngd/ripng_nb.c
@@ -6,11 +6,12 @@
#include <zebra.h>
-#include "northbound.h"
+#include "distribute.h"
+#include "if_rmap.h"
#include "libfrr.h"
+#include "northbound.h"
#include "ripngd/ripng_nb.h"
-#include "lib/if_rmap.h"
/* clang-format off */
const struct frr_yang_module_info frr_ripngd_info = {
@@ -93,6 +94,45 @@ const struct frr_yang_module_info frr_ripngd_info = {
},
},
{
+ .xpath = "/frr-ripngd:ripngd/instance/distribute-list",
+ .cbs = {
+ .create = ripngd_instance_distribute_list_create,
+ .destroy = group_distribute_list_destroy,
+ }
+ },
+ {
+ .xpath = "/frr-ripngd:ripngd/instance/distribute-list/in/access-list",
+ .cbs = {
+ .modify = group_distribute_list_ipv6_modify,
+ .destroy = group_distribute_list_ipv6_destroy,
+ .cli_show = group_distribute_list_ipv6_cli_show,
+ }
+ },
+ {
+ .xpath = "/frr-ripngd:ripngd/instance/distribute-list/out/access-list",
+ .cbs = {
+ .modify = group_distribute_list_ipv6_modify,
+ .destroy = group_distribute_list_ipv6_destroy,
+ .cli_show = group_distribute_list_ipv6_cli_show,
+ }
+ },
+ {
+ .xpath = "/frr-ripngd:ripngd/instance/distribute-list/in/prefix-list",
+ .cbs = {
+ .modify = group_distribute_list_ipv6_modify,
+ .destroy = group_distribute_list_ipv6_destroy,
+ .cli_show = group_distribute_list_ipv6_cli_show,
+ }
+ },
+ {
+ .xpath = "/frr-ripngd:ripngd/instance/distribute-list/out/prefix-list",
+ .cbs = {
+ .modify = group_distribute_list_ipv6_modify,
+ .destroy = group_distribute_list_ipv6_destroy,
+ .cli_show = group_distribute_list_ipv6_cli_show,
+ }
+ },
+ {
.xpath = "/frr-ripngd:ripngd/instance/redistribute",
.cbs = {
.apply_finish = ripngd_instance_redistribute_apply_finish,
diff --git a/ripngd/ripng_nb.h b/ripngd/ripng_nb.h
index 1c0e63c241..12d3cd5129 100644
--- a/ripngd/ripng_nb.h
+++ b/ripngd/ripng_nb.h
@@ -7,6 +7,8 @@
#ifndef _FRR_RIPNG_NB_H_
#define _FRR_RIPNG_NB_H_
+#include "northbound.h"
+
extern const struct frr_yang_module_info frr_ripngd_info;
/* Mandatory callbacks. */
@@ -30,6 +32,8 @@ int ripngd_instance_offset_list_access_list_modify(
int ripngd_instance_offset_list_metric_modify(struct nb_cb_modify_args *args);
int ripngd_instance_passive_interface_create(struct nb_cb_create_args *args);
int ripngd_instance_passive_interface_destroy(struct nb_cb_destroy_args *args);
+int ripngd_instance_distribute_list_create(struct nb_cb_create_args *args);
+int ripngd_instance_distribute_list_destroy(struct nb_cb_destroy_args *args);
int ripngd_instance_redistribute_create(struct nb_cb_create_args *args);
int ripngd_instance_redistribute_destroy(struct nb_cb_destroy_args *args);
int ripngd_instance_redistribute_route_map_modify(
diff --git a/ripngd/ripng_nb_config.c b/ripngd/ripng_nb_config.c
index 6ce1c1e356..d05d91cfc7 100644
--- a/ripngd/ripng_nb_config.c
+++ b/ripngd/ripng_nb_config.c
@@ -369,6 +369,22 @@ int ripngd_instance_passive_interface_destroy(struct nb_cb_destroy_args *args)
}
/*
+ * XPath: /frr-ripng:ripng/instance/distribute-list
+ */
+int ripngd_instance_distribute_list_create(struct nb_cb_create_args *args)
+{
+ struct ripng *ripng;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ ripng = nb_running_get_entry(args->dnode, NULL, true);
+ group_distribute_list_create_helper(args, ripng->distribute_ctx);
+
+ return NB_OK;
+}
+
+/*
* XPath: /frr-ripngd:ripngd/instance/redistribute
*/
int ripngd_instance_redistribute_create(struct nb_cb_create_args *args)
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index bb6ec02343..4c3405d7dd 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -2286,8 +2286,6 @@ static int ripng_config_write(struct vty *vty)
nb_cli_show_dnode_cmds(vty, dnode, false);
- config_write_distribute(vty, ripng->distribute_ctx);
-
vty_out(vty, "exit\n");
write = 1;
diff --git a/yang/frr-ripngd.yang b/yang/frr-ripngd.yang
index 4aeaf36400..383b45fa4a 100644
--- a/yang/frr-ripngd.yang
+++ b/yang/frr-ripngd.yang
@@ -13,6 +13,9 @@ module frr-ripngd {
import frr-if-rmap {
prefix frr-if-rmap;
}
+ import frr-filter {
+ prefix frr-filter;
+ }
import frr-interface {
prefix frr-interface;
}
@@ -63,6 +66,7 @@ module frr-ripngd {
description
"Changed interface references to use
frr-interface:interface-ref typedef";
+ reference "FRRouting";
}
revision 2018-11-27 {
description
@@ -72,6 +76,7 @@ module frr-ripngd {
}
container ripngd {
+ description "ripng routing instance data";
/*
* Routing instance configuration.
*/
@@ -169,15 +174,18 @@ module frr-ripngd {
"A list of interfaces where the sending of RIPng packets
is disabled.";
}
+
+ uses frr-filter:distribute-list-group;
+
list redistribute {
key "protocol";
description
"Redistributes routes learned from other routing protocols.";
leaf protocol {
type frr-route-types:frr-route-types-v6;
+ must '. != "ripng"';
description
"Routing protocol.";
- must '. != "ripng"';
}
leaf route-map {
type frr-route-map:route-map-ref;
@@ -330,6 +338,7 @@ module frr-ripngd {
* Per-interface configuration data
*/
augment "/frr-interface:lib/frr-interface:interface" {
+ description "RIPng interface augmentation.";
container ripng {
description
"RIPng interface parameters.";