diff mbox series

[nft,05/10] evaluate: add flowtable to the cache

Message ID 20210415131330.6692-6-pablo@netfilter.org
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series cache updates | expand

Commit Message

Pablo Neira Ayuso April 15, 2021, 1:13 p.m. UTC
If the cache does not contain this flowtable that is defined in this
batch, then add it to the cache. This allows for references to this new
flowtable in the same batch.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/evaluate.c | 3 +++
 src/rule.c     | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/evaluate.c b/src/evaluate.c
index d0dfbabdf538..7b2d01c5dee1 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -3925,6 +3925,9 @@  static int flowtable_evaluate(struct eval_ctx *ctx, struct flowtable *ft)
 	if (table == NULL)
 		return table_not_found(ctx);
 
+	if (ft_cache_find(table, ft->handle.flowtable.name) == NULL)
+		ft_cache_add(flowtable_get(ft), table);
+
 	if (ft->hook.name) {
 		ft->hook.num = str2hooknum(NFPROTO_NETDEV, ft->hook.name);
 		if (ft->hook.num == NF_INET_NUMHOOKS)
diff --git a/src/rule.c b/src/rule.c
index 414e53e7d2f6..a6909fc75060 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -2247,7 +2247,7 @@  struct flowtable *flowtable_lookup_fuzzy(const char *ft_name,
 	string_misspell_init(&st);
 
 	list_for_each_entry(table, &cache->list, list) {
-		list_for_each_entry(ft, &table->flowtables, list) {
+		list_for_each_entry(ft, &table->cache_ft, cache_list) {
 			if (!strcmp(ft->handle.flowtable.name, ft_name)) {
 				*t = table;
 				return ft;