|
|
- From cc5934ed5939315ba5d95bfaf052625762107205 Mon Sep 17 00:00:00 2001
- From: Donald Sharp <sharpd@cumulusnetworks.com>
- Date: Tue, 30 Jun 2020 08:59:46 -0400
- Subject: [PATCH 1/2] vtysh: master is a non-sorted list
-
- The commit:
- a798241265a5808083a06b14ce1637d1ddf6a45a
-
- attempted to use sorted master lists to do faster lookups
- by using a RB Tree. Unfortunately the original code
- was creating a list->cmp function *but* never using it.
- If you look at the commit, it clearly shows that the
- function listnode_add is used to insert but when you
- look at that function it is a tail push.
-
- Fixes: #6573
-
- Namely now this ordering is preserved:
- bgp as-path access-list originate-only permit ^$
- bgp as-path access-list originate-only deny .*
-
- Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
- ---
- vtysh/vtysh_config.c | 21 ++++++++++-----------
- 1 file changed, 10 insertions(+), 11 deletions(-)
-
- diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
- index abbb111f9d..2ab9dd5a9a 100644
- --- a/vtysh/vtysh_config.c
- +++ b/vtysh/vtysh_config.c
- @@ -34,7 +34,7 @@ DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CONFIG_LINE, "Vtysh configuration line")
-
- vector configvec;
-
- -PREDECL_RBTREE_UNIQ(config_master);
- +PREDECL_LIST(config_master);
-
- struct config {
- /* Configuration node name. */
- @@ -72,11 +72,6 @@ static struct config *config_new(void)
- return config;
- }
-
- -static int config_cmp(const struct config *c1, const struct config *c2)
- -{
- - return strcmp(c1->name, c2->name);
- -}
- -
- static void config_del(struct config *config)
- {
- list_delete(&config->line);
- @@ -84,13 +79,15 @@ static void config_del(struct config *config)
- XFREE(MTYPE_VTYSH_CONFIG, config);
- }
-
- -DECLARE_RBTREE_UNIQ(config_master, struct config, rbt_item, config_cmp)
- +DECLARE_LIST(config_master, struct config, rbt_item)
-
- static struct config *config_get(int index, const char *line)
- {
- - struct config *config;
- + struct config *config, *config_loop;
- struct config_master_head *master;
-
- + config = config_loop = NULL;
- +
- master = vector_lookup_ensure(configvec, index);
-
- if (!master) {
- @@ -99,8 +96,10 @@ static struct config *config_get(int index, const char *line)
- vector_set_index(configvec, index, master);
- }
-
- - const struct config config_ref = { .name = (char *)line };
- - config = config_master_find(master, &config_ref);
- + frr_each (config_master, master, config_loop) {
- + if (strcmp(config_loop->name, line) == 0)
- + config = config_loop;
- + }
-
- if (!config) {
- config = config_new();
- @@ -109,7 +108,7 @@ static struct config *config_get(int index, const char *line)
- config->line->cmp = (int (*)(void *, void *))line_cmp;
- config->name = XSTRDUP(MTYPE_VTYSH_CONFIG_LINE, line);
- config->index = index;
- - config_master_add(master, config);
- + config_master_add_tail(master, config);
- }
- return config;
- }
-
- From 3e4d90ec556649e11954f2f56b5282f95e7e013b Mon Sep 17 00:00:00 2001
- From: Donald Sharp <sharpd@cumulusnetworks.com>
- Date: Tue, 30 Jun 2020 09:03:55 -0400
- Subject: [PATCH 2/2] vtysh: Improve lookup performance
-
- When we find the line we are interested in, stop looking.
-
- Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
- ---
- vtysh/vtysh_config.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
- diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
- index 2ab9dd5a9a..61bcf3b658 100644
- --- a/vtysh/vtysh_config.c
- +++ b/vtysh/vtysh_config.c
- @@ -97,8 +97,10 @@ static struct config *config_get(int index, const char *line)
- }
-
- frr_each (config_master, master, config_loop) {
- - if (strcmp(config_loop->name, line) == 0)
- + if (strcmp(config_loop->name, line) == 0) {
- config = config_loop;
- + break;
- + }
- }
-
- if (!config) {
|