From patchwork Thu Nov 2 14:57:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Simonart X-Patchwork-Id: 1858563 X-Patchwork-Delegate: nusiddiq@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=WW8zDXTQ; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SLn6w1mzMz1yQ6 for ; Fri, 3 Nov 2023 01:58:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9999D4F108; Thu, 2 Nov 2023 14:57:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 9999D4F108 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=WW8zDXTQ 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 dT2_p_oUFik0; Thu, 2 Nov 2023 14:57:53 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id D9D9C41E4F; Thu, 2 Nov 2023 14:57:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D9D9C41E4F Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AEB41C0039; Thu, 2 Nov 2023 14:57:52 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0E185C0032 for ; Thu, 2 Nov 2023 14:57:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D6E35434A4 for ; Thu, 2 Nov 2023 14:57:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D6E35434A4 Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WW8zDXTQ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vRAYl_WvjWNt for ; Thu, 2 Nov 2023 14:57:46 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 97D7A43452 for ; Thu, 2 Nov 2023 14:57:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 97D7A43452 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698937065; 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=XB708DLvrHq0WCrghtT4kMKcV/iKWS+SJHRfuilGEYU=; b=WW8zDXTQhhHCqkNe6OCciHV/X93Rs9josm2/GxvnC/8/4IgNnGAX+0wcZFQimIZwn5XNAv nxbEdFyVQIUEkbKXA/CGoK9ADJ2bjNe6ZprpduEKe3h+cDym3e4Cuow6z+pIY2SXxEXQcm Ufhw1QBFJ6YY85cH+bLviVd1GDn9en8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-1-zxuYKyx0PyGZ-RKxmDL8MA-1; Thu, 02 Nov 2023 10:57:42 -0400 X-MC-Unique: zxuYKyx0PyGZ-RKxmDL8MA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id C9C40811E7D for ; Thu, 2 Nov 2023 14:57:41 +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 AF1A5502E; Thu, 2 Nov 2023 14:57:41 +0000 (UTC) From: Xavier Simonart To: xsimonar@redhat.com, dev@openvswitch.org Date: Thu, 2 Nov 2023 15:57:41 +0100 Message-Id: <20231102145741.437199-1-xsimonar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] northd: fix missing port up when deleting and adding back an lsp 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" When a logical switch port was deleted and added back quickly, it could happen that the lsp was never reported up Signed-off-by: Xavier Simonart Acked-by: Ales Musil --- northd/northd.c | 17 +++++++++++------ tests/ovn.at | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index f8b046d83..0bea3bf2c 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -5192,11 +5192,16 @@ ls_port_has_changed(const struct nbrec_logical_switch_port *old, } static struct ovn_port * -ovn_port_find_in_datapath(struct ovn_datapath *od, const char *name) +ovn_port_find_in_datapath(struct ovn_datapath *od, const char *name, + const struct uuid uuid) { struct ovn_port *op; HMAP_FOR_EACH_WITH_HASH (op, dp_node, hash_string(name, 0), &od->ports) { if (!strcmp(op->key, name)) { + if (op->nbsp && memcmp(&op->nbsp->header_.uuid, &uuid, + sizeof(uuid))) { + continue; + } return op; } } @@ -5381,8 +5386,8 @@ ls_handle_lsp_changes(struct ovsdb_idl_txn *ovnsb_idl_txn, /* Compare the individual ports in the old and new Logical Switches */ for (size_t j = 0; j < changed_ls->n_ports; ++j) { struct nbrec_logical_switch_port *new_nbsp = changed_ls->ports[j]; - op = ovn_port_find_in_datapath(od, new_nbsp->name); - + op = ovn_port_find_in_datapath(od, new_nbsp->name, + new_nbsp->header_.uuid); if (!op) { if (!lsp_can_be_inc_processed(new_nbsp)) { goto fail; @@ -5671,9 +5676,9 @@ northd_handle_sb_port_binding_changes( * notification of that transaction, and we can ignore in this * case. Fallback to recompute otherwise, to avoid dangling * sb idl pointers and other unexpected behavior. */ - if (op) { - VLOG_WARN_RL(&rl, "A port-binding for %s is deleted but the " - "LSP still exists.", pb->logical_port); + if (op && op->sb == pb) { + VLOG_WARN_RL(&rl, "A port-binding for %s is deleted but " + "the LSP still exists.", pb->logical_port); return false; } } else { diff --git a/tests/ovn.at b/tests/ovn.at index 637d92bed..cfd39a918 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -36957,3 +36957,48 @@ AT_CHECK([grep -c "NXT_CT_FLUSH_ZONE" hv1/ovs-vswitchd.log], [0], [dnl OVN_CLEANUP([hv1]) AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD_NO_HV([ +AT_SETUP([port up with slow northd]) +ovn_start + +sleep_northd() { + echo northd going to sleep + AT_CHECK([kill -STOP $(cat northd/ovn-northd.pid)]) +} + +wake_up_northd() { + echo northd going to sleep + AT_CHECK([kill -CONT $(cat northd/ovn-northd.pid)]) +} + +net_add n1 +sim_add hv1 +as hv1 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.11 + +check ovn-nbctl --wait=hv ls-add ls0 +# Create a pilot port and wait it up to make sure we are ready for the real +# tests, so that the counters measured are accurate. +check ovn-nbctl --wait=hv lsp-add ls0 lsp-pilot -- lsp-set-addresses lsp-pilot "unknown" +ovs-vsctl add-port br-int lsp-pilot -- set interface lsp-pilot external_ids:iface-id=lsp-pilot +wait_for_ports_up +check ovn-nbctl --wait=hv sync + +check ovn-nbctl --wait=hv lsp-add ls0 lsp0-2 -- lsp-set-addresses lsp0-2 "aa:aa:aa:00:00:02 192.168.0.12" +ovs-vsctl add-port br-int lsp0-2 -- set interface lsp0-2 external_ids:iface-id=lsp0-2 +wait_for_ports_up +check ovn-nbctl --wait=hv sync + +sleep_northd +check ovn-nbctl lsp-del lsp0-2 +check ovn-nbctl lsp-add ls0 lsp0-2 -- lsp-set-addresses lsp0-2 "aa:aa:aa:00:00:02 192.168.0.12" +wake_up_northd + +check ovn-nbctl --wait=sb sync +wait_for_ports_up + +OVN_CLEANUP([hv1]) +AT_CLEANUP +])