From patchwork Fri Apr 26 17:54:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1928289 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=bFLFf5eH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (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 4VR0lF0gY3z1yP2 for ; Sat, 27 Apr 2024 03:56:09 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C9E6C83B56; Fri, 26 Apr 2024 17:56:06 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id kfOG09ZBoQrn; Fri, 26 Apr 2024 17:56:05 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3A69783B2F Authentication-Results: smtp1.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=bFLFf5eH Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3A69783B2F; Fri, 26 Apr 2024 17:56:05 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id ECB77C0077; Fri, 26 Apr 2024 17:56:04 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 732DAC0037 for ; Fri, 26 Apr 2024 17:56:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A43336148A for ; Fri, 26 Apr 2024 17:56:00 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5ZCFgH9QKlSX for ; Fri, 26 Apr 2024 17:55:59 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=ihrachys@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 3F0AB61474 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 3F0AB61474 Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bFLFf5eH 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 3F0AB61474 for ; Fri, 26 Apr 2024 17:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714154158; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IVE/xbs9d3hE7vVfQ2H/r6Dt9MleDAd/QfsN1TEvMDA=; b=bFLFf5eH5cpg/mLqJ+9Fwh+YcIY2VWnV9LqsEJoQYdK7wJH/4KUK//JCSE/5e7u92BZTsm 8wU7aNKV8pjilOr28codTsOmzDT7VzOYeRzcl5zgdntLhuqzNG3rp6vUyiu7T1FMB6QRmQ GI6oCqA1FT14O9PQz10xbY0i+eUbBbY= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-3P1zo78AOoqNMCbSYMzl0Q-1; Fri, 26 Apr 2024 13:55:56 -0400 X-MC-Unique: 3P1zo78AOoqNMCbSYMzl0Q-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-3c5ffab3db3so2810455b6e.3 for ; Fri, 26 Apr 2024 10:55:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714154155; x=1714758955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IVE/xbs9d3hE7vVfQ2H/r6Dt9MleDAd/QfsN1TEvMDA=; b=brB0hgPSI2kJz3pU4N/KT3m8ini2MbR8zJIKNxsXMACwnw70XPiwbcJm5gbp9K1c1p 5h6G9zgFZ0bRmJBHjgoKug7poZDMzeA7HSPlflpyTQkedNO8amdA7phLTj6dbRsUQU6I 3bpc75cI13phxoPHo2wu+9DPJLfpK1NHYFxfQZ6OOL6w8zNoZvMxwl+it7TZGWR3oZOy wRV84SZADi5kPf9QnvoyEgvf8kHYV8Ks3p+BAkCZZZc9/s8LB1XLmUclpYWqvTkBQ1RG 7OVFGr14yIQUbVGSnyN5CcMbmrrTlZiDCptiLk0mV6UH+Bf8StqCwXMV8ecHtb74dlL2 AKFQ== X-Gm-Message-State: AOJu0YzOEr2+JW4hpkAxnifYzP5XYlJ2mkLEv5iKAoNsBBO2TSjC5VMG D8CWxUzKUYSEyzobTtXTCM5DzOa+NyOVaNcTPMrPXGQmL321OFcj1EVjdKferwby4hq7yNdQ3pc 6HQdQhCGha24tOfKVyCvdQM8pG5oaQFDW+qe9+OBo0ETTEOHBibsKPFOZV/pRzx+vi/B2Y/IfZo Zk7adnJuPrhz7EEurCegnoUQTtM+oXCktdAw== X-Received: by 2002:a05:6808:2346:b0:3c7:4891:ab62 with SMTP id ef6-20020a056808234600b003c74891ab62mr4158419oib.27.1714154155367; Fri, 26 Apr 2024 10:55:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE6GaZQAi4HpxP9Vxbo1jG/kNSbE1eDh3Mv681kHSuNDTHgbMlS7gxXi0Nvu3Xx7FZgBsxZ9Q== X-Received: by 2002:a05:6808:2346:b0:3c7:4891:ab62 with SMTP id ef6-20020a056808234600b003c74891ab62mr4158404oib.27.1714154155039; Fri, 26 Apr 2024 10:55:55 -0700 (PDT) Received: from fedora38.localdomain.com ([172.73.180.250]) by smtp.gmail.com with ESMTPSA id w17-20020a056214013100b0069b57111a98sm7179855qvs.79.2024.04.26.10.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 10:55:54 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Fri, 26 Apr 2024 17:54:58 +0000 Message-ID: <20240426175501.858655-5-ihrachys@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240426175501.858655-1-ihrachys@redhat.com> References: <20240426175501.858655-1-ihrachys@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v7 4/6] northd: Don't create pb in ls_port_init too early. 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" This allows callers to avoid cleanup of the record in case the function fails. Signed-off-by: Ihar Hrachyshka --- northd/northd.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index 4800a44bd..934c22dac 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -4313,12 +4313,19 @@ ls_port_init(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, if (!ovn_port_assign_requested_tnl_id(sbrec_chassis_table, op)) { return false; } + /* Keep nonconflicting tunnel IDs that are already assigned. */ if (sb) { - op->sb = sb; - /* Keep nonconflicting tunnel IDs that are already assigned. */ if (!op->tunnel_key) { - ovn_port_add_tnlid(op, op->sb->tunnel_key); + ovn_port_add_tnlid(op, sb->tunnel_key); } + } + /* Assign new tunnel ids where needed. */ + if (!ovn_port_allocate_key(sbrec_chassis_table, op)) { + return false; + } + /* Create new binding, if needed. */ + if (sb) { + op->sb = sb; } else { /* XXX: the new SB port_binding will change in IDL, so need to handle * SB port_binding updates incrementally to achieve end-to-end @@ -4326,10 +4333,6 @@ ls_port_init(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, op->sb = sbrec_port_binding_insert(ovnsb_txn); sbrec_port_binding_set_logical_port(op->sb, op->key); } - /* Assign new tunnel ids where needed. */ - if (!ovn_port_allocate_key(sbrec_chassis_table, op)) { - return false; - } ovn_port_update_sbrec(ovnsb_txn, sbrec_chassis_by_name, sbrec_chassis_by_hostname, NULL, sbrec_mirror_table, op, NULL, NULL); @@ -4351,9 +4354,6 @@ ls_port_create(struct ovsdb_idl_txn *ovnsb_txn, struct hmap *ls_ports, if (!ls_port_init(op, ovnsb_txn, od, sb, sbrec_mirror_table, sbrec_chassis_table, sbrec_chassis_by_name, sbrec_chassis_by_hostname)) { - if (op->sb) { - sbrec_port_binding_delete(op->sb); - } ovn_port_destroy(ls_ports, op); return NULL; } @@ -4557,8 +4557,8 @@ ls_handle_lsp_changes(struct ovsdb_idl_txn *ovnsb_idl_txn, ni->sbrec_chassis_table, ni->sbrec_chassis_by_name, ni->sbrec_chassis_by_hostname)) { - if (op->sb) { - sbrec_port_binding_delete(op->sb); + if (sb) { + sbrec_port_binding_delete(sb); } ovn_port_destroy(&nd->ls_ports, op); goto fail;