]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
libnftables: release top level scope
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 17 Jun 2022 17:33:53 +0000 (19:33 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 23 Jun 2022 17:00:02 +0000 (19:00 +0200)
Otherwise bogus variable redefinition are reported via -o/--optimize:

  redefinition.conf:5:8-21: Error: redefinition of symbol 'interface_inet'
  define interface_inet = enp5s0
         ^^^^^^^^^^^^^^

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/libnftables.c
tests/shell/testcases/optimizations/variables [new file with mode: 0755]

index aac682b706ffabc857b717135ceb85f236a25901..f2a1ef04e80b05a61f82ddc2dd05350c7a0e6964 100644 (file)
@@ -708,6 +708,8 @@ err:
        if (rc)
                nft_cache_release(&nft->cache);
 
+       scope_release(nft->state->scopes[0]);
+
        return rc;
 }
 
diff --git a/tests/shell/testcases/optimizations/variables b/tests/shell/testcases/optimizations/variables
new file mode 100755 (executable)
index 0000000..fa98606
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+
+RULESET="define addrv4_vpnnet = 10.1.0.0/16
+
+table ip nat {
+    chain postrouting {
+        type nat hook postrouting priority 0; policy accept;
+
+        ip saddr \$addrv4_vpnnet counter masquerade fully-random comment \"masquerade ipv4\"
+    }
+}"
+
+$NFT -c -o -f - <<< $RULESET