diff mbox series

[ovs-dev,3/5] controller: Fix deletion of container parent port.

Message ID 20240423115333.2796843-4-xsimonar@redhat.com
State Accepted
Delegated to: Numan Siddique
Headers show
Series Fix I+P versus recompute differences. | expand

Checks

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

Commit Message

Xavier Simonart April 23, 2024, 11:53 a.m. UTC
Flows were not properly removed when parent port of a container port
was deleted.

Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
---
 controller/binding.c  |  1 +
 controller/physical.c |  3 ++-
 tests/ovn.at          | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 1 deletion(-)

Comments

Numan Siddique May 30, 2024, 3:28 p.m. UTC | #1
On Tue, Apr 23, 2024 at 7:54 AM Xavier Simonart <xsimonar@redhat.com> wrote:
>
> Flows were not properly removed when parent port of a container port
> was deleted.
>
> Signed-off-by: Xavier Simonart <xsimonar@redhat.com>

Acked-by: Numan Siddique <numans@ovn.org>

Numan

> ---
>  controller/binding.c  |  1 +
>  controller/physical.c |  3 ++-
>  tests/ovn.at          | 34 ++++++++++++++++++++++++++++++++++
>  3 files changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/controller/binding.c b/controller/binding.c
> index 3b36ed881..1499ceae1 100644
> --- a/controller/binding.c
> +++ b/controller/binding.c
> @@ -2759,6 +2759,7 @@ handle_deleted_vif_lport(const struct sbrec_port_binding *pb,
>           * deleted 'pb' type is LP_VIF. */
>          struct binding_lport *c_lport;
>          LIST_FOR_EACH (c_lport, list_node, &lbinding->binding_lports) {
> +            remove_local_lports(c_lport->pb->logical_port, b_ctx_out);
>              if (!release_binding_lport(b_ctx_in->chassis_rec, c_lport,
>                                         !b_ctx_in->ovnsb_idl_txn,
>                                         b_ctx_out)) {
> diff --git a/controller/physical.c b/controller/physical.c
> index 7ee308694..98f7dbab2 100644
> --- a/controller/physical.c
> +++ b/controller/physical.c
> @@ -1026,7 +1026,8 @@ put_local_common_flows(uint32_t dp_key,
>          put_resubmit(OFTABLE_LOG_TO_PHY, ofpacts_p);
>          put_stack(MFF_IN_PORT, ofpact_put_STACK_POP(ofpacts_p));
>          ofctrl_check_and_add_flow_metered(flow_table, OFTABLE_SAVE_INPORT, 100,
> -                                          0, &match, ofpacts_p, hc_uuid,
> +                                          parent_pb->header_.uuid.parts[0],
> +                                          &match, ofpacts_p, &pb->header_.uuid,
>                                            NX_CTLR_NO_METER, NULL, false);
>      }
>  }
> diff --git a/tests/ovn.at b/tests/ovn.at
> index 3c888aaf5..b68678472 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -37794,3 +37794,37 @@ OVS_WAIT_FOR_OUTPUT([as hv1 ovs-ofctl dump-flows br-int table=0 |grep priority=1
>  OVN_CLEANUP([hv1])
>  AT_CLEANUP
>  ])
> +
> +OVN_FOR_EACH_NORTHD([
> +AT_SETUP([Delete parent of container port])
> +ovn_start
> +
> +ovn-nbctl ls-add ls0
> +ovn-nbctl lsp-add ls0 lsp0
> +
> +# Add a second logical port, so that deleting lsp0 does not result in deleting
> +# the last port of the datapath.
> +ovn-nbctl lsp-add ls0 lsp1
> +
> +check ovn-nbctl lsp-add ls0 lsp-cont1 lsp0 1
> +
> +net_add n1
> +
> +sim_add hv1
> +as hv1
> +ovs-vsctl add-br br-phys
> +ovn_attach n1 br-phys 192.168.0.1
> +
> +as hv1
> +ovs-vsctl -- add-port br-int vif \
> +          -- set Interface vif external-ids:iface-id=lsp0
> +ovs-vsctl -- add-port br-int vif1 \
> +          -- set Interface vif1 external-ids:iface-id=lsp1
> +
> +check ovn-nbctl --wait=hv lsp-del lsp0
> +CHECK_FLOWS_AFTER_RECOMPUTE([hv1], [hv1])
> +
> +OVN_CLEANUP([hv1])
> +
> +AT_CLEANUP
> +])
> --
> 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 3b36ed881..1499ceae1 100644
--- a/controller/binding.c
+++ b/controller/binding.c
@@ -2759,6 +2759,7 @@  handle_deleted_vif_lport(const struct sbrec_port_binding *pb,
          * deleted 'pb' type is LP_VIF. */
         struct binding_lport *c_lport;
         LIST_FOR_EACH (c_lport, list_node, &lbinding->binding_lports) {
+            remove_local_lports(c_lport->pb->logical_port, b_ctx_out);
             if (!release_binding_lport(b_ctx_in->chassis_rec, c_lport,
                                        !b_ctx_in->ovnsb_idl_txn,
                                        b_ctx_out)) {
diff --git a/controller/physical.c b/controller/physical.c
index 7ee308694..98f7dbab2 100644
--- a/controller/physical.c
+++ b/controller/physical.c
@@ -1026,7 +1026,8 @@  put_local_common_flows(uint32_t dp_key,
         put_resubmit(OFTABLE_LOG_TO_PHY, ofpacts_p);
         put_stack(MFF_IN_PORT, ofpact_put_STACK_POP(ofpacts_p));
         ofctrl_check_and_add_flow_metered(flow_table, OFTABLE_SAVE_INPORT, 100,
-                                          0, &match, ofpacts_p, hc_uuid,
+                                          parent_pb->header_.uuid.parts[0],
+                                          &match, ofpacts_p, &pb->header_.uuid,
                                           NX_CTLR_NO_METER, NULL, false);
     }
 }
diff --git a/tests/ovn.at b/tests/ovn.at
index 3c888aaf5..b68678472 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -37794,3 +37794,37 @@  OVS_WAIT_FOR_OUTPUT([as hv1 ovs-ofctl dump-flows br-int table=0 |grep priority=1
 OVN_CLEANUP([hv1])
 AT_CLEANUP
 ])
+
+OVN_FOR_EACH_NORTHD([
+AT_SETUP([Delete parent of container port])
+ovn_start
+
+ovn-nbctl ls-add ls0
+ovn-nbctl lsp-add ls0 lsp0
+
+# Add a second logical port, so that deleting lsp0 does not result in deleting
+# the last port of the datapath.
+ovn-nbctl lsp-add ls0 lsp1
+
+check ovn-nbctl lsp-add ls0 lsp-cont1 lsp0 1
+
+net_add n1
+
+sim_add hv1
+as hv1
+ovs-vsctl add-br br-phys
+ovn_attach n1 br-phys 192.168.0.1
+
+as hv1
+ovs-vsctl -- add-port br-int vif \
+          -- set Interface vif external-ids:iface-id=lsp0
+ovs-vsctl -- add-port br-int vif1 \
+          -- set Interface vif1 external-ids:iface-id=lsp1
+
+check ovn-nbctl --wait=hv lsp-del lsp0
+CHECK_FLOWS_AFTER_RECOMPUTE([hv1], [hv1])
+
+OVN_CLEANUP([hv1])
+
+AT_CLEANUP
+])