From patchwork Tue Oct 19 10:21:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Nordahl X-Patchwork-Id: 1543164 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=pSPSL2/R; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HYVDJ6p21z9sPB for ; Tue, 19 Oct 2021 21:22:24 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BF4894077F; Tue, 19 Oct 2021 10:22:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LCP1sNEi4kwg; Tue, 19 Oct 2021 10:22:19 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id A3F004075E; Tue, 19 Oct 2021 10:22:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BA055C002F; Tue, 19 Oct 2021 10:22:14 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id EB970C0022 for ; Tue, 19 Oct 2021 10:22:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CA77B4023F for ; Tue, 19 Oct 2021 10:22:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ziifT6rhgoRk for ; Tue, 19 Oct 2021 10:22:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) by smtp4.osuosl.org (Postfix) with ESMTPS id 211AB40250 for ; Tue, 19 Oct 2021 10:22:09 +0000 (UTC) Received: from frode-threadripper.. (1.general.frode.uk.vpn [10.172.193.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id A053D41C06 for ; Tue, 19 Oct 2021 10:22:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1634638927; bh=PTxyAw3celBQYwXBnSmWt0TASaXGTZiT5kcgg7nA9zU=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pSPSL2/R5qYl7HgSvxrhEpIqRTJ2owo1WWJzHM3RE7ZwMZ/LBWtFXZs6nxyELWbA4 aqBoWVL0FPqOWzkqpY/0Yi3mo+Bk++y+DJ6Tr7ZA8Um0C93h05wKdn/RMu+bTZWjgB yVb3McW4BavhZuQvOogF1EYWxPzbo0C/e5pwfofTtfiXlFFld2Bh4xEieOGi1H2HhS kT1iIAwpKwecwB1YQovAJrB3n4oLgx2S3IqqDqWIbQAhqL2lJGa+OISUfvqRzc5695 1Du3asFaEuDOJe/e5wT+Txrh0TKAfVExNre+nCzkEV7anc8WMiyAT/7C3E8y0syVTd kJCSEcc5zFeHQ== From: Frode Nordahl To: dev@openvswitch.org Date: Tue, 19 Oct 2021 12:21:58 +0200 Message-Id: <20211019102205.3837601-5-frode.nordahl@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211019102205.3837601-1-frode.nordahl@canonical.com> References: <20211019101348.3833652-1-frode.nordahl@canonical.com> <20211019102205.3837601-1-frode.nordahl@canonical.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn v7 05/12] binding: Move can_bind helper to lport module. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" The `can_bind_on_this_chassis` helper is useful outside of the binding module. Since it is related to lports renaming it to `lport_can_bind_on_this_chassis` and putting it into the lport module appears to be appropriate. Signed-off-by: Frode Nordahl --- controller/binding.c | 29 ++--------------------------- controller/lport.c | 25 +++++++++++++++++++++++++ controller/lport.h | 3 +++ 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index aac96694a..ecfddced5 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -1054,31 +1054,6 @@ is_binding_lport_this_chassis(struct binding_lport *b_lport, b_lport->pb->chassis == chassis); } -static bool -can_bind_on_this_chassis(const struct sbrec_chassis *chassis_rec, - const struct sbrec_port_binding *pb) -{ - /* We need to check for presence of the requested-chassis option in - * addittion to checking the pb->requested_chassis column because this - * column will be set to NULL whenever the option points to a non-existent - * chassis. As the controller routinely clears its own chassis record this - * might occur more often than one might think. */ - const char *requested_chassis_option = smap_get(&pb->options, - "requested-chassis"); - if (requested_chassis_option && requested_chassis_option[0] - && !pb->requested_chassis) { - /* The requested-chassis option is set, but the requested_chassis - * column is not filled. This means that the chassis the option - * points to is currently not running, or is in the process of starting - * up. In this case we must fall back to comparing the strings to - * avoid release/claim thrashing. */ - return !strcmp(requested_chassis_option, chassis_rec->name) - || !strcmp(requested_chassis_option, chassis_rec->hostname); - } - return !requested_chassis_option || !requested_chassis_option[0] - || chassis_rec == pb->requested_chassis; -} - /* Returns 'true' if the 'lbinding' has binding lports of type LP_CONTAINER, * 'false' otherwise. */ static bool @@ -1181,7 +1156,7 @@ consider_vif_lport(const struct sbrec_port_binding *pb, struct local_binding *lbinding, struct hmap *qos_map) { - bool can_bind = can_bind_on_this_chassis(b_ctx_in->chassis_rec, pb); + bool can_bind = lport_can_bind_on_this_chassis(b_ctx_in->chassis_rec, pb); if (!lbinding) { lbinding = local_binding_find(&b_ctx_out->lbinding_data->bindings, @@ -1296,7 +1271,7 @@ consider_container_lport(const struct sbrec_port_binding *pb, } ovs_assert(parent_b_lport && parent_b_lport->pb); - bool can_bind = can_bind_on_this_chassis(b_ctx_in->chassis_rec, pb); + bool can_bind = lport_can_bind_on_this_chassis(b_ctx_in->chassis_rec, pb); return consider_vif_lport_(pb, can_bind, b_ctx_in, b_ctx_out, container_b_lport, qos_map); diff --git a/controller/lport.c b/controller/lport.c index 25b4ef200..5ad40f6d3 100644 --- a/controller/lport.c +++ b/controller/lport.c @@ -108,6 +108,31 @@ lport_get_l3gw_peer(const struct sbrec_port_binding *pb, return get_peer_lport(pb, sbrec_port_binding_by_name); } +bool +lport_can_bind_on_this_chassis(const struct sbrec_chassis *chassis_rec, + const struct sbrec_port_binding *pb) +{ + /* We need to check for presence of the requested-chassis option in + * addittion to checking the pb->requested_chassis column because this + * column will be set to NULL whenever the option points to a non-existent + * chassis. As the controller routinely clears its own chassis record this + * might occur more often than one might think. */ + const char *requested_chassis_option = smap_get(&pb->options, + "requested-chassis"); + if (requested_chassis_option && requested_chassis_option[0] + && !pb->requested_chassis) { + /* The requested-chassis option is set, but the requested_chassis + * column is not filled. This means that the chassis the option + * points to is currently not running, or is in the process of starting + * up. In this case we must fall back to comparing the strings to + * avoid release/claim thrashing. */ + return !strcmp(requested_chassis_option, chassis_rec->name) + || !strcmp(requested_chassis_option, chassis_rec->hostname); + } + return !requested_chassis_option || !requested_chassis_option[0] + || chassis_rec == pb->requested_chassis; +} + const struct sbrec_datapath_binding * datapath_lookup_by_key(struct ovsdb_idl_index *sbrec_datapath_binding_by_key, uint64_t dp_key) diff --git a/controller/lport.h b/controller/lport.h index 43b3d714d..4716c58f9 100644 --- a/controller/lport.h +++ b/controller/lport.h @@ -43,6 +43,9 @@ const struct sbrec_port_binding *lport_lookup_by_key( struct ovsdb_idl_index *sbrec_port_binding_by_key, uint64_t dp_key, uint64_t port_key); +bool lport_can_bind_on_this_chassis(const struct sbrec_chassis *chassis_rec, + const struct sbrec_port_binding *pb); + const struct sbrec_datapath_binding *datapath_lookup_by_key( struct ovsdb_idl_index *sbrec_datapath_binding_by_key, uint64_t dp_key);