Blame SOURCES/0075-tests-py-add-dnat-to-port-without-defining-destinati.patch

96192c
From eeba2cd956485d3059dabf86a7ad8dd59ee682dd Mon Sep 17 00:00:00 2001
96192c
From: Phil Sutter <psutter@redhat.com>
96192c
Date: Fri, 4 Feb 2022 14:18:44 +0100
96192c
Subject: [PATCH] tests: py: add dnat to port without defining destination
96192c
 address
96192c
96192c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2030773
96192c
Upstream Status: nftables commit 0f27e258b37a5
96192c
Conflicts: Context changes due to missing commit ae1d822630e6d
96192c
           ("src: context tracking for multiple transport protocols")
96192c
96192c
commit 0f27e258b37a592233d6ad5381cd1fae65e57514
96192c
Author: Pablo Neira Ayuso <pablo@netfilter.org>
96192c
Date:   Thu Jul 22 17:43:56 2021 +0200
96192c
96192c
    tests: py: add dnat to port without defining destination address
96192c
96192c
    Add a test to cover dnat to port without destination address.
96192c
96192c
    Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1428
96192c
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
96192c
---
96192c
 tests/py/inet/dnat.t         |  1 +
96192c
 tests/py/inet/dnat.t.json    | 20 ++++++++++++++++++++
96192c
 tests/py/inet/dnat.t.payload |  8 ++++++++
96192c
 3 files changed, 29 insertions(+)
96192c
96192c
diff --git a/tests/py/inet/dnat.t b/tests/py/inet/dnat.t
96192c
index fcdf943..6beceda 100644
96192c
--- a/tests/py/inet/dnat.t
96192c
+++ b/tests/py/inet/dnat.t
96192c
@@ -6,6 +6,7 @@ iifname "foo" tcp dport 80 redirect to :8080;ok
96192c
 
96192c
 iifname "eth0" tcp dport 443 dnat ip to 192.168.3.2;ok
96192c
 iifname "eth0" tcp dport 443 dnat ip6 to [dead::beef]:4443;ok
96192c
+meta l4proto tcp dnat to :80;ok;meta l4proto 6 dnat to :80
96192c
 
96192c
 dnat ip to ct mark map { 0x00000014 : 1.2.3.4};ok
96192c
 dnat ip to ct mark . ip daddr map { 0x00000014 . 1.1.1.1 : 1.2.3.4};ok
96192c
diff --git a/tests/py/inet/dnat.t.json b/tests/py/inet/dnat.t.json
96192c
index ac6dac6..f88e9cf 100644
96192c
--- a/tests/py/inet/dnat.t.json
96192c
+++ b/tests/py/inet/dnat.t.json
96192c
@@ -164,3 +164,23 @@
96192c
     }
96192c
 ]
96192c
 
96192c
+# meta l4proto tcp dnat to :80
96192c
+[
96192c
+    {
96192c
+        "match": {
96192c
+            "left": {
96192c
+                "meta": {
96192c
+                    "key": "l4proto"
96192c
+                }
96192c
+            },
96192c
+            "op": "==",
96192c
+            "right": 6
96192c
+        }
96192c
+    },
96192c
+    {
96192c
+        "dnat": {
96192c
+            "port": 80
96192c
+        }
96192c
+    }
96192c
+]
96192c
+
96192c
diff --git a/tests/py/inet/dnat.t.payload b/tests/py/inet/dnat.t.payload
96192c
index b81caf7..6d8569d 100644
96192c
--- a/tests/py/inet/dnat.t.payload
96192c
+++ b/tests/py/inet/dnat.t.payload
96192c
@@ -52,3 +52,11 @@ inet test-inet prerouting
96192c
   [ payload load 4b @ network header + 16 => reg 9 ]
96192c
   [ lookup reg 1 set __map%d dreg 1 ]
96192c
   [ nat dnat ip addr_min reg 1 addr_max reg 0 ]
96192c
+
96192c
+# meta l4proto tcp dnat to :80
96192c
+inet
96192c
+  [ meta load l4proto => reg 1 ]
96192c
+  [ cmp eq reg 1 0x00000006 ]
96192c
+  [ immediate reg 1 0x00005000 ]
96192c
+  [ nat dnat inet proto_min reg 1 flags 0x2 ]
96192c
+
96192c
-- 
96192c
2.31.1
96192c