From c74578c141f0abd50ef1d01a597e12216a36ff17 Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Tue, 7 Mar 2017 23:06:43 -0800 Subject: 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 Acked-by: Russell Bryant --- ovn/controller/binding.c | 3 ++- ovn/controller/ovn-controller.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'ovn/controller') 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); -- cgit v1.2.1