summaryrefslogtreecommitdiff
path: root/ovn/controller
diff options
context:
space:
mode:
authorGurucharan Shetty <guru@ovn.org>2017-03-07 23:06:43 -0800
committerGurucharan Shetty <guru@ovn.org>2017-03-10 10:32:27 -0800
commitc74578c141f0abd50ef1d01a597e12216a36ff17 (patch)
tree00b81ba51d5045ef7286bfd9c14e58333761cab5 /ovn/controller
parentf931866780a87d2467018b8ebf45e3dbb548b9c9 (diff)
downloadopenvswitch-c74578c141f0abd50ef1d01a597e12216a36ff17.tar.gz
ovn-controller: Don't bind non-existent interfaces.
There are multiple reasons why a interface can exist in the Open vSwitch database but not exist in the system. For e.g, a restart of a host after a system crash. Ideally, whoever added the interface in the Open vSwitch database should remove those interfaces. But that usually does not happen in practise. Based on experience, I have observerd that on any long lasting OVS installation there are always a couple of stale interfaces. When a stale interface remains in the Open vSwitch database and the container/VM initially backing that stale interface is moved to a different machine, the two ovn-controllers start over-writing the OVN-SB's port_binding table in a loop. This situation can be avoided, if ovn-controller only binds the interfaces that actually have a valid 'ofport'. Signed-off-by: Gurucharan Shetty <guru@ovn.org> Acked-by: Russell Bryant <russell@ovn.org>
Diffstat (limited to 'ovn/controller')
-rw-r--r--ovn/controller/binding.c3
-rw-r--r--ovn/controller/ovn-controller.c1
2 files changed, 3 insertions, 1 deletions
diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
index c90cb6556..95e9deb32 100644
--- a/ovn/controller/binding.c
+++ b/ovn/controller/binding.c
@@ -86,8 +86,9 @@ get_local_iface_ids(const struct ovsrec_bridge *br_int,
iface_rec = port_rec->interfaces[j];
iface_id = smap_get(&iface_rec->external_ids, "iface-id");
+ int64_t ofport = iface_rec->n_ofport ? *iface_rec->ofport : 0;
- if (iface_id) {
+ if (iface_id && ofport > 0) {
shash_add(lport_to_iface, iface_id, iface_rec);
sset_add(local_lports, iface_id);
}
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index ea299dadd..a36973ac9 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -518,6 +518,7 @@ main(int argc, char *argv[])
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_interface_col_name);
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_interface_col_type);
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_interface_col_options);
+ ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_interface_col_ofport);
ovsdb_idl_add_table(ovs_idl_loop.idl, &ovsrec_table_port);
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_port_col_name);
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_port_col_interfaces);