]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Speedup prefix-list readin by a large factor
authorDonald Sharp <sharpd@nvidia.com>
Wed, 15 Mar 2023 17:51:19 +0000 (13:51 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 16 Mar 2023 14:40:35 +0000 (10:40 -0400)
Reading in prefix-lists is reading in the specified
prefix list and validating that the prefix is unique
2 times.  This makes no sense.  Relax the requirement
that a prefix list can limit this as well as completely
remove this check.  Validation then just becomes
does this prefix-list specified actually make sense
and that is taken care of by the the cli code.

Reading in prefix-lists was looking for duplicate prefixes
2 times instead of doing it just one time.  Let's just
not do it at all.

By doing this change, The code changes from never
completing for a 27k long prefix-list to taking
just under 30 seconds, with 4 daemons processing
this data.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
lib/filter_cli.c
lib/filter_nb.c

index 7ef0d47f67bc016e104784d8e021b5c63a80550f..07dd939f7128df24007783c901b1957b81bdda17 100644 (file)
@@ -1272,9 +1272,6 @@ DEFPY_YANG(
                pda.any = true;
        }
 
-       if (plist_is_dup(vty->candidate_config->dnode, &pda))
-               return CMD_SUCCESS;
-
        /*
         * Create the prefix-list first, so we can generate sequence if
         * none given (backward compatibility).
@@ -1476,9 +1473,6 @@ DEFPY_YANG(
                pda.any = true;
        }
 
-       if (plist_is_dup(vty->candidate_config->dnode, &pda))
-               return CMD_SUCCESS;
-
        /*
         * Create the prefix-list first, so we can generate sequence if
         * none given (backward compatibility).
index a14f232339db7719af12ebe9334d847898932068..eb0b94527f401130e90ed334edeb0b8bbd6f3710 100644 (file)
@@ -456,24 +456,6 @@ bool plist_is_dup(const struct lyd_node *dnode, struct plist_dup_args *pda)
        return pda->pda_found;
 }
 
-static bool plist_is_dup_nb(const struct lyd_node *dnode)
-{
-       const struct lyd_node *entry_dnode =
-               yang_dnode_get_parent(dnode, "entry");
-       struct plist_dup_args pda = {};
-
-       /* Initialize. */
-       pda.pda_type = yang_dnode_get_string(entry_dnode, "../type");
-       pda.pda_name = yang_dnode_get_string(entry_dnode, "../name");
-       pda.pda_action = yang_dnode_get_string(entry_dnode, "action");
-       pda.pda_entry_dnode = entry_dnode;
-
-       plist_dnode_to_prefix(entry_dnode, &pda.any, &pda.prefix, &pda.ge,
-                             &pda.le);
-
-       return plist_is_dup(entry_dnode, &pda);
-}
-
 /*
  * XPath: /frr-filter:lib/access-list
  */
@@ -1331,13 +1313,6 @@ lib_prefix_list_entry_ipv4_prefix_modify(struct nb_cb_modify_args *args)
                const struct lyd_node *plist_dnode =
                        yang_dnode_get_parent(args->dnode, "prefix-list");
 
-               if (plist_is_dup_nb(args->dnode)) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "duplicated prefix list value: %s",
-                                yang_dnode_get_string(args->dnode, NULL));
-                       return NB_ERR_VALIDATION;
-               }
-
                return prefix_list_nb_validate_v4_af_type(
                        plist_dnode, args->errmsg, args->errmsg_len);
        }
@@ -1366,13 +1341,6 @@ lib_prefix_list_entry_ipv6_prefix_modify(struct nb_cb_modify_args *args)
                const struct lyd_node *plist_dnode =
                        yang_dnode_get_parent(args->dnode, "prefix-list");
 
-               if (plist_is_dup_nb(args->dnode)) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "duplicated prefix list value: %s",
-                                yang_dnode_get_string(args->dnode, NULL));
-                       return NB_ERR_VALIDATION;
-               }
-
                return prefix_list_nb_validate_v6_af_type(
                        plist_dnode, args->errmsg, args->errmsg_len);
        }
@@ -1404,13 +1372,6 @@ static int lib_prefix_list_entry_ipv4_prefix_length_greater_or_equal_modify(
                const struct lyd_node *plist_dnode =
                        yang_dnode_get_parent(args->dnode, "prefix-list");
 
-               if (plist_is_dup_nb(args->dnode)) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "duplicated prefix list value: %s",
-                                yang_dnode_get_string(args->dnode, NULL));
-                       return NB_ERR_VALIDATION;
-               }
-
                return prefix_list_nb_validate_v4_af_type(
                        plist_dnode, args->errmsg, args->errmsg_len);
        }
@@ -1448,13 +1409,6 @@ static int lib_prefix_list_entry_ipv4_prefix_length_lesser_or_equal_modify(
                const struct lyd_node *plist_dnode =
                        yang_dnode_get_parent(args->dnode, "prefix-list");
 
-               if (plist_is_dup_nb(args->dnode)) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "duplicated prefix list value: %s",
-                                yang_dnode_get_string(args->dnode, NULL));
-                       return NB_ERR_VALIDATION;
-               }
-
                return prefix_list_nb_validate_v4_af_type(
                        plist_dnode, args->errmsg, args->errmsg_len);
        }
@@ -1492,13 +1446,6 @@ static int lib_prefix_list_entry_ipv6_prefix_length_greater_or_equal_modify(
                const struct lyd_node *plist_dnode =
                        yang_dnode_get_parent(args->dnode, "prefix-list");
 
-               if (plist_is_dup_nb(args->dnode)) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "duplicated prefix list value: %s",
-                                yang_dnode_get_string(args->dnode, NULL));
-                       return NB_ERR_VALIDATION;
-               }
-
                return prefix_list_nb_validate_v6_af_type(
                        plist_dnode, args->errmsg, args->errmsg_len);
        }
@@ -1536,13 +1483,6 @@ static int lib_prefix_list_entry_ipv6_prefix_length_lesser_or_equal_modify(
                const struct lyd_node *plist_dnode =
                        yang_dnode_get_parent(args->dnode, "prefix-list");
 
-               if (plist_is_dup_nb(args->dnode)) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "duplicated prefix list value: %s",
-                                yang_dnode_get_string(args->dnode, NULL));
-                       return NB_ERR_VALIDATION;
-               }
-
                return prefix_list_nb_validate_v6_af_type(
                        plist_dnode, args->errmsg, args->errmsg_len);
        }
@@ -1574,16 +1514,11 @@ static int lib_prefix_list_entry_any_create(struct nb_cb_create_args *args)
        struct prefix_list_entry *ple;
        int type;
 
-       if (args->event == NB_EV_VALIDATE) {
-               if (plist_is_dup_nb(args->dnode)) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "duplicated prefix list value: %s",
-                                yang_dnode_get_string(args->dnode, NULL));
-                       return NB_ERR_VALIDATION;
-               }
-
+       /*
+        * If we have gotten to this point, it's legal
+        */
+       if (args->event == NB_EV_VALIDATE)
                return NB_OK;
-       }
 
        if (args->event != NB_EV_APPLY)
                return NB_OK;