summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2024-01-23 01:09:25 +0100
committerIgor Ryzhov <iryzhov@nfware.com>2024-01-23 11:33:39 +0100
commita594cda8cec0a67d59ee28d5fb59e958611370c9 (patch)
treec3860517b2672f8785569bf8a10a85ca3a117739 /ripd
parentMerge pull request #15185 from LabNConsulting/chopps/distlist (diff)
downloadfrr-a594cda8cec0a67d59ee28d5fb59e958611370c9.tar.xz
frr-a594cda8cec0a67d59ee28d5fb59e958611370c9.zip
lib: remove leaf-list xpath hack from northbound
Currently, when editing a leaf-list, `nb_candidate_edit` expects to receive it's xpath without a predicate and the value in a separate argument, and then creates the full xpath. This hack is complicated, because it depends on the operation and on the caller being a backend or not. Instead, let's require to always include the predicate in a leaf-list xpath. Update all the usages in the code accordingly. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'ripd')
-rw-r--r--ripd/rip_cli.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c
index d4366d018..3344ccf11 100644
--- a/ripd/rip_cli.c
+++ b/ripd/rip_cli.c
@@ -273,8 +273,13 @@ DEFPY_YANG (rip_neighbor,
"Specify a neighbor router\n"
"Neighbor address\n")
{
- nb_cli_enqueue_change(vty, "./explicit-neighbor",
- no ? NB_OP_DESTROY : NB_OP_CREATE, neighbor_str);
+ char xpath[XPATH_MAXLEN];
+
+ snprintf(xpath, sizeof(xpath), "./explicit-neighbor[.='%s']",
+ neighbor_str);
+
+ nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE,
+ NULL);
return nb_cli_apply_changes(vty, NULL);
}
@@ -295,8 +300,12 @@ DEFPY_YANG (rip_network_prefix,
"Enable routing on an IP network\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
{
- nb_cli_enqueue_change(vty, "./network",
- no ? NB_OP_DESTROY : NB_OP_CREATE, network_str);
+ char xpath[XPATH_MAXLEN];
+
+ snprintf(xpath, sizeof(xpath), "./network[.='%s']", network_str);
+
+ nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE,
+ NULL);
return nb_cli_apply_changes(vty, NULL);
}
@@ -317,8 +326,12 @@ DEFPY_YANG (rip_network_if,
"Enable routing on an IP network\n"
"Interface name\n")
{
- nb_cli_enqueue_change(vty, "./interface",
- no ? NB_OP_DESTROY : NB_OP_CREATE, network);
+ char xpath[XPATH_MAXLEN];
+
+ snprintf(xpath, sizeof(xpath), "./interface[.='%s']", network);
+
+ nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE,
+ NULL);
return nb_cli_apply_changes(vty, NULL);
}
@@ -412,17 +425,21 @@ DEFPY_YANG (rip_passive_interface,
bool passive_default =
yang_dnode_get_bool(vty->candidate_config->dnode, "%s%s",
VTY_CURR_XPATH, "/passive-default");
+ char xpath[XPATH_MAXLEN];
+ enum nb_operation op;
if (passive_default) {
- nb_cli_enqueue_change(vty, "./non-passive-interface",
- no ? NB_OP_CREATE : NB_OP_DESTROY,
- ifname);
+ snprintf(xpath, sizeof(xpath),
+ "./non-passive-interface[.='%s']", ifname);
+ op = no ? NB_OP_CREATE : NB_OP_DESTROY;
} else {
- nb_cli_enqueue_change(vty, "./passive-interface",
- no ? NB_OP_DESTROY : NB_OP_CREATE,
- ifname);
+ snprintf(xpath, sizeof(xpath), "./passive-interface[.='%s']",
+ ifname);
+ op = no ? NB_OP_DESTROY : NB_OP_CREATE;
}
+ nb_cli_enqueue_change(vty, xpath, op, NULL);
+
return nb_cli_apply_changes(vty, NULL);
}
@@ -495,8 +512,12 @@ DEFPY_YANG (rip_route,
"RIP static route configuration\n"
"IP prefix <network>/<length>\n")
{
- nb_cli_enqueue_change(vty, "./static-route",
- no ? NB_OP_DESTROY : NB_OP_CREATE, route_str);
+ char xpath[XPATH_MAXLEN];
+
+ snprintf(xpath, sizeof(xpath), "./static-route[.='%s']", route_str);
+
+ nb_cli_enqueue_change(vty, xpath, no ? NB_OP_DESTROY : NB_OP_CREATE,
+ NULL);
return nb_cli_apply_changes(vty, NULL);
}