When performing CT_LB action in ovn-trace, take into account current
connection tracking state provided by the user.

Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1980702
Fixes: 8accd26cb2 ("OVN: add CT_LB action to ovn-trace")
Signed-off-by: Lorenzo Bianconi <[email protected]>
---
Changes since v1:
- use next_ct_state() and do not access ct state directly
---
 tests/ovn-northd.at   | 56 ++++++++++++++++++++++++++++++++++++-------
 utilities/ovn-trace.c |  8 ++++++-
 2 files changed, 55 insertions(+), 9 deletions(-)

diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index c4424ab14..8c14bc76a 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -2916,7 +2916,12 @@ AT_CHECK_UNQUOTED([ovn-trace --ct new --ct new --minimal 
ls "${flow}"], [0], [dn
 # 
tcp,reg14=0x${lsp1_inport},vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=42.42.42.1,nw_dst=66.66.66.66,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=80,tcp_flags=0
 ct_lb {
     ct_lb {
-        output("lsp2");
+        reg0[[6]] = 0;
+        *** chk_lb_hairpin_reply action not implemented;
+        reg0[[12]] = 0;
+        ct_lb {
+            output("lsp2");
+        };
     };
 };
 ])
@@ -2927,7 +2932,12 @@ AT_CHECK_UNQUOTED([ovn-trace --ct new --ct new --minimal 
ls "${flow}"], [0], [dn
 # 
udp,reg14=0x${lsp1_inport},vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=42.42.42.1,nw_dst=66.66.66.66,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=80
 ct_lb {
     ct_lb {
-        output("lsp2");
+        reg0[[6]] = 0;
+        *** chk_lb_hairpin_reply action not implemented;
+        reg0[[12]] = 0;
+        ct_lb {
+            output("lsp2");
+        };
     };
 };
 ])
@@ -2944,7 +2954,12 @@ AT_CHECK_UNQUOTED([ovn-trace --ct new --ct new --minimal 
ls "${flow}"], [0], [dn
 # 
tcp,reg14=0x${lsp1_inport},vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=42.42.42.1,nw_dst=66.66.66.66,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=80,tcp_flags=0
 ct_lb {
     ct_lb {
-        output("lsp2");
+        reg0[[6]] = 0;
+        *** chk_lb_hairpin_reply action not implemented;
+        reg0[[12]] = 0;
+        ct_lb {
+            output("lsp2");
+        };
     };
 };
 ])
@@ -2955,7 +2970,12 @@ AT_CHECK_UNQUOTED([ovn-trace --ct new --ct new --minimal 
ls "${flow}"], [0], [dn
 # 
udp,reg14=0x${lsp1_inport},vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=42.42.42.1,nw_dst=66.66.66.66,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=80
 ct_lb {
     ct_lb {
-        output("lsp2");
+        reg0[[6]] = 0;
+        *** chk_lb_hairpin_reply action not implemented;
+        reg0[[12]] = 0;
+        ct_lb {
+            output("lsp2");
+        };
     };
 };
 ])
@@ -3052,7 +3072,12 @@ AT_CHECK_UNQUOTED([ovn-trace --ct new --ct new --minimal 
ls "${flow}"], [0], [dn
 # 
tcp,reg14=0x${lsp1_inport},vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=42.42.42.1,nw_dst=66.66.66.66,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=80,tcp_flags=0
 ct_lb {
     ct_lb {
-        output("lsp2");
+        reg0[[6]] = 0;
+        *** chk_lb_hairpin_reply action not implemented;
+        reg0[[12]] = 0;
+        ct_lb {
+            output("lsp2");
+        };
     };
 };
 ])
@@ -3063,7 +3088,12 @@ AT_CHECK_UNQUOTED([ovn-trace --ct new --ct new --minimal 
ls "${flow}"], [0], [dn
 # 
udp,reg14=0x${lsp1_inport},vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=42.42.42.1,nw_dst=66.66.66.66,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=80
 ct_lb {
     ct_lb {
-        output("lsp2");
+        reg0[[6]] = 0;
+        *** chk_lb_hairpin_reply action not implemented;
+        reg0[[12]] = 0;
+        ct_lb {
+            output("lsp2");
+        };
     };
 };
 ])
@@ -3080,7 +3110,12 @@ AT_CHECK_UNQUOTED([ovn-trace --ct new --ct new --minimal 
ls "${flow}"], [0], [dn
 # 
tcp,reg14=0x${lsp1_inport},vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=42.42.42.1,nw_dst=66.66.66.66,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=80,tcp_flags=0
 ct_lb {
     ct_lb {
-        output("lsp2");
+        reg0[[6]] = 0;
+        *** chk_lb_hairpin_reply action not implemented;
+        reg0[[12]] = 0;
+        ct_lb {
+            output("lsp2");
+        };
     };
 };
 ])
@@ -3091,7 +3126,12 @@ AT_CHECK_UNQUOTED([ovn-trace --ct new --ct new --minimal 
ls "${flow}"], [0], [dn
 # 
udp,reg14=0x${lsp1_inport},vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,nw_src=42.42.42.1,nw_dst=66.66.66.66,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=80
 ct_lb {
     ct_lb {
-        output("lsp2");
+        reg0[[6]] = 0;
+        *** chk_lb_hairpin_reply action not implemented;
+        reg0[[12]] = 0;
+        ct_lb {
+            output("lsp2");
+        };
     };
 };
 ])
diff --git a/utilities/ovn-trace.c b/utilities/ovn-trace.c
index 617ad834c..e99202da6 100644
--- a/utilities/ovn-trace.c
+++ b/utilities/ovn-trace.c
@@ -2351,6 +2351,7 @@ execute_ct_lb(const struct ovnact_ct_lb *ct_lb,
               const struct ovntrace_datapath *dp, struct flow *uflow,
               enum ovnact_pipeline pipeline, struct ovs_list *super)
 {
+    struct ds comment = DS_EMPTY_INITIALIZER;
     struct flow ct_lb_flow = *uflow;
 
     int family = (ct_lb_flow.dl_type == htons(ETH_TYPE_IP) ? AF_INET
@@ -2404,10 +2405,15 @@ execute_ct_lb(const struct ovnact_ct_lb *ct_lb,
             }
             ct_lb_flow.ct_state |= CS_DST_NAT;
         }
+        if (ct_state_idx < n_ct_states) {
+            ct_lb_flow.ct_state |= next_ct_state(&comment);
+        }
     }
 
     struct ovntrace_node *node = ovntrace_node_append(
-        super, OVNTRACE_NODE_TRANSFORMATION, "ct_lb");
+        super, OVNTRACE_NODE_TRANSFORMATION, "ct_lb%s",
+        ds_cstr_ro(&comment));
+    ds_destroy(&comment);
     trace__(dp, &ct_lb_flow, ct_lb->ltable, pipeline, &node->subs);
 }
 
-- 
2.31.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to