diff mbox series

[ovs-dev] binding: fix missing localnet for local datapath

Message ID 20220819154426.1099473-1-xsimonar@redhat.com
State Superseded
Headers show
Series [ovs-dev] binding: fix missing localnet for local datapath | expand

Checks

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

Commit Message

Xavier Simonart Aug. 19, 2022, 3:44 p.m. UTC
When a lrp option is set to always-redirect=false ("bridged"
redirect type), local datapaths are properly updated.
However, in some cases, when I+P is used, localnet ports
attached to those datapaths were not properly updated.
This results in missing flows and packets not going trough.

This issue was catched by random failures in test case
"Stateless Floating IP".

Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
---
 controller/binding.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Comments

Han Zhou Aug. 22, 2022, 5:48 a.m. UTC | #1
On Fri, Aug 19, 2022 at 8:44 AM Xavier Simonart <xsimonar@redhat.com> wrote:
>
> When a lrp option is set to always-redirect=false ("bridged"
> redirect type), local datapaths are properly updated.
> However, in some cases, when I+P is used, localnet ports
> attached to those datapaths were not properly updated.
> This results in missing flows and packets not going trough.
>
> This issue was catched by random failures in test case
> "Stateless Floating IP".
>
> Signed-off-by: Xavier Simonart <xsimonar@redhat.com>

Thanks Xavier!
Should this be fixed by
https://github.com/ovn-org/ovn/commit/50b3af8938c93491d429dcabe8f9902f0aa43426
already?

Han

> ---
>  controller/binding.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
>
> diff --git a/controller/binding.c b/controller/binding.c
> index 9f5393a92..2722b87b7 100644
> --- a/controller/binding.c
> +++ b/controller/binding.c
> @@ -2574,6 +2574,31 @@ consider_patch_port_for_local_datapaths(const
struct sbrec_port_binding *pb,
>      }
>  }
>
> +static void
> +update_ld_ports(struct binding_ctx_in *b_ctx_in,
> +                struct binding_ctx_out *b_ctx_out)
> +{
> +    const struct sbrec_port_binding *pb;
> +    SBREC_PORT_BINDING_TABLE_FOR_EACH (pb,
> +                                       b_ctx_in->port_binding_table) {
> +        enum en_lport_type lport_type = get_lport_type(pb);
> +        if (lport_type == LP_LOCALNET) {
> +            struct shash bridge_mappings =
> +                SHASH_INITIALIZER(&bridge_mappings);
> +            add_ovs_bridge_mappings(b_ctx_in->ovs_table,
> +                                    b_ctx_in->bridge_table,
> +                                    &bridge_mappings);
> +            update_ld_localnet_port(pb, &bridge_mappings,
> +                                    b_ctx_out->egress_ifaces,
> +                                    b_ctx_out->local_datapaths);
> +            shash_destroy(&bridge_mappings);
> +        } else if (lport_type == LP_EXTERNAL) {
> +            update_ld_external_ports(pb, b_ctx_out->local_datapaths);
> +        }
> +    }
> +}
> +
> +
>  static bool
>  handle_updated_port(struct binding_ctx_in *b_ctx_in,
>                      struct binding_ctx_out *b_ctx_out,
> @@ -2671,6 +2696,14 @@ handle_updated_port(struct binding_ctx_in
*b_ctx_in,
>          }
>          consider_patch_port_for_local_datapaths(distributed_pb, b_ctx_in,
>                                                  b_ctx_out);
> +        /* If option always-redirect has changed, check if localnet
should
> +         * be updated
> +         */
> +        if (sbrec_port_binding_is_updated(pb,
> +
 SBREC_PORT_BINDING_COL_OPTIONS)) {
> +            update_ld_ports(b_ctx_in, b_ctx_out);
> +        }
> +
>          break;
>
>      case LP_EXTERNAL:
> --
> 2.31.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff mbox series

Patch

diff --git a/controller/binding.c b/controller/binding.c
index 9f5393a92..2722b87b7 100644
--- a/controller/binding.c
+++ b/controller/binding.c
@@ -2574,6 +2574,31 @@  consider_patch_port_for_local_datapaths(const struct sbrec_port_binding *pb,
     }
 }
 
+static void
+update_ld_ports(struct binding_ctx_in *b_ctx_in,
+                struct binding_ctx_out *b_ctx_out)
+{
+    const struct sbrec_port_binding *pb;
+    SBREC_PORT_BINDING_TABLE_FOR_EACH (pb,
+                                       b_ctx_in->port_binding_table) {
+        enum en_lport_type lport_type = get_lport_type(pb);
+        if (lport_type == LP_LOCALNET) {
+            struct shash bridge_mappings =
+                SHASH_INITIALIZER(&bridge_mappings);
+            add_ovs_bridge_mappings(b_ctx_in->ovs_table,
+                                    b_ctx_in->bridge_table,
+                                    &bridge_mappings);
+            update_ld_localnet_port(pb, &bridge_mappings,
+                                    b_ctx_out->egress_ifaces,
+                                    b_ctx_out->local_datapaths);
+            shash_destroy(&bridge_mappings);
+        } else if (lport_type == LP_EXTERNAL) {
+            update_ld_external_ports(pb, b_ctx_out->local_datapaths);
+        }
+    }
+}
+
+
 static bool
 handle_updated_port(struct binding_ctx_in *b_ctx_in,
                     struct binding_ctx_out *b_ctx_out,
@@ -2671,6 +2696,14 @@  handle_updated_port(struct binding_ctx_in *b_ctx_in,
         }
         consider_patch_port_for_local_datapaths(distributed_pb, b_ctx_in,
                                                 b_ctx_out);
+        /* If option always-redirect has changed, check if localnet should
+         * be updated
+         */
+        if (sbrec_port_binding_is_updated(pb,
+                                          SBREC_PORT_BINDING_COL_OPTIONS)) {
+            update_ld_ports(b_ctx_in, b_ctx_out);
+        }
+
         break;
 
     case LP_EXTERNAL: