]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: fix deletion of empty prefix-lists
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 6 Apr 2021 18:26:09 +0000 (21:26 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 6 Apr 2021 20:18:47 +0000 (23:18 +0300)
We delete the prefix-list when its last entry is deleted, but the check
is missed when we delete the description.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
lib/filter_cli.c

index 02dfd7f8b25babd55ba6893c974ae57cd724d7b2..f42290dc19d31f048024587e754802f6009ad93c 100644 (file)
@@ -1462,13 +1462,18 @@ DEFPY_YANG(
        ACCESS_LIST_REMARK_STR)
 {
        char xpath[XPATH_MAXLEN];
+       int rv;
 
        snprintf(xpath, sizeof(xpath),
                 "/frr-filter:lib/prefix-list[type='ipv4'][name='%s']/remark",
                 name);
        nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
 
-       return nb_cli_apply_changes(vty, NULL);
+       rv = nb_cli_apply_changes(vty, NULL);
+       if (rv == CMD_SUCCESS)
+               return plist_remove_if_empty(vty, "ipv4", name);
+
+       return rv;
 }
 
 ALIAS(
@@ -1658,13 +1663,18 @@ DEFPY_YANG(
        ACCESS_LIST_REMARK_STR)
 {
        char xpath[XPATH_MAXLEN];
+       int rv;
 
        snprintf(xpath, sizeof(xpath),
                 "/frr-filter:lib/prefix-list[type='ipv6'][name='%s']/remark",
                 name);
        nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
 
-       return nb_cli_apply_changes(vty, NULL);
+       rv = nb_cli_apply_changes(vty, NULL);
+       if (rv == CMD_SUCCESS)
+               return plist_remove_if_empty(vty, "ipv6", name);
+
+       return rv;
 }
 
 ALIAS(