From patchwork Wed Mar 8 07:18:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurucharan Shetty X-Patchwork-Id: 736672 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vdgdZ4r4Dz9s8W for ; Thu, 9 Mar 2017 04:34:58 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 23471B44; Wed, 8 Mar 2017 17:34:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 7E62849B for ; Wed, 8 Mar 2017 17:34:53 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 160781A7 for ; Wed, 8 Mar 2017 17:34:53 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id 187so4021408pgb.2 for ; Wed, 08 Mar 2017 09:34:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=0ItEdVSp/6o+9rhI/8i1sCR8zT+sxTmqopjqmXskMRg=; b=snVaNY4NCHWfH2+QXOW4zDZbI/LREcRNrKdIHIyQspQv+Oc6R85s4j9GBb4UZVaA1A wZaEYsvJ0XMoeZ+MCMKIveuMwSwi71mSi2CFtelEX8c5U+QZQIQd/0mpUHJO/4T4B6Rt eVnDF5EqjL9eOz6qRdtgz7psuthx832haVPFb+6bGwsmaUjPG+GYiTxM7uCC1RBD+lJQ k9/ARzd1sq2FoNn/nGT9GqebLzxUrlWt9h5G8LgsufvD0R2IPDOV81I692NT0gf/tAI1 9NXeXwXFN3tD9/zgKoY0mxh/6gjuCrjEuA/VtoNPpEMOaHzdadcR1RYhR4NUd0zv2Ssm o9hQ== X-Gm-Message-State: AMke39lHgy3ckiltnqMEpOZQ53e5XnJ6KEqGj6r1VvQ4oXqxC6HYMo9y7fhzVQRK8i380w== X-Received: by 10.98.106.134 with SMTP id f128mr8603933pfc.142.1488994492569; Wed, 08 Mar 2017 09:34:52 -0800 (PST) Received: from ovn1.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id 187sm7455348pff.17.2017.03.08.09.34.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Mar 2017 09:34:51 -0800 (PST) From: Gurucharan Shetty To: dev@openvswitch.org Date: Tue, 7 Mar 2017 23:18:57 -0800 Message-Id: <1488957537-12991-1-git-send-email-guru@ovn.org> X-Mailer: git-send-email 1.9.1 X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00, DATE_IN_PAST_06_12, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] ovn-controller: Don't bind non-existent interfaces. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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(-) diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c index c90cb65..95e9deb 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 ea299da..a36973a 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);