From patchwork Wed Mar 30 00:46:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1610893 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=UJdeKTW4; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 4KSnp93Ddhz9sCq for ; Wed, 30 Mar 2022 11:47:29 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id AAD73611B7; Wed, 30 Mar 2022 00:47:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org 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 LBIfqfzrTLB8; Wed, 30 Mar 2022 00:47:23 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 666EC6119D; Wed, 30 Mar 2022 00:47:21 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C6FA2C0086; Wed, 30 Mar 2022 00:47:19 +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 B0792C0031 for ; Wed, 30 Mar 2022 00:47:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9F20341B58 for ; Wed, 30 Mar 2022 00:47:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 fgU6Q3ZoyXO7 for ; Wed, 30 Mar 2022 00:47:15 +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 smtp4.osuosl.org (Postfix) with ESMTPS id A7CF441B4C for ; Wed, 30 Mar 2022 00:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648601234; 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=CYigwSikf+74y8c8TjIp9Ca4s57U70X5PvBKdoL0MLk=; b=UJdeKTW4BMaIVOL23xf0oTqpl9mZli601wEJl5vqbVcpcdrDwXf4VtYD87a6vwcevQDA5n tC+oKk/AY60KOpxglKr55OtydardP+BgBn4QFUl1rOL0oTVQRzWgEdzsrz/J9veGFdabOC yrajKoRdpoDp2MBsJYHsdrkRlcq3mCw= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-Cmf-F7rdPXOvd06tHEpWRQ-1; Tue, 29 Mar 2022 20:47:13 -0400 X-MC-Unique: Cmf-F7rdPXOvd06tHEpWRQ-1 Received: by mail-qv1-f69.google.com with SMTP id d11-20020a0cffab000000b00440f965f77cso15036491qvv.4 for ; Tue, 29 Mar 2022 17:47:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CYigwSikf+74y8c8TjIp9Ca4s57U70X5PvBKdoL0MLk=; b=Q2ueMRiqBzymr+SiluUDj5rXnE3LCG3RBZPRrWbeN/PiccRJrJuTixHK+SpKKQVKyQ wLtHBtMZpAhjp5Ati54WQjmhFCfRWbD3RRQeSy7pF18NULHrEaqevTrqIikrrAcuQikQ C3p704V4bBhL+MNWthMfInJDnCQ1KnUT+qEuRfCxIKAyHbINE9rABNIH0GDA+MhXLWOU Az1Q2g746Y5EQbpLQUYP2EbZw+uGVT4tiERta0S+nmMvvr3TKmjqWAUeIQyWZ0raotOg wG0xOmGb6twVPSnnjF8LHJhXDSRpQuuID9vJVBZBvcM01P6IvlL/pQAoNHI9W+fnOin/ bYTA== X-Gm-Message-State: AOAM532DOyI3ix9orxAnM+bTg79fJJWidi0CWQHYNEGD+Ulrberlbv4b 6f7z+Yv2JUQ80AdN5D/f8zh75ahvZaMO7Er2U2wRZz1fa6SdUIATThj1qrLHxG3zlE04c37TfAy fMtj+7sbFEMGsTMjFAgFYdI2HhrBDr3EXUui4+rgRDW2bZ7YzxtgJj8IwuXjvJ1Nj X-Received: by 2002:a05:620a:d96:b0:67a:ee04:d947 with SMTP id q22-20020a05620a0d9600b0067aee04d947mr23409639qkl.237.1648601232478; Tue, 29 Mar 2022 17:47:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxwGAy6pTNVXbqM/uxiuwYBc49ss8p/c82+Uv6zBAxBr0RIHy0jw1NIX7RqN+egMz2mOoHEg== X-Received: by 2002:a05:620a:d96:b0:67a:ee04:d947 with SMTP id q22-20020a05620a0d9600b0067aee04d947mr23409625qkl.237.1648601232179; Tue, 29 Mar 2022 17:47:12 -0700 (PDT) Received: from fedora34.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id e20-20020ac84e54000000b002e06753cf70sm17957120qtw.6.2022.03.29.17.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 17:47:11 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Wed, 30 Mar 2022 00:46:50 +0000 Message-Id: <20220330004702.1025695-4-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220330004702.1025695-1-ihrachys@redhat.com> References: <20220330004702.1025695-1-ihrachys@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ihrachys@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v4 03/15] northd: separate code for nb->sb port binding chassis update 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 ovn_port_update_sbrec function became too long, and the next patches will touch the code to update chassis mapping for ports. This patch prepares for the next step. Signed-off-by: Ihar Hrachyshka --- northd/northd.c | 62 ++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index 17af42ac4..b46862b43 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -3144,6 +3144,40 @@ chassis_lookup(struct ovsdb_idl_index *sbrec_chassis_by_name, sbrec_chassis_by_hostname, name_or_hostname); } +static void +ovn_port_update_sbrec_chassis( + struct ovsdb_idl_index *sbrec_chassis_by_name, + struct ovsdb_idl_index *sbrec_chassis_by_hostname, + const struct ovn_port *op) +{ + const char *requested_chassis; /* May be NULL. */ + bool reset_requested_chassis = false; + requested_chassis = smap_get(&op->nbsp->options, + "requested-chassis"); + if (requested_chassis) { + const struct sbrec_chassis *chassis = chassis_lookup( + sbrec_chassis_by_name, sbrec_chassis_by_hostname, + requested_chassis); + if (chassis) { + sbrec_port_binding_set_requested_chassis(op->sb, chassis); + } else { + reset_requested_chassis = true; + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT( + 1, 1); + VLOG_WARN_RL( + &rl, + "Unknown chassis '%s' set as " + "options:requested-chassis on LSP '%s'.", + requested_chassis, op->nbsp->name); + } + } else if (op->sb->requested_chassis) { + reset_requested_chassis = true; + } + if (reset_requested_chassis) { + sbrec_port_binding_set_requested_chassis(op->sb, NULL); + } +} + static void ovn_port_update_sbrec(struct northd_input *input_data, struct ovsdb_idl_txn *ovnsb_txn, @@ -3335,32 +3369,8 @@ ovn_port_update_sbrec(struct northd_input *input_data, sbrec_port_binding_set_ha_chassis_group(op->sb, NULL); } - const char *requested_chassis; /* May be NULL. */ - bool reset_requested_chassis = false; - requested_chassis = smap_get(&op->nbsp->options, - "requested-chassis"); - if (requested_chassis) { - const struct sbrec_chassis *chassis = chassis_lookup( - sbrec_chassis_by_name, sbrec_chassis_by_hostname, - requested_chassis); - if (chassis) { - sbrec_port_binding_set_requested_chassis(op->sb, chassis); - } else { - reset_requested_chassis = true; - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT( - 1, 1); - VLOG_WARN_RL( - &rl, - "Unknown chassis '%s' set as " - "options:requested-chassis on LSP '%s'.", - requested_chassis, op->nbsp->name); - } - } else if (op->sb->requested_chassis) { - reset_requested_chassis = true; - } - if (reset_requested_chassis) { - sbrec_port_binding_set_requested_chassis(op->sb, NULL); - } + ovn_port_update_sbrec_chassis(sbrec_chassis_by_name, + sbrec_chassis_by_hostname, op); } else { const char *chassis = NULL; if (op->peer && op->peer->od && op->peer->od->nbr) {