]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink_delinearize: do not reset protocol context for nat protocol expression
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 4 Apr 2023 13:34:05 +0000 (15:34 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 5 Apr 2023 13:57:17 +0000 (15:57 +0200)
This patch reverts 403b46ada490 ("netlink_delinearize: kill dependency
before eval of 'redirect' stmt"). Since ("evaluate: bogus missing
transport protocol"), this workaround is not required anymore.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink_delinearize.c
tests/py/ip/redirect.t
tests/py/ip/redirect.t.json
tests/py/ip/redirect.t.payload
tests/py/ip6/redirect.t
tests/py/ip6/redirect.t.json
tests/py/ip6/redirect.t.payload.ip6

index fd166eb15c011caa8e77ae32eb848ecde8abd904..935a6667a1c7c87caf5a9558d6cae8cc94954c89 100644 (file)
@@ -3375,10 +3375,8 @@ static void rule_parse_postprocess(struct netlink_parse_ctx *ctx, struct rule *r
                case STMT_NAT:
                        if (stmt->nat.addr != NULL)
                                expr_postprocess(&rctx, &stmt->nat.addr);
-                       if (stmt->nat.proto != NULL) {
-                               payload_dependency_reset(&dl->pdctx);
+                       if (stmt->nat.proto != NULL)
                                expr_postprocess(&rctx, &stmt->nat.proto);
-                       }
                        break;
                case STMT_TPROXY:
                        if (stmt->tproxy.addr)
index d2991ce288b0677861d1ade95a984c1f1059eb2e..8c2b52f0441540bdd426f332516a41d9724bca04 100644 (file)
@@ -47,5 +47,5 @@ ip daddr 10.0.0.0-10.2.3.4 udp dport 53 counter redirect;ok
 iifname "eth0" ct state established,new tcp dport vmap {22 : drop, 222 : drop } redirect;ok
 
 # redirect with maps
-ip protocol 6 redirect to :tcp dport map { 22 : 8000, 80 : 8080};ok
+redirect to :tcp dport map { 22 : 8000, 80 : 8080};ok
 
index 3544e7f1b9c5d1039a35b3fe7a9d41317eae88d3..2afdf9b13e888c13179289b82ffa6da6fad4e550 100644 (file)
     }
 ]
 
-# ip protocol 6 redirect to :tcp dport map { 22 : 8000, 80 : 8080}
+# redirect to :tcp dport map { 22 : 8000, 80 : 8080}
 [
-    {
-        "match": {
-            "left": {
-                "payload": {
-                    "field": "protocol",
-                    "protocol": "ip"
-                }
-            },
-           "op": "==",
-            "right": 6
-        }
-    },
     {
         "redirect": {
             "port": {
index 424ad7b4f7ec0e2558ce095ed9e07261572f707c..4bed47c18ef94396deb79b08bd386e75004b71d3 100644 (file)
@@ -207,12 +207,12 @@ ip test-ip4 output
   [ lookup reg 1 set __map%d dreg 0 ]
   [ redir ]
 
-# ip protocol 6 redirect to :tcp dport map { 22 : 8000, 80 : 8080}
+# redirect to :tcp dport map { 22 : 8000, 80 : 8080}
 __map%d test-ip4 b
 __map%d test-ip4 0
         element 00001600  : 0000401f 0 [end]    element 00005000  : 0000901f 0 [end]
 ip test-ip4 output
-  [ payload load 1b @ network header + 9 => reg 1 ]
+  [ meta load l4proto => reg 1 ]
   [ cmp eq reg 1 0x00000006 ]
   [ payload load 2b @ transport header + 2 => reg 1 ]
   [ lookup reg 1 set __map%d dreg 1 ]
index 778d53f33ce6e0a112a3a1bb14f589b1b489b020..70ef7f9f14f6d89d17a7bc36d44001a08af03931 100644 (file)
@@ -46,4 +46,4 @@ ip6 daddr fe00::1-fe00::200 udp dport 53 counter redirect;ok
 iifname "eth0" ct state established,new tcp dport vmap {22 : drop, 222 : drop } redirect;ok
 
 # redirect with maps
-ip6 nexthdr 6 redirect to :tcp dport map { 22 : 8000, 80 : 8080};ok
+redirect to :tcp dport map { 22 : 8000, 80 : 8080};ok
index 0059c7accc06b8c5ba8fea66add45654cd43707c..c18223fa7a5b532d1ab660d0b799aa6895da3705 100644 (file)
     }
 ]
 
-# ip6 nexthdr 6 redirect to :tcp dport map { 22 : 8000, 80 : 8080}
+# redirect to :tcp dport map { 22 : 8000, 80 : 8080}
 [
-    {
-        "match": {
-            "left": {
-                "payload": {
-                    "field": "nexthdr",
-                    "protocol": "ip6"
-                }
-            },
-           "op": "==",
-            "right": 6
-        }
-    },
     {
         "redirect": {
             "port": {
index e9a20316148568b1b7db79cab32e4b3cd08b0840..cfc290137f923f5ff5d7365427e5c5cecbc90657 100644 (file)
@@ -191,12 +191,12 @@ ip6 test-ip6 output
   [ lookup reg 1 set __map%d dreg 0 ]
   [ redir ]
 
-# ip6 nexthdr 6 redirect to :tcp dport map { 22 : 8000, 80 : 8080}
+# redirect to :tcp dport map { 22 : 8000, 80 : 8080}
 __map%d test-ip6 b
 __map%d test-ip6 0
        element 00001600  : 0000401f 0 [end]    element 00005000  : 0000901f 0 [end]
 ip6 test-ip6 output
-  [ payload load 1b @ network header + 6 => reg 1 ]
+  [ meta load l4proto => reg 1 ]
   [ cmp eq reg 1 0x00000006 ]
   [ payload load 2b @ transport header + 2 => reg 1 ]
   [ lookup reg 1 set __map%d dreg 1 ]