diff mbox series

[ovs-dev] ovn-trace: honor ct state in execute_ct_lb

Message ID e41f5799af7d1f84c804830184c6f05c790c7965.1638393565.git.lorenzo.bianconi@redhat.com
State Changes Requested
Headers show
Series [ovs-dev] ovn-trace: honor ct state in execute_ct_lb | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_ovn-kubernetes success github build: passed
ovsrobot/github-robot-_Build_and_Test fail github build: failed

Commit Message

Lorenzo Bianconi Dec. 1, 2021, 10:18 p.m. UTC
When performing CT_LB action in ovn-trace, take into account current
connection tracking state provided by the user.

Related bz: https://bugzilla.redhat.com/show_bug.cgi?id=1980702

Fixes: 8accd26cb2 ("OVN: add CT_LB action to ovn-trace")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 tests/ovn-northd.at   | 56 ++++++++++++++++++++++++++++++++++++-------
 utilities/ovn-trace.c |  3 +++
 2 files changed, 51 insertions(+), 8 deletions(-)

Comments

Dumitru Ceara Dec. 8, 2021, 1:37 p.m. UTC | #1
Hi Lorenzo,

On 12/1/21 23:18, Lorenzo Bianconi wrote:
> When performing CT_LB action in ovn-trace, take into account current
> connection tracking state provided by the user.
> 
> Related bz: https://bugzilla.redhat.com/show_bug.cgi?id=1980702

The formal tag is "Reported-at:".  It's actually also what our
downstream tools search for.

> 
> Fixes: 8accd26cb2 ("OVN: add CT_LB action to ovn-trace")
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> ---
>  tests/ovn-northd.at   | 56 ++++++++++++++++++++++++++++++++++++-------
>  utilities/ovn-trace.c |  3 +++
>  2 files changed, 51 insertions(+), 8 deletions(-)
> 
> diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
> index f03d14082..1655c8e80 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..419849f64 100644
> --- a/utilities/ovn-trace.c
> +++ b/utilities/ovn-trace.c
> @@ -2404,6 +2404,9 @@ 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 |= ct_states[ct_state_idx];
> +        }

It's better to use next_ct_state() which will take care of incrementing
the ct_state_idx, something like:

ct_lb_flow.ct_state |= next_ct_state(&comment);

>      }
>  
>      struct ovntrace_node *node = ovntrace_node_append(
> 

Here we could append the comment to the trace node:

struct ovntrace_node *node = ovntrace_node_append(
    super, OVNTRACE_NODE_TRANSFORMATION, "ct_lb%s",
    ds_cstr_ro(&comment));

Thanks,
Dumitru
diff mbox series

Patch

diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index f03d14082..1655c8e80 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..419849f64 100644
--- a/utilities/ovn-trace.c
+++ b/utilities/ovn-trace.c
@@ -2404,6 +2404,9 @@  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 |= ct_states[ct_state_idx];
+        }
     }
 
     struct ovntrace_node *node = ovntrace_node_append(