summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-04-09 19:42:23 +0300
committerIgor Ryzhov <iryzhov@nfware.com>2021-04-09 20:58:36 +0300
commit38133c4a11141c60be07906ce7a0e9efc55ba318 (patch)
treeea565def0566459c005462b6441183d92df0d0a9
parent3ebeec9446e4bcc29f477c778ff2b4fa276df7d3 (diff)
lib, doc: add "route-map NAME optimization" command
Currently we have a "route-map optimization" command which is entered from inside the route-map entry but actually applies to the whole route-map. In addition, this command is not shown in the running-config and not stored to the startup-config during "write". Let's add a new command on the config node level to control this setting and show it in the running-config to make possible to save it during "write". The old command is saved for the backward compatibility but hidden and marked as deprecated. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
-rw-r--r--doc/user/routemap.rst6
-rw-r--r--lib/routemap.h3
-rw-r--r--lib/routemap_cli.c52
-rw-r--r--lib/routemap_northbound.c1
-rw-r--r--vtysh/vtysh_config.c3
5 files changed, 57 insertions, 8 deletions
diff --git a/doc/user/routemap.rst b/doc/user/routemap.rst
index 7f357b0925..3cb83cc652 100644
--- a/doc/user/routemap.rst
+++ b/doc/user/routemap.rst
@@ -333,10 +333,10 @@ Route Map Exit Action Command
Route Map Optimization Command
==============================
-.. clicmd:: route-map optimization
+.. clicmd:: route-map ROUTE-MAP-NAME optimization
- Enable route-map processing optimization. The optimization is
- enabled by default.
+ Enable route-map processing optimization for `route-map-name`.
+ The optimization is enabled by default.
Instead of sequentially passing through all the route-map indexes
until a match is found, the search for the best-match index will be
based on a look-up in a prefix-tree. A per-route-map prefix-tree
diff --git a/lib/routemap.h b/lib/routemap.h
index 6385193bbf..5b6b64eaeb 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -902,6 +902,9 @@ extern void route_map_call_show(struct vty *vty, struct lyd_node *dnode,
extern void route_map_description_show(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
+extern void route_map_optimization_disabled_show(struct vty *vty,
+ struct lyd_node *dnode,
+ bool show_defaults);
extern void route_map_cli_init(void);
#ifdef __cplusplus
diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c
index c93e59e99b..e11b9eea74 100644
--- a/lib/routemap_cli.c
+++ b/lib/routemap_cli.c
@@ -1396,16 +1396,57 @@ void route_map_description_show(struct vty *vty, struct lyd_node *dnode,
vty_out(vty, " description %s\n", yang_dnode_get_string(dnode, NULL));
}
-DEFPY_YANG(routemap_optimization, routemap_optimization_cmd,
- "[no] route-map optimization",
- NO_STR
- "route-map\n"
- "optimization\n")
+DEFPY_YANG(
+ route_map_optimization, route_map_optimization_cmd,
+ "[no] route-map WORD$name optimization",
+ NO_STR
+ ROUTE_MAP_CMD_STR
+ "Configure route-map optimization\n")
+{
+ char xpath[XPATH_MAXLEN];
+
+ snprintf(xpath, sizeof(xpath),
+ "/frr-route-map:lib/route-map[name='%s']", name);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+
+ snprintf(
+ xpath, sizeof(xpath),
+ "/frr-route-map:lib/route-map[name='%s']/optimization-disabled",
+ name);
+ nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, no ? "true" : "false");
+
+ return nb_cli_apply_changes(vty, NULL);
+}
+
+void route_map_optimization_disabled_show(struct vty *vty,
+ struct lyd_node *dnode,
+ bool show_defaults)
+{
+ const char *name = yang_dnode_get_string(dnode, "../name");
+ const bool disabled = yang_dnode_get_bool(dnode, NULL);
+
+ vty_out(vty, "%sroute-map %s optimization\n", disabled ? "no " : "",
+ name);
+}
+
+#if CONFDATE > 20220409
+CPP_NOTICE("Time to remove old route-map optimization command")
+#endif
+
+DEFPY_HIDDEN(
+ routemap_optimization, routemap_optimization_cmd,
+ "[no] route-map optimization",
+ NO_STR
+ "route-map\n"
+ "optimization\n")
{
const struct lyd_node *rmi_dnode;
const char *rm_name;
char xpath[XPATH_MAXLEN];
+ vty_out(vty,
+ "%% This command is deprecated. Please, use `route-map NAME optimization` from the config node.\n");
+
rmi_dnode =
yang_dnode_get(vty->candidate_config->dnode, VTY_CURR_XPATH);
if (!rmi_dnode) {
@@ -1474,6 +1515,7 @@ void route_map_cli_init(void)
install_element(CONFIG_NODE, &route_map_cmd);
install_element(CONFIG_NODE, &no_route_map_cmd);
install_element(CONFIG_NODE, &no_route_map_all_cmd);
+ install_element(CONFIG_NODE, &route_map_optimization_cmd);
/* Install the on-match stuff */
install_element(RMAP_NODE, &rmap_onmatch_next_cmd);
diff --git a/lib/routemap_northbound.c b/lib/routemap_northbound.c
index 64be8ad6b0..db06e9caac 100644
--- a/lib/routemap_northbound.c
+++ b/lib/routemap_northbound.c
@@ -1225,6 +1225,7 @@ const struct frr_yang_module_info frr_route_map_info = {
.xpath = "/frr-route-map:lib/route-map/optimization-disabled",
.cbs = {
.modify = lib_route_map_optimization_disabled_modify,
+ .cli_show = route_map_optimization_disabled_show,
}
},
{
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index 498d3e5f67..3414c764ce 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -342,6 +342,9 @@ void vtysh_config_parse_line(void *arg, const char *line)
config = config_get(OPENFABRIC_NODE, line);
else if (strncmp(line, "route-map", strlen("route-map")) == 0)
config = config_get(RMAP_NODE, line);
+ else if (strncmp(line, "no route-map", strlen("no route-map"))
+ == 0)
+ config = config_get(RMAP_NODE, line);
else if (strncmp(line, "pbr-map", strlen("pbr-map")) == 0)
config = config_get(PBRMAP_NODE, line);
else if (strncmp(line, "access-list", strlen("access-list"))