summaryrefslogtreecommitdiffstats
path: root/ripd/rip_interface.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_interface.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_interface.c')
-rw-r--r--ripd/rip_interface.c62
1 files changed, 7 insertions, 55 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index bbac1a0a0..4373484a2 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -35,6 +35,7 @@
#include "sockopt.h"
#include "privs.h"
#include "lib_errors.h"
+#include "northbound_cli.h"
#include "zebra/connected.h"
@@ -1011,29 +1012,29 @@ int rip_neighbor_lookup(struct sockaddr_in *from)
}
/* Add new RIP neighbor to the neighbor tree. */
-static int rip_neighbor_add(struct prefix_ipv4 *p)
+int rip_neighbor_add(struct prefix_ipv4 *p)
{
struct route_node *node;
node = route_node_get(rip->neighbor, (struct prefix *)p);
if (node->info)
- return -1;
+ return NB_ERR_INCONSISTENCY;
node->info = rip->neighbor;
- return 0;
+ return NB_OK;
}
/* Delete RIP neighbor from the neighbor tree. */
-static int rip_neighbor_delete(struct prefix_ipv4 *p)
+int rip_neighbor_delete(struct prefix_ipv4 *p)
{
struct route_node *node;
/* Lock for look up. */
node = route_node_lookup(rip->neighbor, (struct prefix *)p);
if (!node)
- return -1;
+ return NB_ERR_INCONSISTENCY;
node->info = NULL;
@@ -1043,7 +1044,7 @@ static int rip_neighbor_delete(struct prefix_ipv4 *p)
/* Unlock real neighbor information lock. */
route_unlock_node(node);
- return 0;
+ return NB_OK;
}
/* Clear all network and neighbor configuration. */
@@ -1208,53 +1209,6 @@ DEFUN (no_rip_network,
return CMD_SUCCESS;
}
-/* RIP neighbor configuration set. */
-DEFUN (rip_neighbor,
- rip_neighbor_cmd,
- "neighbor A.B.C.D",
- "Specify a neighbor router\n"
- "Neighbor address\n")
-{
- int idx_ipv4 = 1;
- int ret;
- struct prefix_ipv4 p;
-
- ret = str2prefix_ipv4(argv[idx_ipv4]->arg, &p);
-
- if (ret <= 0) {
- vty_out(vty, "Please specify address by A.B.C.D\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- rip_neighbor_add(&p);
-
- return CMD_SUCCESS;
-}
-
-/* RIP neighbor configuration unset. */
-DEFUN (no_rip_neighbor,
- no_rip_neighbor_cmd,
- "no neighbor A.B.C.D",
- NO_STR
- "Specify a neighbor router\n"
- "Neighbor address\n")
-{
- int idx_ipv4 = 2;
- int ret;
- struct prefix_ipv4 p;
-
- ret = str2prefix_ipv4(argv[idx_ipv4]->arg, &p);
-
- if (ret <= 0) {
- vty_out(vty, "Please specify address by A.B.C.D\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- rip_neighbor_delete(&p);
-
- return CMD_SUCCESS;
-}
-
DEFUN (ip_rip_receive_version,
ip_rip_receive_version_cmd,
"ip rip receive version <(1-2)|none>",
@@ -1896,8 +1850,6 @@ void rip_if_init(void)
/* Install commands. */
install_element(RIP_NODE, &rip_network_cmd);
install_element(RIP_NODE, &no_rip_network_cmd);
- install_element(RIP_NODE, &rip_neighbor_cmd);
- install_element(RIP_NODE, &no_rip_neighbor_cmd);
install_element(RIP_NODE, &rip_passive_interface_cmd);
install_element(RIP_NODE, &no_rip_passive_interface_cmd);