bbaaef
From 33fae9ee62a0f3c1ff951cde90d7330650681c32 Mon Sep 17 00:00:00 2001
bbaaef
From: Dumitru Ceara <dceara@redhat.com>
bbaaef
Date: Thu, 2 Apr 2020 10:35:32 +0200
bbaaef
Subject: [PATCH] ovn-controller: Skip vport bindings done through OVS
bbaaef
 external_ids:iface-id.
bbaaef
bbaaef
Port bindings of type "virtual" should not have an associated OVS port
bbaaef
in the integration bridge. If this is the case, it's a misconfig and
bbaaef
ovn-controller should ignore it.
bbaaef
bbaaef
If such a situation is detected, ovn-controller will also log a warning
bbaaef
message to inform the user about the wrong configuration.
bbaaef
bbaaef
Reported-at: https://bugzilla.redhat.com/1818844
bbaaef
CC: Numan Siddique <nusiddiq@redhat.com>
bbaaef
Fixes: 054f4c85c413 ("Add a new logical switch port type - 'virtual'")
bbaaef
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
bbaaef
Signed-off-by: Numan Siddique <numans@ovn.org>
bbaaef
(cherry picked from upstream commit 523b1f5f45682bd6dd454281a97a09c3f429c457)
bbaaef
bbaaef
Change-Id: I65979e1f218f02dd24ba8625e516b766a03fd081
bbaaef
---
bbaaef
 ovn/controller/binding.c | 12 ++++++++++++
bbaaef
 tests/ovn.at             | 20 ++++++++++++++++++++
bbaaef
 2 files changed, 32 insertions(+)
bbaaef
bbaaef
diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
bbaaef
index bf7b5ff..c71731a 100644
bbaaef
--- a/ovn/controller/binding.c
bbaaef
+++ b/ovn/controller/binding.c
bbaaef
@@ -436,6 +436,18 @@ is_our_chassis(const struct sbrec_chassis *chassis_rec,
bbaaef
     const struct ovsrec_interface *iface_rec
bbaaef
         = shash_find_data(lport_to_iface, binding_rec->logical_port);
bbaaef
 
bbaaef
+    /* Ports of type "virtual" should never be explicitly bound to an OVS
bbaaef
+     * port in the integration bridge. If that's the case, ignore the binding
bbaaef
+     * and log a warning.
bbaaef
+     */
bbaaef
+    if (iface_rec && !strcmp(binding_rec->type, "virtual")) {
bbaaef
+        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
bbaaef
+        VLOG_WARN_RL(&rl,
bbaaef
+                     "Virtual port %s should not be bound to OVS port %s",
bbaaef
+                     binding_rec->logical_port, iface_rec->name);
bbaaef
+        return false;
bbaaef
+    }
bbaaef
+
bbaaef
     bool our_chassis = false;
bbaaef
     if (iface_rec
bbaaef
         || (binding_rec->parent_port && binding_rec->parent_port[0] &&
bbaaef
diff --git a/tests/ovn.at b/tests/ovn.at
bbaaef
index 94e5ecd..d74a8b0 100644
bbaaef
--- a/tests/ovn.at
bbaaef
+++ b/tests/ovn.at
bbaaef
@@ -14639,6 +14639,11 @@ ovs-vsctl -- add-port br-int hv1-vif2 -- \
bbaaef
     options:tx_pcap=hv1/vif2-tx.pcap \
bbaaef
     options:rxq_pcap=hv1/vif2-rx.pcap \
bbaaef
     ofport-request=2
bbaaef
+ovs-vsctl -- add-port br-int hv1-vif3 -- \
bbaaef
+    set interface hv1-vif3 \
bbaaef
+    options:tx_pcap=hv1/vif3-tx.pcap \
bbaaef
+    options:rxq_pcap=hv1/vif3-rx.pcap \
bbaaef
+    ofport-request=3
bbaaef
 
bbaaef
 sim_add hv2
bbaaef
 as hv2
bbaaef
@@ -14732,6 +14737,21 @@ logical_port=sw0-vir) = x], [0], [])
bbaaef
 AT_CHECK([test x$(ovn-sbctl --bare --columns virtual_parent find port_binding \
bbaaef
 logical_port=sw0-vir) = x])
bbaaef
 
bbaaef
+# Try to bind sw0-vir directly to an OVS port. This should be ignored by
bbaaef
+# ovn-controller.
bbaaef
+as hv1
bbaaef
+ovs-vsctl set interface hv1-vif3 external-ids:iface-id=sw0-vir
bbaaef
+
bbaaef
+AT_CHECK([test x$(ovn-sbctl --bare --columns chassis find port_binding \
bbaaef
+logical_port=sw0-vir) = x], [0], [])
bbaaef
+
bbaaef
+# Cleanup hv1-vif3.
bbaaef
+as hv1
bbaaef
+ovs-vsctl del-port hv1-vif3
bbaaef
+
bbaaef
+AT_CHECK([test x$(ovn-sbctl --bare --columns chassis find port_binding \
bbaaef
+logical_port=sw0-vir) = x], [0], [])
bbaaef
+
bbaaef
 # From sw0-p0 send GARP for 10.0.0.10. hv1 should claim sw0-vir
bbaaef
 # and sw0-p1 should be its virtual_parent.
bbaaef
 eth_src=505400000003
bbaaef
-- 
bbaaef
1.8.3.1
bbaaef