diff mbox

[nft,1/2] rule: Introduce helper function cache_flush

Message ID 311a646975862ca11499066a4392683ad2265c43.1480587885.git.anatole@rezel.net
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

Anatole Denis Dec. 1, 2016, 10:50 a.m. UTC
cache_release empties the cache, and marks it as uninitialized. Add cache_flush,
which does the same, except it keeps the cache initialized, eg. after a "nft
flush ruleset" when empty is the correct state of the cache.

Signed-off-by: Anatole Denis <anatole@rezel.net>
---
 include/rule.h | 1 +
 src/rule.c     | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Pablo Neira Ayuso Dec. 1, 2016, 11:41 a.m. UTC | #1
On Thu, Dec 01, 2016 at 11:50:16AM +0100, Anatole Denis wrote:
> cache_release empties the cache, and marks it as uninitialized. Add cache_flush,
> which does the same, except it keeps the cache initialized, eg. after a "nft
> flush ruleset" when empty is the correct state of the cache.

Applied, thanks Anatole.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/rule.h b/include/rule.h
index 99e92ee..b9b4a19 100644
--- a/include/rule.h
+++ b/include/rule.h
@@ -422,6 +422,7 @@  struct netlink_ctx;
 extern int do_command(struct netlink_ctx *ctx, struct cmd *cmd);
 
 extern int cache_update(enum cmd_ops cmd, struct list_head *msgs);
+extern void cache_flush(void);
 extern void cache_release(void);
 
 enum udata_type {
diff --git a/src/rule.c b/src/rule.c
index 8c58bfa..8710767 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -157,7 +157,7 @@  replay:
 	return 0;
 }
 
-void cache_release(void)
+void cache_flush(void)
 {
 	struct table *table, *next;
 
@@ -165,6 +165,11 @@  void cache_release(void)
 		list_del(&table->list);
 		table_free(table);
 	}
+}
+
+void cache_release(void)
+{
+	cache_flush();
 	cache_initialized = false;
 }