summaryrefslogtreecommitdiffstats
path: root/ripd/rip_northbound.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2018-05-09 06:34:59 +0200
committerRenato Westphal <renato@opensourcerouting.org>2018-10-27 20:16:12 +0200
commitf0ab22fb70ef94ce4f3109d36744d730003e9876 (patch)
tree9340b90badfbb1d02e91dc99b02dfd44e1a905ca /ripd/rip_northbound.c
parentripd: retrofit the 'distance source' commands to the new northbound model (diff)
downloadfrr-f0ab22fb70ef94ce4f3109d36744d730003e9876.tar.xz
frr-f0ab22fb70ef94ce4f3109d36744d730003e9876.zip
ripd: retrofit the 'neighbor' command to the new northbound model
Make rip_neighbor_add() and rip_neighbor_delete() return northbound error codes since their return values are used as the return value of some northbound callbacks. These functions shouldn't fail in normal conditions because the northbound layer guarantees it will never call the 'create' or 'delete' callback more than once for the same object. Hence any failure in those functions would indicate an internal inconsistency that needs to be investigated (by returning NB_ERR the northbound will log a detailed error message indicating the xpath of the object, the event and the callback where the error happened). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripd/rip_northbound.c')
-rw-r--r--ripd/rip_northbound.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/ripd/rip_northbound.c b/ripd/rip_northbound.c
index 25c279a77..fdb19a3c1 100644
--- a/ripd/rip_northbound.c
+++ b/ripd/rip_northbound.c
@@ -276,15 +276,31 @@ static int ripd_instance_explicit_neighbor_create(enum nb_event event,
const struct lyd_node *dnode,
union nb_resource *resource)
{
- /* TODO: implement me. */
- return NB_OK;
+ struct prefix_ipv4 p;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ p.family = AF_INET;
+ p.prefixlen = IPV4_MAX_BITLEN;
+ yang_dnode_get_ipv4(&p.prefix, dnode, NULL);
+
+ return rip_neighbor_add(&p);
}
static int ripd_instance_explicit_neighbor_delete(enum nb_event event,
const struct lyd_node *dnode)
{
- /* TODO: implement me. */
- return NB_OK;
+ struct prefix_ipv4 p;
+
+ if (event != NB_EV_APPLY)
+ return NB_OK;
+
+ p.family = AF_INET;
+ p.prefixlen = IPV4_MAX_BITLEN;
+ yang_dnode_get_ipv4(&p.prefix, dnode, NULL);
+
+ return rip_neighbor_delete(&p);
}
/*
@@ -858,6 +874,7 @@ const struct frr_yang_module_info frr_ripd_info = {
.xpath = "/frr-ripd:ripd/instance/explicit-neighbor",
.cbs.create = ripd_instance_explicit_neighbor_create,
.cbs.delete = ripd_instance_explicit_neighbor_delete,
+ .cbs.cli_show = cli_show_rip_neighbor,
},
{
.xpath = "/frr-ripd:ripd/instance/network",