]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
scanner: allow prefix in ip6 scope
authorFlorian Westphal <fw@strlen.de>
Wed, 6 Jul 2022 21:49:21 +0000 (23:49 +0200)
committerFlorian Westphal <fw@strlen.de>
Wed, 6 Jul 2022 22:31:29 +0000 (00:31 +0200)
'ip6 prefix' is valid syntax, so make sure scanner recognizes it
also in ip6 context.

Also add test case.

Fixes: a67fce7ffe7e ("scanner: nat: Move to own scope")
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1619
Signed-off-by: Florian Westphal <fw@strlen.de>
src/scanner.l
tests/shell/testcases/sets/0046netmap_0
tests/shell/testcases/sets/dumps/0046netmap_0.nft

index 5741261a690aa562d77e84b7183b91a2e672f83a..1371cd044b65a14c95ca08d55ef1134c0f9e184c 100644 (file)
@@ -403,7 +403,7 @@ addrstring  ({macaddr}|{ip4addr}|{ip6addr})
 }
 
 "log"                  { scanner_push_start_cond(yyscanner, SCANSTATE_STMT_LOG); return LOG; }
-<SCANSTATE_STMT_LOG,SCANSTATE_STMT_NAT,SCANSTATE_IP>"prefix"           { return PREFIX; }
+<SCANSTATE_STMT_LOG,SCANSTATE_STMT_NAT,SCANSTATE_IP,SCANSTATE_IP6>"prefix"             { return PREFIX; }
 <SCANSTATE_STMT_LOG>{
        "snaplen"               { return SNAPLEN; }
        "queue-threshold"       { return QUEUE_THRESHOLD; }
index 2804a4a27edecd143d949fc67dc4f422f85d84c7..60bda4017c5999f11bc1956a40290850d4077ad9 100755 (executable)
@@ -8,6 +8,12 @@ EXPECTED="table ip x {
                                                     10.141.13.0/24 : 192.168.4.0/24 }
             }
      }
+     table ip6 x {
+            chain y {
+                    type nat hook postrouting priority srcnat; policy accept;
+                    snat ip6 prefix to ip6 saddr map { 2001:db8:1111::/64 : 2001:db8:2222::/64 }
+            }
+     }
 "
 
 set -e
index e14c3395431378d7bf843aa9acf204754b77ad91..5ac6b346d5be5cc546addaf43172eaed2a39e8da 100644 (file)
@@ -4,3 +4,9 @@ table ip x {
                snat ip prefix to ip saddr map { 10.141.11.0/24 : 192.168.2.0/24, 10.141.12.0/24 : 192.168.3.0/24, 10.141.13.0/24 : 192.168.4.0/24 }
        }
 }
+table ip6 x {
+       chain y {
+               type nat hook postrouting priority srcnat; policy accept;
+               snat ip6 prefix to ip6 saddr map { 2001:db8:1111::/64 : 2001:db8:2222::/64 }
+       }
+}