]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
rule: reset cache iff there is an existing cache
authorPablo Neira Ayuso <pablo@netfilter.org>
Sun, 18 Mar 2018 20:31:29 +0000 (21:31 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 19 Mar 2018 09:21:37 +0000 (10:21 +0100)
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 <pablo@netfilter.org>
src/rule.c

index 4334efacbbdf7034ab877889b8203c1213a4d658..c65600364e7d49a8da93fce8ffafa8e4c3b00791 100644 (file)
@@ -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);