From patchwork Mon Jul 17 15:06:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Simonart X-Patchwork-Id: 1808792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.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=BmVOFE3z; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R4QR169q9z20FK for ; Tue, 18 Jul 2023 01:06:53 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E2641415FB; Mon, 17 Jul 2023 15:06:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org E2641415FB Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BmVOFE3z 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 r52av357JgDv; Mon, 17 Jul 2023 15:06:49 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 86A2F414C5; Mon, 17 Jul 2023 15:06:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 86A2F414C5 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 435B5C0072; Mon, 17 Jul 2023 15:06:48 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5EFFDC0032 for ; Mon, 17 Jul 2023 15:06:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 25FD081B53 for ; Mon, 17 Jul 2023 15:06:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 25FD081B53 Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BmVOFE3z X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dBF_OYsUAvyB for ; Mon, 17 Jul 2023 15:06:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3845481947 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3845481947 for ; Mon, 17 Jul 2023 15:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689606404; 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: in-reply-to:in-reply-to:references:references; bh=Lo9dvlcCI4d+UFRbrNGJqpnfE8WWFQv+gDBowsyW5dQ=; b=BmVOFE3zlrXlRJ8dGnEfYg7BMIzWkAz4W7hmB8qt2AB1Ln8lnKYR7d4OvYjZQVOhpOWjj8 6jsNR9+neiqJZiicrf+j7NjcSQ2CwpaxPmIkeCSfkSKSomTBNnnvJYup909ssRdGEdKcay qgYO9hETuT1GYcXuXjZeT4fzlH+JqYw= 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-407-KLkc7tFHNearMcWPVNA8Pw-1; Mon, 17 Jul 2023 11:06:43 -0400 X-MC-Unique: KLkc7tFHNearMcWPVNA8Pw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B688B88D06E for ; Mon, 17 Jul 2023 15:06:42 +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 9EDFC4CD0F1; Mon, 17 Jul 2023 15:06:42 +0000 (UTC) From: Xavier Simonart To: xsimonar@redhat.com, dev@openvswitch.org Date: Mon, 17 Jul 2023 17:06:40 +0200 Message-Id: <20230717150641.2069008-3-xsimonar@redhat.com> In-Reply-To: <20230717150641.2069008-1-xsimonar@redhat.com> References: <20230717150641.2069008-1-xsimonar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 2/3] binding: fixed ovn-installed not properly removed (migration) 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" Fixed another potential race condition causing ovn-controller to not properly remove ovn-install. Before this patch, ovn-installed was not removed if an hypervisor was receiving the port_binding->chassis change (to another hv) within the same idl as the requested-chassis change. This caused random failures to test "options:multiple requested-chassis for logical port" Signed-off-by: Xavier Simonart --- controller/binding.c | 13 +++++++++++-- controller/if-status.c | 19 ++++++++++++++++--- controller/if-status.h | 2 ++ tests/ovn.at | 29 +++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index f619aba2e..75319c4e7 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -1506,8 +1506,9 @@ release_lport(const struct sbrec_port_binding *pb, if (!release_lport_additional_chassis(pb, chassis_rec, sb_readonly)) { return false; } + } else { + VLOG_INFO("Releasing lport %s", pb->logical_port); } - update_lport_tracking(pb, tracked_datapaths, false); if_status_mgr_release_iface(if_mgr, pb->logical_port); return true; @@ -1616,8 +1617,16 @@ consider_vif_lport_(const struct sbrec_port_binding *pb, } if (pb->chassis == b_ctx_in->chassis_rec - || is_additional_chassis(pb, b_ctx_in->chassis_rec)) { + || is_additional_chassis(pb, b_ctx_in->chassis_rec) + || if_status_is_port_claimed(b_ctx_out->if_mgr, + pb->logical_port)) { /* Release the lport if there is no lbinding. */ + if (lbinding_set && !can_bind) { + if_status_mgr_remove_ovn_installed(b_ctx_out->if_mgr, + b_lport->lbinding->iface->name, + &b_lport->lbinding->iface->header_.uuid); + } + if (!lbinding_set || !can_bind) { return release_lport(pb, b_ctx_in->chassis_rec, !b_ctx_in->ovnsb_idl_txn, diff --git a/controller/if-status.c b/controller/if-status.c index b45208746..6c5afc866 100644 --- a/controller/if-status.c +++ b/controller/if-status.c @@ -71,12 +71,12 @@ enum if_state { * but not yet marked "up" in the binding module (in * SB and OVS databases). */ - OIF_MARK_DOWN, /* Released interface but not yet marked "down" in - * the binding module (in SB and/or OVS databases). - */ OIF_INSTALLED, /* Interface flows programmed in OVS and binding * marked "up" in the binding module. */ + OIF_MARK_DOWN, /* Released interface but not yet marked "down" in + * the binding module (in SB and/or OVS databases). + */ OIF_UPDATE_PORT, /* Logical ports need to be set down, and pb->chassis * removed. */ @@ -820,3 +820,16 @@ if_status_mgr_get_memory_usage(struct if_status_mgr *mgr, simap_increase(usage, "if_status_mgr_ifaces_state_usage-KB", ROUND_UP(ifaces_state_usage, 1024) / 1024); } + +bool +if_status_is_port_claimed(const struct if_status_mgr *mgr, + const char *iface_id) +{ + struct ovs_iface *iface = shash_find_data(&mgr->ifaces, iface_id); + if (!iface || (iface->state > OIF_INSTALLED)) { + return false; + } else { + return true; + } +} + diff --git a/controller/if-status.h b/controller/if-status.h index 15624bcfa..9714f6d8d 100644 --- a/controller/if-status.h +++ b/controller/if-status.h @@ -62,5 +62,7 @@ uint16_t if_status_mgr_iface_get_mtu(const struct if_status_mgr *mgr, const char *iface_id); bool if_status_mgr_iface_update(const struct if_status_mgr *mgr, const struct ovsrec_interface *iface_rec); +bool if_status_is_port_claimed(const struct if_status_mgr *mgr, + const char *iface_id); # endif /* controller/if-status.h */ diff --git a/tests/ovn.at b/tests/ovn.at index f2148faac..11da1bd78 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14499,6 +14499,35 @@ wait_column "$hv1_uuid" Port_Binding requested_additional_chassis logical_port=l check ovn-nbctl lsp-set-options lsp0 requested-chassis=hv2 wait_column "" Port_Binding additional_encap logical_port=lsp0 +# Migration with some race conditions +check ovn-nbctl lsp-set-options lsp0 \ + requested-chassis=hv2,hv1 +wait_column "$hv2_uuid" Port_Binding chassis logical_port=lsp0 +wait_column "$hv2_uuid" Port_Binding requested_chassis logical_port=lsp0 +wait_column "$hv1_uuid" Port_Binding additional_chassis logical_port=lsp0 +wait_column "$hv1_uuid" Port_Binding requested_additional_chassis logical_port=lsp0 + +# Check ovn-installed updated for both chassis +wait_for_ports_up + +for hv in hv1 hv2; do + OVS_WAIT_UNTIL([test `as $hv ovs-vsctl get Interface lsp0 external_ids:ovn-installed` = '"true"']) +done + +# Complete moving the binding to the new location +sleep_controller hv2 +check ovn-nbctl lsp-set-options lsp0 requested-chassis=hv1 + +wait_column "$hv1_uuid" Port_Binding chassis logical_port=lsp0 +wait_column "$hv1_uuid" Port_Binding requested_chassis logical_port=lsp0 +wait_column "" Port_Binding additional_chassis logical_port=lsp0 +wait_column "" Port_Binding requested_additional_chassis logical_port=lsp0 +wake_up_controller hv2 +# Check ovn-installed updated for main chassis and removed from additional chassis +wait_for_ports_up +OVS_WAIT_UNTIL([test `as hv1 ovs-vsctl get Interface lsp0 external_ids:ovn-installed` = '"true"']) +OVS_WAIT_UNTIL([test x`as hv2 ovs-vsctl get Interface lsp0 external_ids:ovn-installed` = x]) + OVN_CLEANUP([hv1],[hv2]) AT_CLEANUP