Skip to content

Commit

Permalink
Merge pull request FRRouting#13005 from donaldsharp/prefix_list_speedup
Browse files Browse the repository at this point in the history
lib: Speedup prefix-list readin by a large factor
  • Loading branch information
riw777 authored Mar 17, 2023
2 parents 3bf4d3b + e2e8f8d commit d4906f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 75 deletions.
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

0 comments on commit d4906f8

Please sign in to comment.