summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas.abraitis@gmail.com>2020-04-27 12:13:48 +0300
committerDonatas Abraitis <donatas.abraitis@gmail.com>2020-04-27 12:13:48 +0300
commit7d16d76f4c5628aefd104d1a5bc97b1829a375e7 (patch)
tree6b7f828cfc8907d7988eba24a896e4d9c3335693
parent7351b9575423b665829fdaca76e0ffbbdf4e829e (diff)
lib: Delete the entire access-list only if there are no more entries
When you enter the access-list with the same sequence number but with a different prefix AND access-list has only a single entry, then the entry is deleted and the whole access-list is deleted. That means that "replace entry" never be re-inserted. With fix: ``` ~# vtysh -c 'c' -c 'access-list 1 seq 10 permit 127.0.0.10/32' ~# vtysh -c 'sh run' | grep access-list access-list 1 seq 10 permit 127.0.0.10/32 ~# vtysh -c 'c' -c 'access-list 1 seq 10 permit 127.0.0.20/32' ~# vtysh -c 'sh run' | grep access-list access-list 1 seq 10 permit 127.0.0.20/32 ~# vtysh -c 'c' -c 'access-list 1 seq 11 permit 127.0.0.11/32' ~# vtysh -c 'sh run' | grep access-list access-list 1 seq 10 permit 127.0.0.20/32 access-list 1 seq 11 permit 127.0.0.11/32 ~# vtysh -c 'c' -c 'no access-list 1 seq 10 permit 127.0.0.20/32' ~# vtysh -c 'sh run' | grep access-list access-list 1 seq 11 permit 127.0.0.11/32 ~# ``` Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
-rw-r--r--lib/filter.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/filter.c b/lib/filter.c
index 17ca4689f4..4a83b8b043 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -451,6 +451,7 @@ static void access_list_filter_delete(struct access_list *access,
struct filter *filter)
{
struct access_master *master;
+ struct filter *replace = filter;
master = access->master;
@@ -472,7 +473,7 @@ static void access_list_filter_delete(struct access_list *access,
(*master->delete_hook)(access);
/* If access_list becomes empty delete it from access_master. */
- if (access_list_empty(access))
+ if (access_list_empty(access) && !replace)
access_list_delete(access);
}