]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: fix distribute-list deletion
authorIgor Ryzhov <idryzhov@gmail.com>
Fri, 9 Aug 2024 22:32:55 +0000 (01:32 +0300)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Mon, 12 Aug 2024 19:03:24 +0000 (19:03 +0000)
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 <idryzhov@gmail.com>
(cherry picked from commit 8fad4f317ebd3de7677d7600e7a024f713b20d70)

lib/distribute.c

index 90a73c363585df815977540ebce28e277c36b84b..c0693b084908976adb5c362aea2e4cacff6e5152 100644 (file)
@@ -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;
 }