On 12/9/21 12:16, Lorenzo Bianconi wrote:
> 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 <lorenzo.bianc...@redhat.com>
> ---
> Changes since v1:
> - use next_ct_state() and do not access ct state directly
> ---

Hi Lorenzo,

Thanks for v2, I have one more comment below.

Regards,
Dumitru

>  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);
> +        }

We should skip the "if" and always call next_ct_state(); it will add a
comment if there are not enough ct states specified:

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);
>  }
>  
> 

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to