Skip to content

Commit

Permalink
lib: fix distribute-list deletion
Browse files Browse the repository at this point in the history
When a whole distribute-list is deleted (can be done only using API),
all its children must be cleaned up manually.

Fixes #16538

Signed-off-by: Igor Ryzhov <[email protected]>
  • Loading branch information
idryzhov committed Aug 9, 2024
1 parent 927be7a commit 8fad4f3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/distribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,43 @@ int group_distribute_list_create_helper(
* XPath: /frr-ripd:ripd/instance/distribute-lists/distribute-list/{in,out}/{access,prefix}-list
*/

static int distribute_list_leaf_update(const struct lyd_node *dnode,
int ip_version, bool no);

int group_distribute_list_destroy(struct nb_cb_destroy_args *args)
{
struct lyd_node *dnode;

if (args->event != NB_EV_APPLY)
return NB_OK;

/*
* We don't keep the IP version of distribute-list anywhere, so we're
* trying to remove both. If one doesn't exist, it's simply skipped by
* the remove function.
*/

dnode = yang_dnode_get(args->dnode, "in/access-list");
if (dnode) {
distribute_list_leaf_update(dnode, 4, true);
distribute_list_leaf_update(dnode, 6, true);
}
dnode = yang_dnode_get(args->dnode, "in/prefix-list");
if (dnode) {
distribute_list_leaf_update(dnode, 4, true);
distribute_list_leaf_update(dnode, 6, true);
}
dnode = yang_dnode_get(args->dnode, "out/access-list");
if (dnode) {
distribute_list_leaf_update(dnode, 4, true);
distribute_list_leaf_update(dnode, 6, true);
}
dnode = yang_dnode_get(args->dnode, "out/prefix-list");
if (dnode) {
distribute_list_leaf_update(dnode, 4, true);
distribute_list_leaf_update(dnode, 6, true);
}

nb_running_unset_entry(args->dnode);
return NB_OK;
}
Expand Down

0 comments on commit 8fad4f3

Please sign in to comment.