From patchwork Wed Jun 15 10:09:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Simonart X-Patchwork-Id: 1643588 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" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JkPzK3eS; 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 (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNLdW5JKFz9t6h for ; Wed, 15 Jun 2022 20:09:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id EF2BC41950; Wed, 15 Jun 2022 10:09:48 +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 s5Mn06fIzAt8; Wed, 15 Jun 2022 10:09:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 813E94193D; Wed, 15 Jun 2022 10:09:46 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 59B7BC0032; Wed, 15 Jun 2022 10:09:46 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id EDA1CC002D for ; Wed, 15 Jun 2022 10:09:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D984C607CE for ; Wed, 15 Jun 2022 10:09:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OZ73RtApoPcB for ; Wed, 15 Jun 2022 10:09:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 0BE636066D for ; Wed, 15 Jun 2022 10:09:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655287782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QveV3qE8xeU/fMtZMy2NszD51sUhQm6fu3NZclb4kvU=; b=JkPzK3eSiGJQJWYo02b3lcAJenvLXzvVLuHMdvzDpN1X0HKMYNS0k/vxxGIHQ9g3z0BQ8y Mg08Ts0o8CINRa1QP4I9lD9yWc6507D7wOVlm6oNVCz/PY/jIiwY3yzbePMHTkTRr1Blyr CDHj5wWa2WZZ9ZA6e1bZUs6x9b99OMw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-192-tLatOaZsNdON3CcPtYVNww-1; Wed, 15 Jun 2022 06:09:40 -0400 X-MC-Unique: tLatOaZsNdON3CcPtYVNww-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2A7F780159B for ; Wed, 15 Jun 2022 10:09:40 +0000 (UTC) Received: from wsfd-netdev90.ntdv.lab.eng.bos.redhat.com (wsfd-netdev90.ntdv.lab.eng.bos.redhat.com [10.19.188.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11324C08F0D; Wed, 15 Jun 2022 10:09:40 +0000 (UTC) From: Xavier Simonart To: xsimonar@redhat.com, dev@openvswitch.org Date: Wed, 15 Jun 2022 06:09:39 -0400 Message-Id: <20220615100939.653785-1-xsimonar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=xsimonar@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] ovn-controller: fixed ovn-installed not always properly added. 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" OVN checks whether ovn-installed is already present (in OVS) before updating it. This might cause ovn-installed related issues in the following case: - (1) ovn-installed is present - (2) we claim the interface - (3) we update ovs, removing ovn-installed and start installing flows - (4) (next loop), after flows installed, we check if ovn-installed is absent, and if yes, we update OVS with ovn-installed. However, in step4, if OVS is still busy from step 3, ovn-installed is read as present; hence OVN controller does not update it and move to INSTALLED state. Note that this does not happen with writing port up in SBDB because Port status changes will hit I-P. Signed-off-by: Xavier Simonart --- controller/binding.c | 14 ++++++++++---- controller/binding.h | 3 ++- controller/if-status.c | 5 +++-- controller/if-status.h | 3 ++- controller/ovn-controller.c | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index 2279570f9..7b01767cd 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -644,7 +644,8 @@ local_binding_get_lport_ofport(const struct shash *local_bindings, } bool -local_binding_is_up(struct shash *local_bindings, const char *pb_name) +local_binding_is_up(struct shash *local_bindings, const char *pb_name, + bool ovs_readonly) { struct local_binding *lbinding = local_binding_find(local_bindings, pb_name); @@ -653,6 +654,10 @@ local_binding_is_up(struct shash *local_bindings, const char *pb_name) if (b_lport->pb->n_up && !b_lport->pb->up[0]) { return false; } + if (ovs_readonly) { + /* We might be reading stale data from OVS */ + return false; + } return smap_get_bool(&lbinding->iface->external_ids, OVN_INSTALLED_EXT_ID, false); } @@ -1297,9 +1302,11 @@ consider_vif_lport_(const struct sbrec_port_binding *pb, const char *requested_chassis_option = smap_get( &pb->options, "requested-chassis"); VLOG_INFO_RL(&rl, - "Not claiming lport %s, chassis %s requested-chassis %s", + "Not claiming lport %s, chassis %s requested-chassis %s " + "pb->chassis %s", pb->logical_port, b_ctx_in->chassis_rec->name, - requested_chassis_option ? requested_chassis_option : "[]"); + requested_chassis_option ? requested_chassis_option : "[]", + pb->chassis ? pb->chassis->name: ""); } } @@ -1313,7 +1320,6 @@ consider_vif_lport_(const struct sbrec_port_binding *pb, b_ctx_out->if_mgr); } } - return true; } diff --git a/controller/binding.h b/controller/binding.h index 1fed06674..178a0650c 100644 --- a/controller/binding.h +++ b/controller/binding.h @@ -151,7 +151,8 @@ const struct sbrec_port_binding *local_binding_get_primary_pb( ofp_port_t local_binding_get_lport_ofport(const struct shash *local_bindings, const char *pb_name); -bool local_binding_is_up(struct shash *local_bindings, const char *pb_name); +bool local_binding_is_up(struct shash *local_bindings, const char *pb_name, + bool ovs_readonly); bool local_binding_is_down(struct shash *local_bindings, const char *pb_name); void local_binding_set_up(struct shash *local_bindings, const char *pb_name, const struct sbrec_chassis *chassis_rec, diff --git a/controller/if-status.c b/controller/if-status.c index ad61844d8..af82d2f10 100644 --- a/controller/if-status.c +++ b/controller/if-status.c @@ -248,7 +248,8 @@ if_status_mgr_delete_iface(struct if_status_mgr *mgr, const char *iface_id) void if_status_mgr_update(struct if_status_mgr *mgr, - struct local_binding_data *binding_data) + struct local_binding_data *binding_data, + bool ovs_readonly) { if (!binding_data) { return; @@ -263,7 +264,7 @@ if_status_mgr_update(struct if_status_mgr *mgr, HMAPX_FOR_EACH_SAFE (node, &mgr->ifaces_per_state[OIF_MARK_UP]) { struct ovs_iface *iface = node->data; - if (local_binding_is_up(bindings, iface->id)) { + if (local_binding_is_up(bindings, iface->id, ovs_readonly)) { ovs_iface_set_state(mgr, iface, OIF_INSTALLED); } } diff --git a/controller/if-status.h b/controller/if-status.h index bb8a3950d..ae1641e5c 100644 --- a/controller/if-status.h +++ b/controller/if-status.h @@ -31,7 +31,8 @@ void if_status_mgr_claim_iface(struct if_status_mgr *, const char *iface_id); void if_status_mgr_release_iface(struct if_status_mgr *, const char *iface_id); void if_status_mgr_delete_iface(struct if_status_mgr *, const char *iface_id); -void if_status_mgr_update(struct if_status_mgr *, struct local_binding_data *); +void if_status_mgr_update(struct if_status_mgr *, struct local_binding_data *, + bool ovs_readonly); void if_status_mgr_run(struct if_status_mgr *mgr, struct local_binding_data *, const struct sbrec_chassis *, bool sb_readonly, bool ovs_readonly); diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 2793c8687..78c7cc457 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -3999,7 +3999,7 @@ main(int argc, char *argv[]) runtime_data ? &runtime_data->lbinding_data : NULL; stopwatch_start(IF_STATUS_MGR_UPDATE_STOPWATCH_NAME, time_msec()); - if_status_mgr_update(if_mgr, binding_data); + if_status_mgr_update(if_mgr, binding_data, !ovs_idl_txn); stopwatch_stop(IF_STATUS_MGR_UPDATE_STOPWATCH_NAME, time_msec());