From: Pablo Neira Ayuso Date: Sun, 18 Mar 2018 20:31:29 +0000 (+0100) Subject: rule: reset cache iff there is an existing cache X-Git-Tag: v0.8.4~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aba100e593f28105be300dc888935fad5dc822f;p=thirdparty%2Fnftables.git rule: reset cache iff there is an existing cache If genid is unset, then do not reset existing cache. In the kernel, generation ID is assumed to be always != zero. This patch fixes: nft 'add table x; add chain x y;' that allow us to send several commands in one single batch from the command line. Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/rule.c b/src/rule.c index 4334efac..c6560036 100644 --- a/src/rule.c +++ b/src/rule.c @@ -165,7 +165,9 @@ replay: genid = netlink_genid_get(&ctx); if (genid && genid == cache->genid) return 0; - cache_release(cache); + if (cache->genid) + cache_release(cache); + ret = cache_init(&ctx, cmd); if (ret < 0) { cache_release(cache);