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

195495
From 00d3745306aa87eeb2466dbb5e6958225de3354f Mon Sep 17 00:00:00 2001
195495
From: Pablo Neira Ayuso <pablo@netfilter.org>
195495
Date: Thu, 22 Jul 2021 17:43:56 +0200
195495
Subject: [PATCH] tests: py: add dnat to port without defining destination
195495
 address
195495
195495
Add a test to cover dnat to port without destination address.
195495
195495
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1428
195495
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
195495
(cherry picked from commit 0f27e258b37a592233d6ad5381cd1fae65e57514)
195495
---
195495
 tests/py/inet/dnat.t         |  1 +
195495
 tests/py/inet/dnat.t.json    | 20 ++++++++++++++++++++
195495
 tests/py/inet/dnat.t.payload |  7 +++++++
195495
 3 files changed, 28 insertions(+)
195495
195495
diff --git a/tests/py/inet/dnat.t b/tests/py/inet/dnat.t
195495
index b460af3925570..e4e169f2bc3ec 100644
195495
--- a/tests/py/inet/dnat.t
195495
+++ b/tests/py/inet/dnat.t
195495
@@ -6,6 +6,7 @@ iifname "foo" tcp dport 80 redirect to :8080;ok
195495
 
195495
 iifname "eth0" tcp dport 443 dnat ip to 192.168.3.2;ok
195495
 iifname "eth0" tcp dport 443 dnat ip6 to [dead::beef]:4443;ok
195495
+meta l4proto tcp dnat to :80;ok;meta l4proto 6 dnat to :80
195495
 
195495
 dnat ip to ct mark map { 0x00000014 : 1.2.3.4};ok
195495
 dnat ip to ct mark . ip daddr map { 0x00000014 . 1.1.1.1 : 1.2.3.4};ok
195495
diff --git a/tests/py/inet/dnat.t.json b/tests/py/inet/dnat.t.json
195495
index 1b8aba6297d36..c341a0455fea1 100644
195495
--- a/tests/py/inet/dnat.t.json
195495
+++ b/tests/py/inet/dnat.t.json
195495
@@ -219,3 +219,23 @@
195495
     }
195495
 ]
195495
 
195495
+# meta l4proto tcp dnat to :80
195495
+[
195495
+    {
195495
+        "match": {
195495
+            "left": {
195495
+                "meta": {
195495
+                    "key": "l4proto"
195495
+                }
195495
+            },
195495
+            "op": "==",
195495
+            "right": 6
195495
+        }
195495
+    },
195495
+    {
195495
+        "dnat": {
195495
+            "port": 80
195495
+        }
195495
+    }
195495
+]
195495
+
195495
diff --git a/tests/py/inet/dnat.t.payload b/tests/py/inet/dnat.t.payload
195495
index a741b9cbdb8d7..be5baf8fd4b47 100644
195495
--- a/tests/py/inet/dnat.t.payload
195495
+++ b/tests/py/inet/dnat.t.payload
195495
@@ -77,3 +77,10 @@ inet
195495
   [ immediate reg 2 0x00005000 ]
195495
   [ nat dnat ip addr_min reg 1 addr_max reg 0 proto_min reg 2 proto_max reg 0 flags 0x2 ]
195495
 
195495
+# meta l4proto tcp dnat to :80
195495
+inet
195495
+  [ meta load l4proto => reg 1 ]
195495
+  [ cmp eq reg 1 0x00000006 ]
195495
+  [ immediate reg 1 0x00005000 ]
195495
+  [ nat dnat inet proto_min reg 1 flags 0x2 ]
195495
+
195495
-- 
195495
2.34.1
195495