From patchwork Fri May 26 00:26:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 767182 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 3wYn671nYhz9s7h for ; Fri, 26 May 2017 10:27:59 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OKtt0pmv"; dkim-atps=neutral Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 49278C07; Fri, 26 May 2017 00:26:49 +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 6819BBF2 for ; Fri, 26 May 2017 00:26:47 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 116B712A for ; Fri, 26 May 2017 00:26:47 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id n23so42196012pfb.3 for ; Thu, 25 May 2017 17:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NSckJBabnFgEMFMtFXJreKXoJAaFuYsjlx3ieYGA7Rc=; b=OKtt0pmv5OeRy5K7tOPN9hLHGdJmOl7DqnWGeN8tVi7ulJS70FCvrmQDYVgcw3DijN 7t4EqIoRbKqUCSv0Br1BZwXIK8vtBKlKHzB72QOcjb3QesFbQhpUSEFLVBeau0hguPf+ ATadVmzDXQePiq9uZ+cj3KaJELobb+Nzw2/BDwawsDgnX+MA8JrUVZSU96ydhYSsgiH6 vowlihYV+k1HRGLSYhyDpbaOBr4HtPH1opVIRrtRlAtHtSHlk6HkL1C9J80GmieETfy1 Nq+b1UzYklOJaSnVjpcacCEdCQJ9smX9c1rl4JkSl9CPXpMAHdIQd22Y+uN0mg7CT21n fQfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NSckJBabnFgEMFMtFXJreKXoJAaFuYsjlx3ieYGA7Rc=; b=l0jUDIPOKaw7G9gPRZ+M1rxVuXqE0m5Sz8drWAbh3G3irEO9ftSXRcos39fxi0CBGv isB4tx6nmgz+edorE3i6mzrvtxKlXp5/cVHdVHvassnOaOBRJHoiXib84JLviwHHSdYI gKOeHStZHl0QoxqXnuczGpgKQmVB10nYBN3OHfyOqN4vfmGrNivDZX1Bp5fAQ2mIc5Mu BhWy22pAg11Hr/FRJfeCcF7p7dA7/SSOg+j7phHlN4ycGhegwOt2NZSpbNLGk4jLqsXa VrctQGXXrSSerOmdz54Hf6ZbQC3NMsiqlmPaklqw/7tpt9rDAI4b83pXiACwVsL1RJEL Zd8A== X-Gm-Message-State: AODbwcAA3XQUcsnC2MY8CaVvpxluVYCdl6ZV+WWFb9Kmh0LM0I8PhxCH C9jiL0SpWI+a3+dO X-Received: by 10.99.152.9 with SMTP id q9mr48035535pgd.131.1495758406442; Thu, 25 May 2017 17:26:46 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.70]) by smtp.gmail.com with ESMTPSA id c63sm14919796pfd.8.2017.05.25.17.26.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 May 2017 17:26:45 -0700 (PDT) From: Han Zhou To: dev@openvswitch.org Date: Thu, 25 May 2017 17:26:45 -0700 Message-Id: <1495758407-20532-3-git-send-email-zhouhan@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1495758407-20532-1-git-send-email-zhouhan@gmail.com> References: <1495758407-20532-1-git-send-email-zhouhan@gmail.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 2/4] ovn-controller: readonly mode binding_run and get_br_int 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 This change is to prepare for the future change for multi-threading. Both binding_run() and get_br_int() are needed by pinctrl thread, but we don't want to update SB DB or create bridges in that scenario, so need "readonly" mode for these functions. Signed-off-by: Han Zhou --- ovn/controller/binding.c | 11 +++++++---- ovn/controller/binding.h | 2 +- ovn/controller/ovn-controller.c | 10 +++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c index 8080f8f..29673fa 100644 --- a/ovn/controller/binding.c +++ b/ovn/controller/binding.c @@ -368,7 +368,8 @@ consider_local_datapath(struct controller_ctx *ctx, struct hmap *local_datapaths, struct shash *lport_to_iface, struct sset *local_lports, - struct hmap *localnet_ports) + struct hmap *localnet_ports, + bool update_sb) { const struct ovsrec_interface *iface_rec = shash_find_data(lport_to_iface, binding_rec->logical_port); @@ -428,7 +429,7 @@ consider_local_datapath(struct controller_ctx *ctx, our_chassis = false; } - if (ctx->ovnsb_idl_txn) { + if (ctx->ovnsb_idl_txn && update_sb) { if (our_chassis) { if (binding_rec->chassis != chassis_rec) { if (binding_rec->chassis) { @@ -459,7 +460,8 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, const struct sbrec_chassis *chassis_rec, const struct ldatapath_index *ldatapaths, const struct lport_index *lports, struct hmap *local_datapaths, - struct sset *local_lports) + struct sset *local_lports, + bool update_sb) { if (!chassis_rec) { return; @@ -486,7 +488,8 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, chassis_rec, binding_rec, sset_is_empty(&egress_ifaces) ? NULL : &qos_map, local_datapaths, &lport_to_iface, - local_lports, &localnet_ports); + local_lports, &localnet_ports, + update_sb); } diff --git a/ovn/controller/binding.h b/ovn/controller/binding.h index 3bfa7d1..5b77f1a 100644 --- a/ovn/controller/binding.h +++ b/ovn/controller/binding.h @@ -32,7 +32,7 @@ void binding_register_ovs_idl(struct ovsdb_idl *); void binding_run(struct controller_ctx *, const struct ovsrec_bridge *br_int, const struct sbrec_chassis *, const struct ldatapath_index *, const struct lport_index *, struct hmap *local_datapaths, - struct sset *all_lports); + struct sset *all_lports, bool update_sb); bool binding_cleanup(struct controller_ctx *, const struct sbrec_chassis *); #endif /* ovn/binding.h */ diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index 1155657..4537046 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -243,7 +243,7 @@ create_br_int(struct controller_ctx *ctx, } static const struct ovsrec_bridge * -get_br_int(struct controller_ctx *ctx) +get_br_int(struct controller_ctx *ctx, bool need_create) { const struct ovsrec_open_vswitch *cfg; cfg = ovsrec_open_vswitch_first(ctx->ovs_idl); @@ -256,7 +256,7 @@ get_br_int(struct controller_ctx *ctx) const struct ovsrec_bridge *br; br = get_bridge(ctx->ovs_idl, br_int_name); - if (!br) { + if (!br && need_create) { return create_br_int(ctx, cfg, br_int_name); } return br; @@ -614,7 +614,7 @@ main(int argc, char *argv[]) * local hypervisor, and localnet ports. */ struct sset local_lports = SSET_INITIALIZER(&local_lports); - const struct ovsrec_bridge *br_int = get_br_int(&ctx); + const struct ovsrec_bridge *br_int = get_br_int(&ctx, true); const char *chassis_id = get_chassis_id(ctx.ovs_idl); struct ldatapath_index ldatapaths; @@ -629,7 +629,7 @@ main(int argc, char *argv[]) chassis = chassis_run(&ctx, chassis_id, br_int); encaps_run(&ctx, br_int, chassis_id); binding_run(&ctx, br_int, chassis, &ldatapaths, &lports, - &local_datapaths, &local_lports); + &local_datapaths, &local_lports, true); } if (br_int && chassis) { @@ -751,7 +751,7 @@ main(int argc, char *argv[]) .ovnsb_idl_txn = ovsdb_idl_loop_run(&ovnsb_idl_loop), }; - const struct ovsrec_bridge *br_int = get_br_int(&ctx); + const struct ovsrec_bridge *br_int = get_br_int(&ctx, false); const char *chassis_id = get_chassis_id(ctx.ovs_idl); const struct sbrec_chassis *chassis = chassis_id ? get_chassis(ctx.ovnsb_idl, chassis_id) : NULL;