5f9769
From 0ec31292fc29d2c111927382b13ea8af0499f6ac Mon Sep 17 00:00:00 2001
5f9769
From: Dumitru Ceara <dceara@redhat.com>
5f9769
Date: Wed, 6 Jan 2021 11:53:14 +0100
5f9769
Subject: [PATCH] binding: Do not clear container lbinding->pb when parent is
5f9769
 deleted.
5f9769
5f9769
When a parent Port_Binding is deleted we shouldn't clear the children's
5f9769
'pb' field.  Container port bindings have their own Port_Binding SB
5f9769
record so the child_lbinding->pb field should be cleared only when
5f9769
their corresponding SB record is deleted.
5f9769
5f9769
Whithout this fix when a parent Port_Binding "remove" followed by "add"
5f9769
operations are received in the same iteration in ovn-controller,
5f9769
consider_container_lport() can be called with "pb == NULL" causing a
5f9769
crash.
5f9769
5f9769
Fixes: 354bdba51abf ("ovn-controller: I-P for SB port binding and OVS interface in runtime_data.")
5f9769
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
5f9769
Signed-off-by: Numan Siddique <numans@ovn.org>
5f9769
5f9769
(cherry-picked from master commit d3245f69dd6ec613ceb193f728946f7e3b9b3de3)
5f9769
---
5f9769
 controller/binding.c | 3 +--
5f9769
 tests/ovn.at         | 7 +++++++
5f9769
 2 files changed, 8 insertions(+), 2 deletions(-)
5f9769
5f9769
diff --git a/controller/binding.c b/controller/binding.c
5f9769
index cb60c5d..e632203 100644
5f9769
--- a/controller/binding.c
5f9769
+++ b/controller/binding.c
5f9769
@@ -958,8 +958,7 @@ release_local_binding_children(const struct sbrec_chassis *chassis_rec,
5f9769
             }
5f9769
         }
5f9769
 
5f9769
-        /* Clear the local bindings' 'pb' and 'iface'. */
5f9769
-        l->pb = NULL;
5f9769
+        /* Clear the local bindings' 'iface'. */
5f9769
         l->iface = NULL;
5f9769
     }
5f9769
 
5f9769
diff --git a/tests/ovn.at b/tests/ovn.at
5f9769
index 8bcfcdf..ce6db86 100644
5f9769
--- a/tests/ovn.at
5f9769
+++ b/tests/ovn.at
5f9769
@@ -9126,6 +9126,13 @@ OVS_WAIT_UNTIL([test xup = x$(ovn-nbctl lsp-get-up vm1)])
5f9769
 OVS_WAIT_UNTIL([test xup = x$(ovn-nbctl lsp-get-up foo1)])
5f9769
 OVS_WAIT_UNTIL([test xup = x$(ovn-nbctl lsp-get-up bar1)])
5f9769
 
5f9769
+# Move VM1 to a new logical switch.
5f9769
+ovn-nbctl ls-add mgmt2
5f9769
+ovn-nbctl lsp-del vm1 -- lsp-add mgmt2 vm1
5f9769
+OVS_WAIT_UNTIL([test xup = x$(ovn-nbctl lsp-get-up vm1)])
5f9769
+OVS_WAIT_UNTIL([test xup = x$(ovn-nbctl lsp-get-up foo1)])
5f9769
+OVS_WAIT_UNTIL([test xup = x$(ovn-nbctl lsp-get-up bar1)])
5f9769
+
5f9769
 as hv1 ovs-vsctl del-port vm1
5f9769
 OVS_WAIT_UNTIL([test xdown = x$(ovn-nbctl lsp-get-up vm1)])
5f9769
 OVS_WAIT_UNTIL([test xdown = x$(ovn-nbctl lsp-get-up foo1)])
5f9769
-- 
5f9769
1.8.3.1
5f9769