Blob Blame History Raw
From d4bca93c0851c2f0b739411cd49ce32e3b8263bb Mon Sep 17 00:00:00 2001
From: Numan Siddique <numans@ovn.org>
Date: Sat, 21 Aug 2021 00:41:07 -0400
Subject: [PATCH 3/4] controller: Don't allocate zone ids for non-VIF port
 bindings.

The commit 6fb87aad8c3("controller: Improve ct zone handling.")
caused a regression.  After this commit ovn-controller is allocating
zone id for non VIF port bindings and this is causing unexpected
behavior.  This patch fixes this issue.  Also added a test case
to cover this scenario.

Fixes: 6fb87aad8c3("controller: Improve ct zone handling.")
Reported-by: Vladislav Odintsov <odivlad@gmail.com>
Tested-by: Vladislav Odintsov <odivlad@gmail.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
---
 controller/ovn-controller.c |  5 +++
 tests/ovn.at                | 69 +++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)

diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index 678419ab3..739048cf8 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -1919,6 +1919,11 @@ ct_zones_runtime_data_handler(struct engine_node *node, void *data)
         struct shash_node *shash_node;
         SHASH_FOR_EACH (shash_node, &tdp->lports) {
             struct tracked_lport *t_lport = shash_node->data;
+            if (strcmp(t_lport->pb->type, "")) {
+                /* We allocate zone-id's only to VIF lports. */
+                continue;
+            }
+
             if (t_lport->tracked_type == TRACKED_RESOURCE_NEW) {
                 if (!simap_contains(&ct_zones_data->current,
                                     t_lport->pb->logical_port)) {
diff --git a/tests/ovn.at b/tests/ovn.at
index f1ebb088b..9329dd828 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -28041,3 +28041,72 @@ primary lport : [[sw0-port2]]
 OVN_CLEANUP([hv1])
 AT_CLEANUP
 ])
+
+OVN_FOR_EACH_NORTHD([
+AT_SETUP([ovn-controller ct zone I-P handling])
+ovn_start
+
+net_add n1
+
+sim_add hv1
+as hv1
+ovs-vsctl add-br br-phys
+ovn_attach n1 br-phys 192.168.0.1
+
+check as hv1 ovs-vsctl add-port br-int vif11 \
+    -- set interface vif11 external_ids:iface-id=sw0-port1
+
+ovn-nbctl ls-add sw0
+ovn-nbctl lsp-add sw0 sw0-port1
+ovn-nbctl lsp-set-addresses sw0-port1 "50:54:00:00:00:01 10.0.0.3"
+
+ovn-nbctl lr-add lr0
+ovn-nbctl lrp-add lr0 lr0-sw0 00:00:00:00:ff:01 10.0.0.1/24
+ovn-nbctl lsp-add sw0 sw0-lr0
+ovn-nbctl lsp-set-type sw0-lr0 router
+ovn-nbctl lsp-set-addresses sw0-lr0 00:00:00:00:ff:01
+ovn-nbctl lsp-set-options sw0-lr0 router-port=lr0-sw0
+
+wait_for_ports_up sw0-port1
+
+AT_CHECK([as hv1 ovn-appctl -t ovn-controller ct-zone-list | \
+grep sw0-port1 -c], [0], [1
+])
+
+# There should be no ct-zone id allocated for sw0-lr0 and lr0-sw0
+AT_CHECK([as hv1 ovn-appctl -t ovn-controller ct-zone-list | \
+grep sw0-lr0], [1], [])
+
+AT_CHECK([as hv1 ovn-appctl -t ovn-controller ct-zone-list | \
+grep lr0-sw0], [1], [])
+
+check as hv1 ovs-vsctl add-port br-int vif12 \
+    -- set interface vif12 external_ids:iface-id=sw1-port1
+
+ovn-nbctl ls-add sw1
+ovn-nbctl lsp-add sw1 sw1-port1
+
+wait_for_ports_up sw1-port1
+AT_CHECK([as hv1 ovn-appctl -t ovn-controller ct-zone-list | \
+grep sw1-port1 -c], [0], [1
+])
+
+# Attach sw1 to lr0
+ovn-nbctl lsp-add sw1 sw1-lr0
+ovn-nbctl lsp-set-type sw1-lr0 router
+ovn-nbctl lsp-set-addresses sw1-lr0 00:00:00:00:ff:02
+ovn-nbctl lsp-set-options sw1-lr0 router-port=lr0-sw1
+
+# There should be no ct-zone id allocated for sw1-lr0
+AT_CHECK([as hv1 ovn-appctl -t ovn-controller ct-zone-list | \
+grep sw1-lr0], [1], [])
+
+ovn-nbctl lrp-add lr0 lr0-sw1 00:00:00:00:ff:02 20.0.0.1/24
+
+# There should be no ct-zone id allocated for lr0-sw1
+AT_CHECK([as hv1 ovn-appctl -t ovn-controller ct-zone-list | \
+grep lr0-sw1], [1], [])
+
+OVN_CLEANUP([hv1])
+AT_CLEANUP
+])
-- 
2.31.1