summaryrefslogtreecommitdiffstats
path: root/ripngd/ripngd.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2018-11-29 03:49:49 +0100
committerRenato Westphal <renato@opensourcerouting.org>2018-12-03 16:47:58 +0100
commit9a12e9e5edb4f119cd794f347581ae3a950f2c15 (patch)
treec7f26c73fd4c52e444a7c2dc1b032cd7c099544c /ripngd/ripngd.c
parentyang, ripngd: add 'frr-ripngd.yang' and associated stub callbacks (diff)
downloadfrr-9a12e9e5edb4f119cd794f347581ae3a950f2c15.tar.xz
frr-9a12e9e5edb4f119cd794f347581ae3a950f2c15.zip
ripngd: retrofit the 'router ripng' command to the new northbound model
* Implement the northbound callbacks associated to the '/frr-ripngd:ripngd/instance' YANG path (the code is mostly a copy and paste from the original "router ripng" DEFUNs); * Move ripng_make_socket() out of ripng_create() since creating a socket is an error-prone operation and thus needs to be performed separately during the NB_EV_PREPARE phase; * On ripng_create(), fetch the defaults from the frr-ripngd YANG model; * Convert the "[no] router ripng" CLI commands to be dumb wrappers around the northbound callbacks; * On ripng_config_write(), write logic to call all 'cli_show' northbound callbacks defined under the '/frr-ripngd:ripngd/instance' YANG path. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripngd/ripngd.c')
-rw-r--r--ripngd/ripngd.c78
1 files changed, 22 insertions, 56 deletions
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 2cbbbae7f..634596719 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -36,6 +36,7 @@
#include "if_rmap.h"
#include "privs.h"
#include "lib_errors.h"
+#include "northbound_cli.h"
#include "ripngd/ripngd.h"
#include "ripngd/ripng_route.h"
@@ -87,7 +88,7 @@ void ripng_info_free(struct ripng_info *rinfo)
}
/* Create ripng socket. */
-static int ripng_make_socket(void)
+int ripng_make_socket(void)
{
int ret;
int sock;
@@ -1778,7 +1779,7 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
}
/* Create new RIPng instance and set it to global variable. */
-static int ripng_create(void)
+int ripng_create(int socket)
{
/* ripng should be NULL. */
assert(ripng == NULL);
@@ -1788,10 +1789,15 @@ static int ripng_create(void)
/* Default version and timer values. */
ripng->version = RIPNG_V1;
- ripng->update_time = RIPNG_UPDATE_TIMER_DEFAULT;
- ripng->timeout_time = RIPNG_TIMEOUT_TIMER_DEFAULT;
- ripng->garbage_time = RIPNG_GARBAGE_TIMER_DEFAULT;
- ripng->default_metric = RIPNG_DEFAULT_METRIC_DEFAULT;
+ ripng->update_time = yang_get_default_uint32(
+ "%s/timers/update-interval", RIPNG_INSTANCE);
+ ripng->timeout_time = yang_get_default_uint32(
+ "%s/timers/holddown-interval", RIPNG_INSTANCE);
+ ripng->garbage_time = yang_get_default_uint32(
+ "%s/timers/flush-interval", RIPNG_INSTANCE);
+ ripng->default_metric =
+ yang_get_default_uint8("%s/default-metric", RIPNG_INSTANCE);
+ ripng->ecmp = yang_get_default_bool("%s/allow-ecmp", RIPNG_INSTANCE);
/* Make buffer. */
ripng->ibuf = stream_new(RIPNG_MAX_PACKET_SIZE * 5);
@@ -1803,9 +1809,7 @@ static int ripng_create(void)
ripng->aggregate = agg_table_init();
/* Make socket. */
- ripng->sock = ripng_make_socket();
- if (ripng->sock < 0)
- return ripng->sock;
+ ripng->sock = socket;
/* Threads. */
ripng_event(RIPNG_READ, ripng->sock);
@@ -2153,41 +2157,6 @@ DEFUN (clear_ipv6_rip,
return CMD_SUCCESS;
}
-DEFUN_NOSH (router_ripng,
- router_ripng_cmd,
- "router ripng",
- "Enable a routing process\n"
- "Make RIPng instance command\n")
-{
- int ret;
-
- vty->node = RIPNG_NODE;
-
- if (!ripng) {
- ret = ripng_create();
-
- /* Notice to user we couldn't create RIPng. */
- if (ret < 0) {
- zlog_warn("can't create RIPng");
- return CMD_WARNING_CONFIG_FAILED;
- }
- }
-
- return CMD_SUCCESS;
-}
-
-DEFUN (no_router_ripng,
- no_router_ripng_cmd,
- "no router ripng",
- NO_STR
- "Enable a routing process\n"
- "Make RIPng instance command\n")
-{
- if (ripng)
- ripng_clean();
- return CMD_SUCCESS;
-}
-
DEFUN (ripng_route,
ripng_route_cmd,
"route IPV6ADDR",
@@ -2643,15 +2612,14 @@ DEFUN (no_ripng_allow_ecmp,
/* RIPng configuration write function. */
static int ripng_config_write(struct vty *vty)
{
- int ripng_network_write(struct vty *, int);
- void ripng_redistribute_write(struct vty *, int);
+ struct lyd_node *dnode;
int write = 0;
struct agg_node *rp;
- if (ripng) {
-
- /* RIPng router. */
- vty_out(vty, "router ripng\n");
+ dnode = yang_dnode_get(running_config->dnode,
+ "/frr-ripngd:ripngd/instance");
+ if (dnode) {
+ nb_cli_show_dnode_cmds(vty, dnode, false);
if (ripng->default_information)
vty_out(vty, " default-information originate\n");
@@ -2705,12 +2673,13 @@ static int ripng_config_write(struct vty *vty)
vty_out (vty, " garbage-timer %d\n", ripng->garbage_time);
#endif /* 0 */
- write += config_write_distribute(vty);
+ config_write_distribute(vty);
- write += config_write_if_rmap(vty);
+ config_write_if_rmap(vty);
- write++;
+ write = 1;
}
+
return write;
}
@@ -2989,9 +2958,6 @@ void ripng_init()
install_element(ENABLE_NODE, &clear_ipv6_rip_cmd);
- install_element(CONFIG_NODE, &router_ripng_cmd);
- install_element(CONFIG_NODE, &no_router_ripng_cmd);
-
install_default(RIPNG_NODE);
install_element(RIPNG_NODE, &ripng_route_cmd);
install_element(RIPNG_NODE, &no_ripng_route_cmd);