Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: Speedup prefix-list readin by a large factor #13005

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/filter_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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).
Expand Down
73 changes: 4 additions & 69 deletions lib/filter_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down