From patchwork Sun Apr 30 23:22:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 756960 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 3wGP3H2HPzz9sCX for ; Mon, 1 May 2017 09:32:11 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 84133BD1; Sun, 30 Apr 2017 23:23:34 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp2.linuxfoundation.org (smtp2.linux-foundation.org [172.17.192.36]) by mail.linuxfoundation.org (Postfix) with ESMTPS id B6160BC3 for ; Sun, 30 Apr 2017 23:23:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by smtp2.linuxfoundation.org (Postfix) with ESMTPS id EFD0C1DEE0 for ; Sun, 30 Apr 2017 23:23:31 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by relay8-d.mail.gandi.net (Postfix) with ESMTPS id 8AD584050B; Mon, 1 May 2017 01:23:30 +0200 (CEST) Received: from mfilter15-d.gandi.net (mfilter15-d.gandi.net [217.70.178.143]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 7B4BA41C084; Mon, 1 May 2017 01:23:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter15-d.gandi.net Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter15-d.gandi.net (mfilter15-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id uXavO5e7s3SC; Mon, 1 May 2017 01:23:29 +0200 (CEST) X-Originating-IP: 173.228.112.23 Received: from sigabrt.gateway.sonic.net (173-228-112-23.dsl.dynamic.fusionbroadband.com [173.228.112.23]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 8490B41C080; Mon, 1 May 2017 01:23:27 +0200 (CEST) From: Ben Pfaff To: dev@openvswitch.org Date: Sun, 30 Apr 2017 16:22:21 -0700 Message-Id: <20170430232231.15151-18-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170430232231.15151-1-blp@ovn.org> References: <20170430232231.15151-1-blp@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp2.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 17/27] ovn-northd: Keep external-ids up-to-date in Datapath_Binding. 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 Without this, ovn-northd sets external-ids properly when it creates a Datapath_Binding record, but failed to update the external-ids if they should have changed. Signed-off-by: Ben Pfaff --- ovn/northd/ovn-northd.c | 60 +++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 6e0fd354614e..fe664406fcf8 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -595,6 +595,36 @@ init_ipam_info_for_datapath(struct ovn_datapath *od) } static void +ovn_datapath_update_external_ids(struct ovn_datapath *od) +{ + /* Get the logical-switch or logical-router UUID to set in + * external-ids. */ + char uuid_s[UUID_LEN + 1]; + sprintf(uuid_s, UUID_FMT, UUID_ARGS(&od->key)); + const char *key = od->nbs ? "logical-switch" : "logical-router"; + + /* Get names to set in external-ids. */ + const char *name = od->nbs ? od->nbs->name : od->nbr->name; + const char *name2 = (od->nbs + ? smap_get(&od->nbs->external_ids, + "neutron:network_name") + : smap_get(&od->nbr->external_ids, + "neutron:router_name")); + + /* Set external-ids. */ + struct smap ids = SMAP_INITIALIZER(&ids); + smap_add(&ids, key, uuid_s); + if (*name) { + smap_add(&ids, "name", name); + } + if (name2 && name2[0]) { + smap_add(&ids, *name ? "name2" : "name", name2); + } + sbrec_datapath_binding_set_external_ids(od->sb, &ids); + smap_destroy(&ids); +} + +static void join_datapaths(struct northd_context *ctx, struct hmap *datapaths, struct ovs_list *sb_only, struct ovs_list *nb_only, struct ovs_list *both) @@ -642,6 +672,7 @@ join_datapaths(struct northd_context *ctx, struct hmap *datapaths, od->nbs = nbs; ovs_list_remove(&od->list); ovs_list_push_back(both, &od->list); + ovn_datapath_update_external_ids(od); } else { od = ovn_datapath_create(datapaths, &nbs->header_.uuid, nbs, NULL, NULL); @@ -664,6 +695,7 @@ join_datapaths(struct northd_context *ctx, struct hmap *datapaths, od->nbr = nbr; ovs_list_remove(&od->list); ovs_list_push_back(both, &od->list); + ovn_datapath_update_external_ids(od); } else { /* Can't happen! */ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); @@ -715,33 +747,7 @@ build_datapaths(struct northd_context *ctx, struct hmap *datapaths) } od->sb = sbrec_datapath_binding_insert(ctx->ovnsb_txn); - - /* Get the logical-switch or logical-router UUID to set in - * external-ids. */ - char uuid_s[UUID_LEN + 1]; - sprintf(uuid_s, UUID_FMT, UUID_ARGS(&od->key)); - const char *key = od->nbs ? "logical-switch" : "logical-router"; - - /* Get names to set in external-ids. */ - const char *name = od->nbs ? od->nbs->name : od->nbr->name; - const char *name2 = (od->nbs - ? smap_get(&od->nbs->external_ids, - "neutron:network_name") - : smap_get(&od->nbr->external_ids, - "neutron:router_name")); - - /* Set external-ids. */ - struct smap ids = SMAP_INITIALIZER(&ids); - smap_add(&ids, key, uuid_s); - if (*name) { - smap_add(&ids, "name", name); - } - if (name2 && name2[0]) { - smap_add(&ids, *name ? "name2" : "name", name2); - } - sbrec_datapath_binding_set_external_ids(od->sb, &ids); - smap_destroy(&ids); - + ovn_datapath_update_external_ids(od); sbrec_datapath_binding_set_tunnel_key(od->sb, tunnel_key); } destroy_tnlids(&dp_tnlids);