From patchwork Tue Feb 15 03:57:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592894 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=beX5xxs9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4JyS3q2LvYz9sFw for ; Tue, 15 Feb 2022 14:57:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 2CF93408DD; Tue, 15 Feb 2022 03:57:55 +0000 (UTC) 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 EgLClyiT7gjg; Tue, 15 Feb 2022 03:57:53 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 4B655405F6; Tue, 15 Feb 2022 03:57:52 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 28AEBC007D; Tue, 15 Feb 2022 03:57:51 +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 D9C06C000B for ; Tue, 15 Feb 2022 03:57:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D6BDD819ED for ; Tue, 15 Feb 2022 03:57:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 4hHi2pGd4CmW for ; Tue, 15 Feb 2022 03:57:48 +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.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 341E4813BB for ; Tue, 15 Feb 2022 03:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897466; 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=DK0BZTqGe/yNgMuIe1bkSeGtVcZHZWCevzo8z9aMDKk=; b=beX5xxs9dWKM2K69LAo2C3cvTF0I4qiWX8bLzNTwdy3wgzwedSLlshOXeSawwv0Yg66IpJ BUSLKF7TLgOiQmzc5AZfxdeRkqR4x69VM1T+d3IIflv5WT98jBnPLedyUnHsa3GEM7n5wv 5L8LAX2/vHSwDyI2x35KanEDWyhE8Hk= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-467--l4zrTkXPCCL7QGOO-4vpg-1; Mon, 14 Feb 2022 22:57:46 -0500 X-MC-Unique: -l4zrTkXPCCL7QGOO-4vpg-1 Received: by mail-qt1-f199.google.com with SMTP id d25-20020ac84e39000000b002d1cf849207so14004485qtw.19 for ; Mon, 14 Feb 2022 19:57:46 -0800 (PST) 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=DK0BZTqGe/yNgMuIe1bkSeGtVcZHZWCevzo8z9aMDKk=; b=ufHlmlKZ+KYn4RoRaw/RUtdmuTrDyZwsHWM/5AkfaOEyDKD90Wgj4yAxBanvlhBBjo R00sdSjZTeMxeDMTIni62GHiwXyclnqdWEYH8FKIUbtBHw1evnUbt4wirYcaGAe3nQNs Nwo8v17LVHDYEB7teJtCznKullXMeLmWiGmQlOQEPQlW6yDWYn5ojjJYOXpgoD7tVZUX uTXV7Qyvh2KyRaCilDfoRk1k79eVBJ922j4DBg88Air3Sor1g2vF5F6KiuT3hHN7NtuQ HO8VUaZH1pbdUmyiO9/IOrABGGaCjT2c92FC9ACC32v8W9kmADHqzAvlukEBjaA6/jzB vYww== X-Gm-Message-State: AOAM533XQWj/hWK7fKauEJdBUN/l4gEi8XZvqBn+PgrF7KC9szyLgxmD mWuRbmTDIXhkd7N7GWpxG1AjgF4AGLNLzAfR+IXxmk2+mA6jcx2F3JpbKpXfaBRzq+Wtie3SbTa nKr4ipOzH1eaDIJa9yjDq25KuBPIXEHFTnB6vYazSkIaR/19apSt36vd8ZaTF4/FH X-Received: by 2002:a05:6214:762:: with SMTP id f2mr1230939qvz.24.1644897465030; Mon, 14 Feb 2022 19:57:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJymReoRaENiX6WdxQZAOgi3O2QQ/yy2ueuHEq0oGi1TH4vi0AprHtnK+Ejm6cidmkjzDUZc9g== X-Received: by 2002:a05:6214:762:: with SMTP id f2mr1230931qvz.24.1644897464778; Mon, 14 Feb 2022 19:57:44 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:43 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:23 +0000 Message-Id: <20220215035737.1820679-2-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 01/15] tests: log more info on OVN_CHECK_PACKETS* failure 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" Right now it logs diff between expected and observed only when enough packets arrived. If less than expected packets arrived, only the number of packets observed was logged, but not the packets themselves. This patch makes the functions log the expected packets, the observed packets, as well as the diff between them in this situation. Signed-off-by: Ihar Hrachyshka --- tests/ovn.at | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/ovn.at b/tests/ovn.at index 957eb7850..5d587dde2 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -10,7 +10,19 @@ # testsuite file since the shell function is only emitted once even # when this macro is invoked many times. m4_divert_text([PREPARE_TESTS], - [ovn_check_packets__ () { + [dump_diff__ () { + local rcv_pcap=$1 exp_text=$2 + rcv_text=`echo "$rcv_pcap.packets" | sed 's/\.pcap//'` + echo "Expected:" + sort $exp_text + echo "Received:" + sort $rcv_text + sort $exp_text -o $exp_text.sorted + sort $rcv_text -o $rcv_text.sorted + echo "Diff:" + diff -u $exp_text.sorted $rcv_text.sorted + } + ovn_check_packets__ () { echo echo "$3: checking packets in $1 against $2:" rcv_pcap=$1 @@ -21,7 +33,8 @@ m4_divert_text([PREPARE_TESTS], [$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $rcv_pcap > $rcv_text rcv_n=`wc -l < "$rcv_text"` echo "rcv_n=$rcv_n exp_n=$exp_n" - test $rcv_n -ge $exp_n]) + test $rcv_n -ge $exp_n], + [dump_diff__ "$rcv_pcap" "$exp_text"]) sort $exp_text > expout } ovn_check_packets_remove_broadcast__ () { @@ -35,18 +48,19 @@ m4_divert_text([PREPARE_TESTS], sed -i '/ffffffffffff/d' $rcv_text rcv_n=`wc -l < "$rcv_text"` echo "rcv_n=$rcv_n exp_n=$exp_n" - test $rcv_n -ge $exp_n]) + test $rcv_n -ge $exp_n], + [dump_diff__ "$rcv_pcap" "$exp_text"]) sort $exp_text > expout } ]) m4_define([OVN_CHECK_PACKETS], [ovn_check_packets__ "$1" "$2" "__file__:__line__" - AT_CHECK([sort $rcv_text], [0], [expout])]) + AT_CHECK([sort $rcv_text], [0], [expout], [ignore], [dump_diff__ "$1" "$2"])]) m4_define([OVN_CHECK_PACKETS_REMOVE_BROADCAST], [ovn_check_packets_remove_broadcast__ "$1" "$2" "__file__:__line__" - AT_CHECK([sort $rcv_text], [0], [expout])]) + AT_CHECK([sort $rcv_text], [0], [expout], [ignore], [dump_diff__ "$1" "$2"])]) m4_define([OVN_CHECK_PACKETS_CONTAIN], [ovn_check_packets__ "$1" "$2" "__file__:__line__" From patchwork Tue Feb 15 03:57:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592893 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=WQ2IJ0Vb; 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 4JyS3p5FrBz9sFv for ; Tue, 15 Feb 2022 14:57:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A95FF60E43; Tue, 15 Feb 2022 03:57:55 +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 ZNpKTY--TMXO; Tue, 15 Feb 2022 03:57:54 +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 B77E260E52; Tue, 15 Feb 2022 03:57:53 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E2B96C002D; Tue, 15 Feb 2022 03:57:51 +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 221C7C007D for ; Tue, 15 Feb 2022 03:57:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id F22A240423 for ; Tue, 15 Feb 2022 03:57:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 fJYzuZyH7UnU for ; Tue, 15 Feb 2022 03:57:49 +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 smtp2.osuosl.org (Postfix) with ESMTPS id 12E8340004 for ; Tue, 15 Feb 2022 03:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897468; 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=rsc1vc2UYaUxT44Ef80PMb+bkF3YX+bjZjcaC8sHLyM=; b=WQ2IJ0VbE/MP4W28FDa63Pbth44IaO58zZ81fIV/SDYWyE6OTV96to7MXosf2l09R9SY+S xewhVEL6dRBO6BC3xcx5I9GZbtHV4ZRTlqznoqYukoJlyT9sg6T1Vvbu1CIQ9E4ySJQF/6 qFQ5W8FaVTMjnPxOqRLs8KnuHN+YvR4= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-418-wsWGX3g5OTe1NV7Ad-ZhlA-1; Mon, 14 Feb 2022 22:57:47 -0500 X-MC-Unique: wsWGX3g5OTe1NV7Ad-ZhlA-1 Received: by mail-qt1-f198.google.com with SMTP id h5-20020ac87765000000b002cff8751c63so14059574qtu.3 for ; Mon, 14 Feb 2022 19:57:47 -0800 (PST) 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=rsc1vc2UYaUxT44Ef80PMb+bkF3YX+bjZjcaC8sHLyM=; b=MDJOjrxfGqHbPDmda9F6wxDpm8fdRq+5vrWkUEcsDtBhOkLSZZHrU/fpWyo72Z82h0 AGa2d3SsBdOq+DgRPbJJ4XwBDNISxNF4nLIFT20Gz6WnUnLUJoWwS5E1BPxYkgIK01H9 GnZZGIPKFH1WDhrCjVdecvtLHFv0JNFd4LM31w7/SfT3RBU9a8CZeL/P+7ZDPeVUz7tq Cg3TqU0N5Xk8Tjge5ZjnJLGIVhi9aNDpUlSJmh0bEYd8wi4rqTk/aX3Qlfy91BxkSx9/ /vZydR+mXQRWJdOHRrE8XGZ+2RV9dgAPPlrUGipmjciQaSBYb7aMREED4/CBvIDWlDrX MHfw== X-Gm-Message-State: AOAM532KlsaS9l0ipNnK0E9kLdG8I3fLt0rZllERys5m8/84lVAxGpOU 0H9uvVM4bF5bOS5mn+us9bHuwwLEzoZLV8tFH2lB/OSTm1AWNY+v2y+8qKGhZsBGXeRqS7R8l4O +wLbFlN1N4i3s++gHBEdxTgAO9UZrZ4CVC09dn7tYjpPqqlNFOwgFikHwGt8IYqIR X-Received: by 2002:ad4:4b2c:: with SMTP id s12mr1289968qvw.125.1644897466411; Mon, 14 Feb 2022 19:57:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJym8HL6vzsMl7WFCTKv9KJe1S+fmhr+ccVzXzZxUHjyu7ithq8xdqZzqsLjHTLxqMzNULpVbA== X-Received: by 2002:ad4:4b2c:: with SMTP id s12mr1289962qvw.125.1644897466167; Mon, 14 Feb 2022 19:57:46 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:45 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:24 +0000 Message-Id: <20220215035737.1820679-3-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 02/15] tests: don't bail from OVN_CHECK_PACKETS_CONTAIN prematurily 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 the expected number of packets arrive, OVN_CHECK_PACKETS_CONTAIN bails out. But it should bail out from waiting only when the expected packets were observed or when timeout reached, because the whole point of the function is to allow to ignore some packets (usually garps generated by ports) while waiting on the desired packets to arrive. Signed-off-by: Ihar Hrachyshka --- tests/ovn.at | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/ovn.at b/tests/ovn.at index 5d587dde2..bbba41af4 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -52,6 +52,17 @@ m4_divert_text([PREPARE_TESTS], [dump_diff__ "$rcv_pcap" "$exp_text"]) sort $exp_text > expout } + ovn_wait_packets__ () { + echo "$3: waiting for packets from $2 at $1:" + rcv_pcap=$1 + rcv_text=`echo "$rcv_pcap.packets" | sed 's/\.pcap//'` + exp_text=$2 + OVS_WAIT_UNTIL( + [$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $rcv_pcap > $rcv_text + sort $exp_text > expout + test x"$(sort $rcv_text | comm -2 -3 expout -)" = "x"], + [dump_diff__ "$rcv_pcap" "$exp_text"]) + } ]) m4_define([OVN_CHECK_PACKETS], @@ -63,8 +74,7 @@ m4_define([OVN_CHECK_PACKETS_REMOVE_BROADCAST], AT_CHECK([sort $rcv_text], [0], [expout], [ignore], [dump_diff__ "$1" "$2"])]) m4_define([OVN_CHECK_PACKETS_CONTAIN], - [ovn_check_packets__ "$1" "$2" "__file__:__line__" - AT_CHECK([sort $rcv_text | comm -2 -3 expout -], [0], [])]) + [ovn_wait_packets__ "$1" "$2" "__file__:__line__"]) AT_BANNER([OVN components]) From patchwork Tue Feb 15 03:57:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592896 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=AloKBqZb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::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 4JyS3t1j9Xz9sFv for ; Tue, 15 Feb 2022 14:58:02 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 417D960F35; Tue, 15 Feb 2022 03:57:57 +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 2pf2ZE5USVCJ; Tue, 15 Feb 2022 03:57:56 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 2955360E56; Tue, 15 Feb 2022 03:57:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B4A37C0078; Tue, 15 Feb 2022 03: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 [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id B8461C0080 for ; Tue, 15 Feb 2022 03:57:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id B111C4056E for ; Tue, 15 Feb 2022 03:57:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 l4Y5jxTkQz80 for ; Tue, 15 Feb 2022 03:57:51 +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.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id C8985401C8 for ; Tue, 15 Feb 2022 03:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897469; 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=eLpvYSFSL5zMVGu2PhIW55QTYnVhgwKW9xi3GsFv4Mw=; b=AloKBqZbg/Ge363/Eq//RE0zZEisApLvh7kGRTP0icH63aWs/z0izqOcAoDWcin3VJtv+G yzrwrgFvWrQ4FogBJ4+gdeTx1qefbnoUC7wTUhk/N5z+tJHC/bIXqEs8l+6XL0EiV+hIxA rr2Nr2zwEKp/9wondezwbIFjtUCIzJU= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-207-ARKcSXYCP-26dJpTXFcRIA-1; Mon, 14 Feb 2022 22:57:48 -0500 X-MC-Unique: ARKcSXYCP-26dJpTXFcRIA-1 Received: by mail-qv1-f70.google.com with SMTP id 3-20020ad45b83000000b00423e8603906so13156033qvp.1 for ; Mon, 14 Feb 2022 19:57:48 -0800 (PST) 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=eLpvYSFSL5zMVGu2PhIW55QTYnVhgwKW9xi3GsFv4Mw=; b=G6DQ6+JTos9igHZpYMkwQSsyYAfqQUjT6zZpJJDQ3F+3XgH2lltJBPy0zry/xb7WJD oELyMdzPB4i5xWQpc9utTS7xbeLQf3/dnM2xPj0UDKLZw1xtcdrhhcNP2BPMx0J9b/zx av4KbaB4T1urp0OyU8ldN5+V4Gz/3ZiSyjWicfDXc7RsnyjPZjiVIvEs2VplkYDCTZ6a Yv5VieQZLIGyqvj1IdTSuXJw8P+MBJyAfsarIaT+zBNtbR0QtXcDp+Q/QvUla80Cwk8N Z5+iTr1E+FH/0MqA4AK7YuEhC9tyq0cD5YAPtkIb3NpE0gUn4xhlYo5VYKfcBsXL02UW KOXA== X-Gm-Message-State: AOAM531oVRuo9vw4aGmkIBvgaikyQCnyxIp04L3k1H2AXMPfxHWM7hwq kNnJYPTNG0UA9Qlv13+OLOQZ+8fxqmCW+liY8uuH5wXNK11q8mYo1XC823Dm7pasiTdsCRNUuNN 27kevcqDOXivUpl+kQcT8KPqE+eHK6N2RnfY2KmmsPIZn1eLA3IR1a048540mg6cw X-Received: by 2002:a05:620a:3cf:: with SMTP id r15mr1146075qkm.778.1644897467577; Mon, 14 Feb 2022 19:57:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJypdxH9Bem0czIfMfLiEo9ZZJHYjVH5OEJlLzWBDFuMoUkw1qW56KtJqsklWf0yCuVRlPU26g== X-Received: by 2002:a05:620a:3cf:: with SMTP id r15mr1146066qkm.778.1644897467324; Mon, 14 Feb 2022 19:57:47 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:46 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:25 +0000 Message-Id: <20220215035737.1820679-4-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 03/15] Introduce chassis_is_vtep 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 tiny helper will be reused later. Signed-off-by: Ihar Hrachyshka --- controller/physical.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index 6bfa2304d..3a7fbfb21 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -1408,6 +1408,12 @@ fanout_to_chassis(enum mf_field_id mff_ovn_geneve, } } +static bool +chassis_is_vtep(const struct sbrec_chassis *chassis) +{ + return smap_get_bool(&chassis->other_config, "is-vtep", false); +} + static void consider_mc_group(struct ovsdb_idl_index *sbrec_port_binding_by_name, enum mf_field_id mff_ovn_geneve, @@ -1519,8 +1525,7 @@ consider_mc_group(struct ovsdb_idl_index *sbrec_port_binding_by_name, /* Add remote chassis only when localnet port not exist, * otherwise multicast will reach remote ports through localnet * port. */ - if (smap_get_bool(&port->chassis->other_config, - "is-vtep", false)) { + if (chassis_is_vtep(port->chassis)) { sset_add(&vtep_chassis, port->chassis->name); } else { sset_add(&remote_chassis, port->chassis->name); From patchwork Tue Feb 15 03:57:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592895 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=T0BGmsy9; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JyS3s13D2z9sFv for ; Tue, 15 Feb 2022 14:58:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C9C6A41526; Tue, 15 Feb 2022 03:57:58 +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 vL5RuN2muxgl; Tue, 15 Feb 2022 03:57:57 +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 C0CDA41511; Tue, 15 Feb 2022 03:57:56 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 68BB1C0073; Tue, 15 Feb 2022 03:57:55 +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 D5ED4C007A for ; Tue, 15 Feb 2022 03:57:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id AEA6860E18 for ; Tue, 15 Feb 2022 03:57:52 +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 31wiMgF9l47G for ; Tue, 15 Feb 2022 03:57:52 +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.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 0E34460E3B for ; Tue, 15 Feb 2022 03:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897471; 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=t0iu22tWRdFqZybcoqel5xkrxj0R5CUygcf41giQt2k=; b=T0BGmsy9Bveib4MuupGIuECki2fJ/nzo7Df0emh3Br/kwlu9z4lznZiy5A8Xm6cF3LEHyd jvMtzqG6EwpqZERTJOBF3hF3huOYd+Afn4rQ2tXru/c4zCfXKU8aHhuDDSNaqo3Z5gE13y N3nxs1QwQWy6ZTkCJn+RXBSm+l1My30= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-127-J00rmhzfMoyGChOpFVXF3A-1; Mon, 14 Feb 2022 22:57:49 -0500 X-MC-Unique: J00rmhzfMoyGChOpFVXF3A-1 Received: by mail-qt1-f200.google.com with SMTP id u18-20020a05622a011200b002dc8ccfa79aso967590qtw.13 for ; Mon, 14 Feb 2022 19:57:49 -0800 (PST) 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=t0iu22tWRdFqZybcoqel5xkrxj0R5CUygcf41giQt2k=; b=upPfn6aL+4RM7QSQ/kctbu7fRWU+Tyha5d2vjBKkSc1GF3MKeuvNTRcx30rqCjYUtJ K2Y/R6avgLuTgar5SY15IelqpWvtJCpaRTz4vUz02hkuXrFS4MLe8jn6WZnQBmXb9Vm5 2GyGn7ftLkjaqtS0ZqCh46sC2iblcwCZU9qo7zmhdum4lE9N9yfRIG8QFInxIVzYbnHV 7Mt9h+2HAA5ISOwcbIrSPfSgIRhkg/+Vi3KrgS2VIaTv6rxkR3u4E8/04q0YH5TEcmGA HtoHYK99nP52YtZY/ostXaBuOA7aXT/F7HNkEwqUQdXbUjiD7Li8l8REo4+g9FdPglmh Jn7w== X-Gm-Message-State: AOAM533Ixf2ho5ZX24HDhh1qV/W3QNZWjfeuUtsuvrz6sjcnLPqzHNAF Qr2ZG8jyg9/nqAzlgH664AhENMu56XFLwkEajiVzTeQGe7Ned/eyy606Zyuz9dYzOJeNkX3zNu8 n6bv0IGF6pqq87Kff/1sIhWXNZlW60QYzx4xCn7KIa3KH+2cIP/EO8hKbDZr6rKcF X-Received: by 2002:ad4:5d4e:: with SMTP id jk14mr1247836qvb.68.1644897468968; Mon, 14 Feb 2022 19:57:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRRkNjqOY1gT9aXXVuXkM+lhcWSsH8nS4f+ITzmTeM5gijpIGK8tU2a38mGqEG6BdPx1tUCw== X-Received: by 2002:ad4:5d4e:: with SMTP id jk14mr1247824qvb.68.1644897468690; Mon, 14 Feb 2022 19:57:48 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:47 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:26 +0000 Message-Id: <20220215035737.1820679-5-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 04/15] northd: introduce separate function to look up chassis 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 function will be reused later. Signed-off-by: Ihar Hrachyshka --- northd/northd.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index fc7a64f99..0f694cb2d 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -3120,6 +3120,18 @@ ovn_update_ipv6_prefix(struct hmap *ports) } } +static const struct sbrec_chassis * +chassis_lookup(struct ovsdb_idl_index *sbrec_chassis_by_name, + struct ovsdb_idl_index *sbrec_chassis_by_hostname, + const char *name_or_hostname) +{ + const struct sbrec_chassis *chassis; /* May be NULL. */ + chassis = chassis_lookup_by_name(sbrec_chassis_by_name, + name_or_hostname); + return chassis ? chassis : chassis_lookup_by_hostname( + sbrec_chassis_by_hostname, name_or_hostname); +} + static void ovn_port_update_sbrec(struct northd_input *input_data, struct ovsdb_idl_txn *ovnsb_txn, @@ -3315,12 +3327,9 @@ ovn_port_update_sbrec(struct northd_input *input_data, requested_chassis = smap_get(&op->nbsp->options, "requested-chassis"); if (requested_chassis) { - const struct sbrec_chassis *chassis; /* May be NULL. */ - chassis = chassis_lookup_by_name(sbrec_chassis_by_name, - requested_chassis); - chassis = chassis ? chassis : chassis_lookup_by_hostname( - sbrec_chassis_by_hostname, 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 { From patchwork Tue Feb 15 03:57:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592897 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=OUk80Um2; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JyS3w1X0Wz9sFv for ; Tue, 15 Feb 2022 14:58:04 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6832541552; Tue, 15 Feb 2022 03:58:00 +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 74lUAzV-UeN7; Tue, 15 Feb 2022 03:57:59 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 5604B41512; Tue, 15 Feb 2022 03:57:58 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1C621C0073; Tue, 15 Feb 2022 03:57:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 26D60C007E for ; Tue, 15 Feb 2022 03:57:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 4BF8F82835 for ; Tue, 15 Feb 2022 03:57:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 8kZlqE2bP4bx for ; Tue, 15 Feb 2022 03:57:53 +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.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4225382702 for ; Tue, 15 Feb 2022 03:57:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897472; 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=OttfKoMWvyc5YEICm6hnhNeJw4yr0PqMWP7wuUXwnMg=; b=OUk80Um2IiJMM4SbsxGu0thhQgFDaE5loiFhebaEDFPSw6OeQD8B/UWMHDztLEt7D92ngl EAKuT1A5svzyeHx4L9/rHXEtz7qaB1TUElyqvgI6A39X8Jixbl6lRfZjji+QEBbfysu4FJ sYC2lnsj2B846rEvvnCtWt0sGzUbbY4= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-147-Rba782spOja5hNN37WeaDg-1; Mon, 14 Feb 2022 22:57:51 -0500 X-MC-Unique: Rba782spOja5hNN37WeaDg-1 Received: by mail-qt1-f199.google.com with SMTP id d13-20020ac85acd000000b002dca2fb15a4so133581qtd.0 for ; Mon, 14 Feb 2022 19:57:51 -0800 (PST) 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=OttfKoMWvyc5YEICm6hnhNeJw4yr0PqMWP7wuUXwnMg=; b=Dejp7X3MNnG4w8+JbJ6lOFPZcn24znvNOZdgNXTd/R96i0cmFbnbN1/AKpnY7sTCuP dmmgBaKTyb/ReLlk3B6t6GvFZ+EqPbBrIchUSsAIIEXK4wAcB2A91/c5g9D4Nnlp9+8Z RzVYvutpV5KhAqdRnQ3p6dEq0VFMcxaqa9EK+B4PWJ8w9ME60alXoWwJ8Y6ysPpfE5RU /aLqWTK0yd/2EAlt8nk9SYHrXbcGPKxwn+6Fk0GPx3MOzWHfHocf+YrJK49RzTZoafcM esIqn7ZgnFBCU0CmzRodQ/7AFK4OzAiYsW7YXBbsk6MJ3an0j6f1bpdqi7k3bgRx07v+ 5g9Q== X-Gm-Message-State: AOAM5337ZIrLAvvkGT+W+D+Sd41cKb34htOFINLB7qPLoZUZwVFxps2r sP1rIiYc/NYDYdL8Ai3AI+nnUyHgbr0NeSbK/5YeIhdvONpOeelULYjJmIfnEkPnbE7Im8aggr3 6ummw1gmNp+uKEOp8v6oGNXVOBc5JH31x78EuO6I/ROdd2TdK0tENPRT/TMogAqYD X-Received: by 2002:a37:4043:: with SMTP id n64mr1083394qka.467.1644897470287; Mon, 14 Feb 2022 19:57:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+mvV+UI9eo2RZx3WTFZBzUhgiFET9xOEuR4YW1jrbMBbk7a8MekVeoKbPTucANB18/kyRJQ== X-Received: by 2002:a37:4043:: with SMTP id n64mr1083383qka.467.1644897470023; Mon, 14 Feb 2022 19:57:50 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:49 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:27 +0000 Message-Id: <20220215035737.1820679-6-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 05/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 0f694cb2d..0179b2bc9 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -3132,6 +3132,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, @@ -3322,32 +3356,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) { From patchwork Tue Feb 15 03:57:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592903 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=bTOUfscw; 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 4JyS4R3fnYz9sFv for ; Tue, 15 Feb 2022 14:58:31 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 95EF661C4E; Tue, 15 Feb 2022 03:58:29 +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 tlflFT_4zBsf; Tue, 15 Feb 2022 03:58:25 +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 BB9FA61B85; Tue, 15 Feb 2022 03:58:20 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2AF1AC007A; Tue, 15 Feb 2022 03:58:18 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 195E3C0011 for ; Tue, 15 Feb 2022 03:58:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 68B97408E0 for ; Tue, 15 Feb 2022 03:58:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 axcQ-Z6qKhnw for ; Tue, 15 Feb 2022 03:57:59 +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 smtp2.osuosl.org (Postfix) with ESMTPS id 776944090E for ; Tue, 15 Feb 2022 03:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897478; 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=3Q7lPxxxrWpSAOOF5UnIwywcxoBO3MKARdENYH/wBss=; b=bTOUfscw/haiY205CkCkslRjEyznvWtdsqusVBAs3DzwvmDE9wkmFvc+CdSbl6zxzVd7RY 55Bk01/9HlT92csy8ZxZdDFbvzZBsRFGmk47SVuyEuyvx5EA2tLlcBNylIyYLhtnFxgeEw KlULBnf6IkO9Jk7mkR4CVvolNGHZpqE= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516-XuvSLhaCPi-2TRb1bJCqkw-1; Mon, 14 Feb 2022 22:57:52 -0500 X-MC-Unique: XuvSLhaCPi-2TRb1bJCqkw-1 Received: by mail-qv1-f71.google.com with SMTP id a12-20020a056214062c00b0042c2f3fca04so12718200qvx.21 for ; Mon, 14 Feb 2022 19:57:52 -0800 (PST) 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=3Q7lPxxxrWpSAOOF5UnIwywcxoBO3MKARdENYH/wBss=; b=sHapDhjoWPcIYiLgvNpySFFSj7bUocgn7cVxyga0rDl3Sf36/e0HzVzyWm4mDtRCqY yBq5KWCmpJT7s6KoJdDBJ2Z6iMTpm7Ulr1yJVJaywwV9jEdWoPK6Pggz+BKvppYi6cGR 8tNTpB7vFBlZZBEci6Cqxzbk52Z//jUgApMI7onaL5wmEzDzlkJ9PSnI4LqWQoquIOqU Hf6QAp9pxvSvD3nmzv1cMrRionmWflab24/sYxfeQep2bHoH9FnUtJ4G+NoxC2EvqsCi RlR7MAh2WKemz/m5Z0nCOgr8LZL7/e7c1nC6B7PV7gMZswI4nf4WieT0Gv+1R0oBSk2T T7IA== X-Gm-Message-State: AOAM532rrWhjw3GNB3Z9qgdBdZOXEpzKU0ulM8/uNCmnhrs/L4lBHk5A E7KAEAa1QUlsRCkc0Lz68XQUz0kown/XKYSll00wS2x/XEXxO3ZbpUEdLMmv4unoAtBmQE7TESg ka2HDvhWYKpQKo+RKnBgRSCfUmK+tm6jPDt0NglafpZAxWMOkZZC7/S62wUs9NlIV X-Received: by 2002:a05:6214:e62:: with SMTP id jz2mr1286025qvb.84.1644897471710; Mon, 14 Feb 2022 19:57:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWVIW944bXJiFfhmvg2SxY7muKZl0uX8Q+/TjpGbynLmyBZGYJDtRF1UhYDSiQwOQLyGbeQQ== X-Received: by 2002:a05:6214:e62:: with SMTP id jz2mr1286015qvb.84.1644897471401; Mon, 14 Feb 2022 19:57:51 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:50 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:28 +0000 Message-Id: <20220215035737.1820679-7-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 06/15] Pass chassis and encap into get_port_binding_tun 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" Next patches will need the same functionality while passing a different chassis / encap configuration that is not the primary for a port binding. Signed-off-by: Ihar Hrachyshka --- controller/physical.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index 3a7fbfb21..7ad142293 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -124,17 +124,15 @@ put_resubmit(uint8_t table_id, struct ofpbuf *ofpacts) } /* - * For a port binding, get the corresponding ovn-chassis-id tunnel port - * from the associated encap. + * For an encap and a chassis, get the corresponding ovn-chassis-id tunnel + * port. */ static struct chassis_tunnel * -get_port_binding_tun(const struct sbrec_port_binding *binding, +get_port_binding_tun(const struct sbrec_encap *encap, + const struct sbrec_chassis *chassis, const struct hmap *chassis_tunnels) { - struct sbrec_encap *encap = binding->encap; - struct sbrec_chassis *chassis = binding->chassis; struct chassis_tunnel *tun = NULL; - if (encap) { tun = chassis_tunnel_find(chassis_tunnels, chassis->name, encap->ip); } @@ -295,7 +293,8 @@ put_remote_port_redirect_overlay(const struct if (!is_ha_remote) { /* Setup encapsulation */ const struct chassis_tunnel *rem_tun = - get_port_binding_tun(binding, chassis_tunnels); + get_port_binding_tun(binding->encap, binding->chassis, + chassis_tunnels); if (!rem_tun) { return; } From patchwork Tue Feb 15 03:57:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592900 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=LnWh1BYR; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JyS440v86z9sFv for ; Tue, 15 Feb 2022 14:58:12 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9F45C82B1E; Tue, 15 Feb 2022 03:58:09 +0000 (UTC) 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 00vAFWJJejzx; Tue, 15 Feb 2022 03:58:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4B43782EB5; Tue, 15 Feb 2022 03:58:04 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E75A0C0078; Tue, 15 Feb 2022 03:58:03 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 138CEC007B for ; Tue, 15 Feb 2022 03:58:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A85FF405EF for ; Tue, 15 Feb 2022 03:57:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 wFsNOkjfjQ-n for ; Tue, 15 Feb 2022 03:57:56 +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.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 362DC408E9 for ; Tue, 15 Feb 2022 03:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897475; 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=UhPTflWOznNFTT5iLU8NjWX/s8XRLBJydHrw98NudyU=; b=LnWh1BYR3EtXOiqxCPCNbPCO7zsRu2U1YKSB3LYu37XpOj8hEqsf/mTTmzzOT883BlGGyP li+MeOBAoiYuByInT3cEWL/4jPsC1PQGjaZDU4RHnhG2l/xPN3L6kiLpuSuE9JanmJixq/ uMV4pZHN3VCcoFSTzZGO9uzogjIEORw= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-101-gqprk0rbPYqxMiWuyzWqZA-1; Mon, 14 Feb 2022 22:57:53 -0500 X-MC-Unique: gqprk0rbPYqxMiWuyzWqZA-1 Received: by mail-qv1-f72.google.com with SMTP id kd18-20020a056214401200b0042de5c14702so1836654qvb.12 for ; Mon, 14 Feb 2022 19:57:53 -0800 (PST) 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=UhPTflWOznNFTT5iLU8NjWX/s8XRLBJydHrw98NudyU=; b=WTThwGqEGJT1GdRvaJhpJsX30uIti6FP3YvqgxAs8FG2DdusNQayG5CtjfxhinzfQM lT6F2iOkMfAk0W715eIMjykRlqsDKk0ntiEe1SDP4PgHlTpghT0bBd0UO7bwcETrXgTD 1d3Qam7aw8mOHui/X8aPvVjYvhAwUJdHpwzomp62oL+jLnUpv3ps2HAW5qVNntxBgE3u 09A7mNl/c/aSCttghVC/0g5jnc9Zq8/zzgUCX3yfhUIc6JqGkFmVg3MpUk5FOaQALR+m WV2dgLViMOLrubcw/Bq6aFZmg6Fv0SKVkiCLuX6R3jZvpbVDUGlHAlXhRO8/wJbwK08Q OVZw== X-Gm-Message-State: AOAM53008ZTpSRVTcyUkg2J2KJX/ZIzR6FZob/nXENEB7YJ7SIVgPOXr 2mf7hSOSg4PexMK2T+l7BTs4bHm7Cd3MjEBHfp27NEHgg7Y1li2AEQ0yTAToJYPTXbRTmVArJQ+ YW7uBOfJGoz8MGPcTcHuWRAKfWG48vn955XuUZIoEmKsnmRDBYG+3iTjU8aYcEQNe X-Received: by 2002:a05:622a:607:: with SMTP id z7mr1447023qta.281.1644897473048; Mon, 14 Feb 2022 19:57:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmgHKKaEcVLB+x7sLDrwMG7n/m7tePZJeBrbuDbcuEYsIUZ/lGU1pltG1jpfJ2NSAghPII3A== X-Received: by 2002:a05:622a:607:: with SMTP id z7mr1447008qta.281.1644897472619; Mon, 14 Feb 2022 19:57:52 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:51 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:29 +0000 Message-Id: <20220215035737.1820679-8-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 07/15] Introduce match_outport_dp_and_port_keys in physical.c 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 helper prepares a 'match' struct to match against a datapath and a port key. All existing spots in the file that use such a 'match' struct were updated. It will also be reused later. Signed-off-by: Ihar Hrachyshka --- controller/physical.c | 65 +++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 42 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index 7ad142293..e0afd83ab 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -277,6 +277,15 @@ put_remote_port_redirect_bridged(const struct } +static void +match_outport_dp_and_port_keys(struct match *match, + uint32_t dp_key, uint32_t port_key) +{ + match_init_catchall(match); + match_set_metadata(match, htonll(dp_key)); + match_set_reg(match, MFF_LOG_OUTPORT - MFF_REG0, port_key); +} + static void put_remote_port_redirect_overlay(const struct sbrec_port_binding *binding, @@ -670,7 +679,6 @@ put_replace_router_port_mac_flows(struct ovsdb_idl_index * a. Flow replaces ingress router port mac with a chassis mac. * b. Flow appends the vlan id localnet port is configured with. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); ovs_assert(rport_binding->n_mac == 1); @@ -684,8 +692,7 @@ put_replace_router_port_mac_flows(struct ovsdb_idl_index } /* Replace Router mac flow */ - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); match_set_dl_src(&match, router_port_mac); replace_mac = ofpact_put_SET_ETH_SRC(ofpacts_p); @@ -723,12 +730,10 @@ put_local_common_flows(uint32_t dp_key, * table 39. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */ - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); if (zone_ids) { if (zone_ids->ct) { @@ -786,10 +791,8 @@ put_local_common_flows(uint32_t dp_key, * */ bool nested_container = parent_pb ? true: false; - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); if (!nested_container) { match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_ALLOW_LOOPBACK, MLF_ALLOW_LOOPBACK); @@ -820,11 +823,8 @@ put_local_common_flows(uint32_t dp_key, * ports even if they don't have any child ports which is * unnecessary. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, - parent_pb->tunnel_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_NESTED_CONTAINER, MLF_NESTED_CONTAINER); @@ -920,10 +920,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, put_local_common_flows(dp_key, binding, NULL, &binding_zones, ofpacts_p, flow_table); - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); size_t clone_ofs = ofpacts_p->size; struct ofpact_nest *clone = ofpact_put_CLONE(ofpacts_p); @@ -966,10 +964,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, * output port is changed from the "chassisredirect" port to the * underlying distributed port. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); const char *distributed_port = smap_get_def(&binding->options, "distributed-port", ""); @@ -1203,10 +1199,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, * ======================= * * Deliver the packet to the local vif. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); if (tag) { /* For containers sitting behind a local vif, tag the packets * before delivering them. */ @@ -1240,10 +1234,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, */ if (!strcmp(binding->type, "localnet")) { /* do not forward traffic from localport to localnet port */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_LOCALPORT, MLF_LOCALPORT); ofctrl_add_flow(flow_table, OFTABLE_CHECK_LOOPBACK, 160, @@ -1251,10 +1243,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, ofpacts_p, &binding->header_.uuid); /* Drop LOCAL_ONLY traffic leaking through localnet ports. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_LOCAL_ONLY, MLF_LOCAL_ONLY); ofctrl_add_flow(flow_table, OFTABLE_CHECK_LOOPBACK, 160, @@ -1293,10 +1283,7 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, continue; } - match_init_catchall(&match); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, - port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, MLF_LOCALPORT, MLF_LOCALPORT); match_set_dl_dst(&match, peer_mac); @@ -1318,12 +1305,10 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, * to connected localnet port and resubmits to same table. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */ - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); put_load(localnet_port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, ofpacts_p); @@ -1346,12 +1331,10 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, * flow matches an output port that includes a logical port on a remote * hypervisor, and tunnels the packet to that hypervisor. */ - match_init_catchall(&match); ofpbuf_clear(ofpacts_p); /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */ - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + match_outport_dp_and_port_keys(&match, dp_key, port_key); if (redirect_type && !strcasecmp(redirect_type, "bridged")) { put_remote_port_redirect_bridged(binding, local_datapaths, @@ -1433,11 +1416,9 @@ consider_mc_group(struct ovsdb_idl_index *sbrec_port_binding_by_name, struct sset remote_chassis = SSET_INITIALIZER(&remote_chassis); struct sset vtep_chassis = SSET_INITIALIZER(&vtep_chassis); - struct match match; - match_init_catchall(&match); - match_set_metadata(&match, htonll(dp_key)); - match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, mc->tunnel_key); + struct match match; + match_outport_dp_and_port_keys(&match, dp_key, mc->tunnel_key); /* Go through all of the ports in the multicast group: * From patchwork Tue Feb 15 03:57:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592898 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=TOIv72cl; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 4JyS3x2qzhz9sFv for ; Tue, 15 Feb 2022 14:58:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 4E75E82A4E; Tue, 15 Feb 2022 03:58:03 +0000 (UTC) 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 z1SpBMwMOVIg; Tue, 15 Feb 2022 03:58:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7427B8277E; Tue, 15 Feb 2022 03:58:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 48014C002D; Tue, 15 Feb 2022 03:58:00 +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 19775C0011 for ; Tue, 15 Feb 2022 03:57:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8A16541512 for ; Tue, 15 Feb 2022 03:57:57 +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 XGvUg5V8oIgd for ; Tue, 15 Feb 2022 03:57:57 +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.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id D86BC40230 for ; Tue, 15 Feb 2022 03:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897475; 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=xwbgNATYlJy7KIK9g/qhS/3is3r9QP2SZ1b3tmrI+y0=; b=TOIv72clQbhzq6Sn8KUnqlRZYtmFjdfQTZSdYrFrTK6ubPuAPLc7L5Bz/qdCnSyPZ7AZSo 7x+aUkkt0K6N6G0FgMTYTsZS9Ca5etXU2wNX/fJrLGYr2lrFSAxv+TOzXsyMD9z0fIOpa/ 9FS3n8ZffooPeWMYauA/v4gvcVJFNLM= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-247-sHkDsUTAMEqEzjp5VQdFJg-1; Mon, 14 Feb 2022 22:57:54 -0500 X-MC-Unique: sHkDsUTAMEqEzjp5VQdFJg-1 Received: by mail-qv1-f70.google.com with SMTP id kl13-20020a056214518d00b0042cb237f86bso5872296qvb.0 for ; Mon, 14 Feb 2022 19:57:54 -0800 (PST) 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=xwbgNATYlJy7KIK9g/qhS/3is3r9QP2SZ1b3tmrI+y0=; b=6Y0T1jZ1kSHlV5+90bysQPguvjFM4Q0vs3dncIDwfx25cQZDOnb9YxUYlIqy7zIQCV HoLgikOcLY07izvfeo1GllNivC/kQlaiddEAwrJKJzEEWMb0+7x+FIGvwbEa9n8zX/cg ZFmF7fPMxssTch2iL9pdJOl9FgBcSZsJwO7yhn0TQ+4eRuphstGAhBmLvqFNr2YrKXFj 7c00gxEw00aNBToA3AyidXjLWC6R0YXxmFCqpBDVHAQzcVXLO8zAxH3P3A3LU2kArvd6 eKd1DmL21urtfN3HDCaKzAfWd3q2y6JcBR7+b0+6DIKFFDVBFSipRA70nsnq4gv74P+u ToTA== X-Gm-Message-State: AOAM5320ktHeCS37Eztv0M3qXzMyI7XPgm5NBPVjKaocLolJ/y7Zlui3 RrdZbF844wR99TBKPMe/RawjWxNfhu76gbwoLgGY+P7jxWMwLVT2xbZ1r2AXXwHrXlvfjQBWBWl wulevo98CHwt8q5YcePOe03EGsb84/8MBOVSfsjfSyTEf872NeQxLIakci9da7JJ4 X-Received: by 2002:a05:6214:2608:: with SMTP id gu8mr1268998qvb.35.1644897473788; Mon, 14 Feb 2022 19:57:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzr0B+EPN5MUCx5ZEBZkVQrjPAICgmFi6oX5lS5A7q7whaq4w2idEaSl4jUty+9/PftLdtMNg== X-Received: by 2002:a05:6214:2608:: with SMTP id gu8mr1268992qvb.35.1644897473558; Mon, 14 Feb 2022 19:57:53 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:53 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:30 +0000 Message-Id: <20220215035737.1820679-9-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 08/15] Split code to set zone info into put_zones_ofpacts 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" Signed-off-by: Ihar Hrachyshka --- controller/physical.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index e0afd83ab..c47b15f3e 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -710,6 +710,22 @@ put_replace_router_port_mac_flows(struct ovsdb_idl_index } } +static void +put_zones_ofpacts(const struct zone_ids *zone_ids, struct ofpbuf *ofpacts_p) +{ + if (zone_ids) { + if (zone_ids->ct) { + put_load(zone_ids->ct, MFF_LOG_CT_ZONE, 0, 32, ofpacts_p); + } + if (zone_ids->dnat) { + put_load(zone_ids->dnat, MFF_LOG_DNAT_ZONE, 0, 32, ofpacts_p); + } + if (zone_ids->snat) { + put_load(zone_ids->snat, MFF_LOG_SNAT_ZONE, 0, 32, ofpacts_p); + } + } +} + static void put_local_common_flows(uint32_t dp_key, const struct sbrec_port_binding *pb, @@ -735,17 +751,7 @@ put_local_common_flows(uint32_t dp_key, /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */ match_outport_dp_and_port_keys(&match, dp_key, port_key); - if (zone_ids) { - if (zone_ids->ct) { - put_load(zone_ids->ct, MFF_LOG_CT_ZONE, 0, 32, ofpacts_p); - } - if (zone_ids->dnat) { - put_load(zone_ids->dnat, MFF_LOG_DNAT_ZONE, 0, 32, ofpacts_p); - } - if (zone_ids->snat) { - put_load(zone_ids->snat, MFF_LOG_SNAT_ZONE, 0, 32, ofpacts_p); - } - } + put_zones_ofpacts(zone_ids, ofpacts_p); /* Resubmit to table 39. */ put_resubmit(OFTABLE_CHECK_LOOPBACK, ofpacts_p); From patchwork Tue Feb 15 03:57:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592899 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=QJ6H2kNA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 4JyS400WsFz9sFv for ; Tue, 15 Feb 2022 14:58:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5301F82BD6; Tue, 15 Feb 2022 03:58:06 +0000 (UTC) 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 1l2beZm4Vu8O; Tue, 15 Feb 2022 03:58:04 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 75BC682A3B; Tue, 15 Feb 2022 03:58:02 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2CF93C007A; Tue, 15 Feb 2022 03:58:02 +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 1B043C0078 for ; Tue, 15 Feb 2022 03:58:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D8D5141527 for ; Tue, 15 Feb 2022 03:57:58 +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 KueRnBzz8Bn8 for ; Tue, 15 Feb 2022 03:57:58 +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 3BC51414A2 for ; Tue, 15 Feb 2022 03:57:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897477; 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=TdVbiqzTnzPQKzFkMetNPXGXy1QBTbbfA5+8m+zL2UY=; b=QJ6H2kNAI5OBbEz7ljBQWaLKVjQuJguvX5B1WFK8ndLlGbCcydGUlXsZno08f7gL0CaCHC LOZZm8fB0Gy0TMai3syrdJasDP3VkhNRbqmTcQreA7AS9IjvFswEaFmAIAyuLWz7LCbg/0 elnlc7nOeDCDDM86eindHre4bdQ/20U= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-gQQDIYaFPyaHv8tUOWM77A-1; Mon, 14 Feb 2022 22:57:56 -0500 X-MC-Unique: gQQDIYaFPyaHv8tUOWM77A-1 Received: by mail-qt1-f197.google.com with SMTP id x5-20020ac84d45000000b002cf826b1a18so14112450qtv.2 for ; Mon, 14 Feb 2022 19:57:56 -0800 (PST) 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=TdVbiqzTnzPQKzFkMetNPXGXy1QBTbbfA5+8m+zL2UY=; b=UmtH6PQp8mSi7g+GZAmoySijC+1l5ZDqtuGygU8CNOM25D7LjXLAv9iygMKHmSV1iv vz07KfHe4Vv0RuvHUV8gIJeethQKNPGXqEjjWHa0zvHjiJGAWyJnoP/IKuxQ0TSjhwhv q6zy4Yx6ULsmj2bMaDWQT1fYKz28ibHbBbm6A4PfQLTrfobJK/JYYWbZmniI4psoHxpP 4jMinXSqEB9B+Gn5j9ESprftQ8FgAqrX5UNEdaSE6JWRhkf8RkslYnzh1o6daFm0UFrX MM8yxas3JIxb7g4hG7l5QY3WAxY+QUQQvpVRdxzjnqSFYOQGX9xp+1nG7oZgLkSJg9C6 VPSw== X-Gm-Message-State: AOAM531kEmh7kvLIlJXyEla/l3y/PEELydylT6VaeU0dqenDoMTiJpBB 49J/U8JTmYdX7e9xXb1caM9Gs72Alr+fqSxhiMOn/DysCKyLwe5oYuVSMiMMvEeBfvNzGP5k40U w5p4eQyUSeX3cYY3YLJzgAk2WUDQgcpeMYct+IEbMK1uAAiuy4S3Y0taJIuj5CiYg X-Received: by 2002:a05:6214:b66:: with SMTP id ey6mr1198451qvb.131.1644897475268; Mon, 14 Feb 2022 19:57:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoQu6ifp+7tQGf8btHij16Uji/6RV6GXeWBeetJQpVG5v8t+5CFNpNkBVxS0/mAMI7Vh9uxw== X-Received: by 2002:a05:6214:b66:: with SMTP id ey6mr1198443qvb.131.1644897475013; Mon, 14 Feb 2022 19:57:55 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:54 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:31 +0000 Message-Id: <20220215035737.1820679-10-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 09/15] Use get_port_binding_tun instead of chassis_tunnel_find 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" Right now consider_port_binding first extracts *a* tunnel for a chassis, then later in put_remote_port_redirect_overlay it fetches *the* proper tunnel before configuring encapsulation. Instead of doing it in two steps, just extract the proper tunnel info earlier. Signed-off-by: Ihar Hrachyshka --- controller/physical.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index c47b15f3e..0f9dd91e5 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -301,17 +301,14 @@ put_remote_port_redirect_overlay(const struct { if (!is_ha_remote) { /* Setup encapsulation */ - const struct chassis_tunnel *rem_tun = - get_port_binding_tun(binding->encap, binding->chassis, - chassis_tunnels); - if (!rem_tun) { + if (!tun) { return; } put_encapsulation(mff_ovn_geneve, tun, binding->datapath, port_key, !strcmp(binding->type, "vtep"), ofpacts_p); /* Output to tunnel. */ - ofpact_put_OUTPUT(ofpacts_p)->port = rem_tun->ofport; + ofpact_put_OUTPUT(ofpacts_p)->port = tun->ofport; } else { /* Make sure all tunnel endpoints use the same encapsulation, * and set it up */ @@ -1097,8 +1094,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, if (!binding->chassis) { goto out; } - tun = chassis_tunnel_find(chassis_tunnels, - binding->chassis->name, NULL); + tun = get_port_binding_tun(binding->encap, binding->chassis, + chassis_tunnels); if (!tun) { goto out; } From patchwork Tue Feb 15 03:57:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592901 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=Jitjrtdq; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 4JyS4F2SQkz9s07 for ; Tue, 15 Feb 2022 14:58:21 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7B0F8830C5; Tue, 15 Feb 2022 03:58:19 +0000 (UTC) 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 U65byq66TNgB; Tue, 15 Feb 2022 03:58:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3A55182A17; Tue, 15 Feb 2022 03:58:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0D50BC0011; Tue, 15 Feb 2022 03:58:17 +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 0F54DC000B for ; Tue, 15 Feb 2022 03:58:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D808C82BFD for ; Tue, 15 Feb 2022 03:58:01 +0000 (UTC) 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 TXnEFkR7JcTf for ; Tue, 15 Feb 2022 03:58:00 +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.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id D364082A17 for ; Tue, 15 Feb 2022 03:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897478; 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=PEIfys4cIfkOKsUQ+ug34DKg/bSccL7R+vU0XxQw1xw=; b=JitjrtdqrEi2iwk5CecjYKvUkLDvO71D0GOE0aOh1FVTU86LAH2CgbSORLe9LmG2rsLaMs 6Gv//do8if6ok/WAQOigjGCv04WwfsfN3uMlkQt61xaAoaTf6nLJNYFLzZm4hxKlHT4NMm QJ5eJnLMNXony8EnI20cpchs0+3KjMk= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-93-5t8GuGHCMIapNN8SvektGA-1; Mon, 14 Feb 2022 22:57:57 -0500 X-MC-Unique: 5t8GuGHCMIapNN8SvektGA-1 Received: by mail-qt1-f199.google.com with SMTP id l15-20020ac84ccf000000b002cf9424cfa5so14026376qtv.7 for ; Mon, 14 Feb 2022 19:57:57 -0800 (PST) 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=PEIfys4cIfkOKsUQ+ug34DKg/bSccL7R+vU0XxQw1xw=; b=nMuwPJKaYvRHss09TQU5mwP7Tux1RXYtPrsNjArGCHmHgzPn2/uPMEdTNc4Kkq+d1Q mU7Nf9C606HOx/hUGdDyCkdX5wvyYV6OPnsKgRMid4At3eCQDF2zw2zQsE/ObIAK+hbC oQxol0oSLz9NAi5jWzolxILS90VZ46c+O4yBbxdl4v37q3o9qLlWBgAdqjw+6+t3IR6B pu9cMhTUb9D1qo3DbGU2melIQCm+5jLdW6ZH6/7tK5Z5idokvkC0bqM0Pw632UnNLd7t AG3bhi0B9I9GR49/yrACGHilTV1QkmuqJM48LzWiWxLWp96GHjp6LmqIaFfXXNpPvqOX 4Dlw== X-Gm-Message-State: AOAM533ItG1PjaZCtzmg/3ZQtrpoZMTjAC1n6lGrUtlJiENWHfr1bK5V T/MXFwMW4G8jNQGvsuUJHy/c73EA1ea03rO1EIi2tw4AhcGJQFxwbLBtvmFcs6wQnZK8dh9Hlhs B8nS+gJjd/1/r+1Fvz9/EdBMHNG862bR+rCTMOGVWtehPb6zC4V0JhRfDe2rMr5Z4 X-Received: by 2002:ac8:4e4c:: with SMTP id e12mr1535319qtw.98.1644897476671; Mon, 14 Feb 2022 19:57:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyx4onWf5LVM9BKkdpvMgIF7GhlWM5K1fYOLAzS/Jbk0Wm72GXrVBITnOC2rB74ZUU1mgzOHQ== X-Received: by 2002:ac8:4e4c:: with SMTP id e12mr1535312qtw.98.1644897476449; Mon, 14 Feb 2022 19:57:56 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:55 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:32 +0000 Message-Id: <20220215035737.1820679-11-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 10/15] Tag all packets that arrived from a tunnel as LOCAL_ONLY 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" A next patch may need to clone packets to another chassis as part of "port migration" procedure, but only if they haven't originated at another chassis. This LOCAL_ONLY tag will enforce the requirement. Signed-off-by: Ihar Hrachyshka --- controller/physical.c | 1 + 1 file changed, 1 insertion(+) diff --git a/controller/physical.c b/controller/physical.c index 0f9dd91e5..bc4f7c4f0 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -1727,6 +1727,7 @@ physical_run(struct physical_ctx *p_ctx, OVS_NOT_REACHED(); } + put_load(1, MFF_LOG_FLAGS, MLF_LOCAL_ONLY_BIT, 1, &ofpacts); put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts); ofctrl_add_flow(flow_table, OFTABLE_PHY_TO_LOG, 100, 0, &match, From patchwork Tue Feb 15 03:57:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592904 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=QGHvlbGE; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 4JyS4W4V9Kz9sFv for ; Tue, 15 Feb 2022 14:58:35 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 307C8408E0; Tue, 15 Feb 2022 03:58:33 +0000 (UTC) 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 DG3vux31r_ok; Tue, 15 Feb 2022 03:58:30 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 6990140A86; Tue, 15 Feb 2022 03:58:29 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4A7DBC0011; Tue, 15 Feb 2022 03:58:29 +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 1721AC002D for ; Tue, 15 Feb 2022 03:58:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E463C82EB4 for ; Tue, 15 Feb 2022 03:58:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 GT7v8TIafigJ for ; Tue, 15 Feb 2022 03:58:01 +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.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3E101828E3 for ; Tue, 15 Feb 2022 03:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897480; 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=MnnPmwLHeRJ3TS8SY5+PD4/cv+U9WgTEcckMabSfOgg=; b=QGHvlbGEVGjLr+tn0o43fEPepzTOxzP2WrrfKGJgumhpItE/vMWaFY6wkGCY8SRrMPFR+A hTNYx6XSCZgi/pKklSnbHElVKgPuL+9VqZRvORmMWbblPv0AcdQo8tfC94WS3Y8dg9ujrx kVrBK7icq20Le4dynyc3cfz3qWerdjA= 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-537-Gl6CSZ4NPRGCFlbliZbkeg-1; Mon, 14 Feb 2022 22:57:59 -0500 X-MC-Unique: Gl6CSZ4NPRGCFlbliZbkeg-1 Received: by mail-qv1-f69.google.com with SMTP id cs16-20020ad44c50000000b0042bfd7b5158so13152469qvb.3 for ; Mon, 14 Feb 2022 19:57:59 -0800 (PST) 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=MnnPmwLHeRJ3TS8SY5+PD4/cv+U9WgTEcckMabSfOgg=; b=tRFBXmPFIWvWYU7hQbCGndFACZH6k9+19WpElvGPGGjIe7qtpAKwPoLrPv5jYAhvPX qn9UFMmvfpWYm0gXlqWBK0Ru9O5y+cA5uxvacz4S9Q2UkP1TuDFaPmo7sKplccuunl6I Qv56Oo0324O1UwG6i7MrV+ARJRere3VxV1vY9LmC9T0+ACfMqyik3NpVH1IjqmQeEp80 bsEbv7Yyu9st1cIWVN1RB6Vo34ONS72By/iIZvv4knYneqUaEWrxNkYKPy8hMCyPf1ar NmhYA9eOkMT9nV3ryRTlUZGqrBd5zbwFoF0wqlbpqg0jSGjv2+IDwUTyvGziDlRbomqI pzjg== X-Gm-Message-State: AOAM530uGBDPyTAOl7//bskSrdeJkMAgPruZqflwmdXPfwHXQ5diA2Cf lhWMu59ybamLfCfOy5e2+AqjxH/QxdHXU2SRzZu2Urc4oiJ+TbHSoDKg9RgQqO6NmyYk8xtPVml 29F7pr/UGUekgThEBMbI76Tqd3CPevdSPOOBFXcrSxoprR4kh7BcANodKccFI2JQH X-Received: by 2002:a05:6214:21e9:: with SMTP id p9mr1569750qvj.86.1644897478015; Mon, 14 Feb 2022 19:57:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwo47VYIbl44HQIdO22zJxQ8yKuAteX8ojRSPs4x8NA6bNrif+A8WOT25yo7WX5+jBx8r4TlQ== X-Received: by 2002:a05:6214:21e9:: with SMTP id p9mr1569743qvj.86.1644897477702; Mon, 14 Feb 2022 19:57:57 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:56 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:33 +0000 Message-Id: <20220215035737.1820679-12-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 11/15] Update port-up on main chassis only 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" In a future patch, there will be a scenario where the same port has attachments at multiple (specifically, 2) chassis, so make sure that 'up' property is updated by the main chassis only. Signed-off-by: Ihar Hrachyshka --- controller/binding.c | 10 +++++++--- controller/binding.h | 2 ++ controller/if-status.c | 15 ++++++++++----- controller/if-status.h | 1 + controller/ovn-controller.c | 4 ++-- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index 4d62b0858..c7a13d5d5 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -681,6 +681,7 @@ 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, const char *ts_now_str, bool sb_readonly, bool ovs_readonly) { @@ -700,8 +701,9 @@ local_binding_set_up(struct shash *local_bindings, const char *pb_name, ts_now_str); } - if (!sb_readonly && lbinding && b_lport && b_lport->pb->n_up - && !b_lport->pb->up[0]) { + if (!sb_readonly && lbinding && b_lport && b_lport->pb->n_up && + !b_lport->pb->up[0] && + (!b_lport->pb->chassis || b_lport->pb->chassis == chassis_rec)) { VLOG_INFO("Setting lport %s up in Southbound", pb_name); binding_lport_set_up(b_lport, sb_readonly); LIST_FOR_EACH (b_lport, list_node, &lbinding->binding_lports) { @@ -712,6 +714,7 @@ local_binding_set_up(struct shash *local_bindings, const char *pb_name, void local_binding_set_down(struct shash *local_bindings, const char *pb_name, + const struct sbrec_chassis *chassis_rec, bool sb_readonly, bool ovs_readonly) { struct local_binding *lbinding = @@ -726,7 +729,8 @@ local_binding_set_down(struct shash *local_bindings, const char *pb_name, OVN_INSTALLED_EXT_ID); } - if (!sb_readonly && b_lport && b_lport->pb->n_up && b_lport->pb->up[0]) { + if (!sb_readonly && b_lport && b_lport->pb->n_up && b_lport->pb->up[0] && + (!b_lport->pb->chassis || b_lport->pb->chassis == chassis_rec)) { VLOG_INFO("Setting lport %s down in Southbound", pb_name); binding_lport_set_down(b_lport, sb_readonly); LIST_FOR_EACH (b_lport, list_node, &lbinding->binding_lports) { diff --git a/controller/binding.h b/controller/binding.h index 430a8d9b1..46f88aff7 100644 --- a/controller/binding.h +++ b/controller/binding.h @@ -154,9 +154,11 @@ ofp_port_t local_binding_get_lport_ofport(const struct shash *local_bindings, bool local_binding_is_up(struct shash *local_bindings, const char *pb_name); 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, const char *ts_now_str, bool sb_readonly, bool ovs_readonly); void local_binding_set_down(struct shash *local_bindings, const char *pb_name, + const struct sbrec_chassis *chassis_rec, bool sb_readonly, bool ovs_readonly); void binding_register_ovs_idl(struct ovsdb_idl *); diff --git a/controller/if-status.c b/controller/if-status.c index fa4c8bd94..ee00f2cc6 100644 --- a/controller/if-status.c +++ b/controller/if-status.c @@ -115,6 +115,7 @@ static void ovs_iface_set_state(struct if_status_mgr *, struct ovs_iface *, static void if_status_mgr_update_bindings( struct if_status_mgr *mgr, struct local_binding_data *binding_data, + const struct sbrec_chassis *, bool sb_readonly, bool ovs_readonly); struct if_status_mgr * @@ -311,6 +312,7 @@ if_status_mgr_update(struct if_status_mgr *mgr, void if_status_mgr_run(struct if_status_mgr *mgr, struct local_binding_data *binding_data, + const struct sbrec_chassis *chassis_rec, bool sb_readonly, bool ovs_readonly) { struct ofctrl_acked_seqnos *acked_seqnos = @@ -335,8 +337,8 @@ if_status_mgr_run(struct if_status_mgr *mgr, ofctrl_acked_seqnos_destroy(acked_seqnos); /* Update binding states. */ - if_status_mgr_update_bindings(mgr, binding_data, sb_readonly, - ovs_readonly); + if_status_mgr_update_bindings(mgr, binding_data, chassis_rec, + sb_readonly, ovs_readonly); } static void @@ -397,6 +399,7 @@ ovs_iface_set_state(struct if_status_mgr *mgr, struct ovs_iface *iface, static void if_status_mgr_update_bindings(struct if_status_mgr *mgr, struct local_binding_data *binding_data, + const struct sbrec_chassis *chassis_rec, bool sb_readonly, bool ovs_readonly) { if (!binding_data) { @@ -412,7 +415,8 @@ if_status_mgr_update_bindings(struct if_status_mgr *mgr, HMAPX_FOR_EACH (node, &mgr->ifaces_per_state[OIF_INSTALL_FLOWS]) { struct ovs_iface *iface = node->data; - local_binding_set_down(bindings, iface->id, sb_readonly, ovs_readonly); + local_binding_set_down(bindings, iface->id, chassis_rec, + sb_readonly, ovs_readonly); } /* Notifiy the binding module to set "up" all bindings that have had @@ -423,7 +427,7 @@ if_status_mgr_update_bindings(struct if_status_mgr *mgr, HMAPX_FOR_EACH (node, &mgr->ifaces_per_state[OIF_MARK_UP]) { struct ovs_iface *iface = node->data; - local_binding_set_up(bindings, iface->id, ts_now_str, + local_binding_set_up(bindings, iface->id, chassis_rec, ts_now_str, sb_readonly, ovs_readonly); } free(ts_now_str); @@ -434,7 +438,8 @@ if_status_mgr_update_bindings(struct if_status_mgr *mgr, HMAPX_FOR_EACH (node, &mgr->ifaces_per_state[OIF_MARK_DOWN]) { struct ovs_iface *iface = node->data; - local_binding_set_down(bindings, iface->id, sb_readonly, ovs_readonly); + local_binding_set_down(bindings, iface->id, chassis_rec, + sb_readonly, ovs_readonly); } } diff --git a/controller/if-status.h b/controller/if-status.h index ff4aa760e..bb8a3950d 100644 --- a/controller/if-status.h +++ b/controller/if-status.h @@ -33,6 +33,7 @@ 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_run(struct if_status_mgr *mgr, struct local_binding_data *, + const struct sbrec_chassis *, bool sb_readonly, bool ovs_readonly); void if_status_mgr_get_memory_usage(struct if_status_mgr *mgr, struct simap *usage); diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 8631bccbc..4d13f11ec 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -3783,8 +3783,8 @@ main(int argc, char *argv[]) time_msec()); stopwatch_start(IF_STATUS_MGR_RUN_STOPWATCH_NAME, time_msec()); - if_status_mgr_run(if_mgr, binding_data, !ovnsb_idl_txn, - !ovs_idl_txn); + if_status_mgr_run(if_mgr, binding_data, chassis, + !ovnsb_idl_txn, !ovs_idl_txn); stopwatch_stop(IF_STATUS_MGR_RUN_STOPWATCH_NAME, time_msec()); } From patchwork Tue Feb 15 03:57:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592905 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=gTK7i1xa; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JyS4m28pnz9sFv for ; Tue, 15 Feb 2022 14:58:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id EE5CD416F8; Tue, 15 Feb 2022 03:58:45 +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 AwkdVvmvJUor; Tue, 15 Feb 2022 03:58:41 +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 B1F104157D; Tue, 15 Feb 2022 03:58:37 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 75A61C000B; Tue, 15 Feb 2022 03:58:37 +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 47FBEC0011 for ; Tue, 15 Feb 2022 03:58:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 42C368291C for ; Tue, 15 Feb 2022 03:58:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 AaTc03Bc3R7L for ; Tue, 15 Feb 2022 03:58:03 +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 smtp1.osuosl.org (Postfix) with ESMTPS id 41C0182D96 for ; Tue, 15 Feb 2022 03:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897482; 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=IKAjo6RxmsVR3pRGixNHJUgNg83mHMbGXAvP2nBZhQ0=; b=gTK7i1xaDfcrLxV6u95SYqcF5taBQ8yf7wDlPjzyrQqVfijstFmz/G6LOecabT6ZTZ72pt OC5yeMSOYgC4M4pTVtiFw/amAL7rkkCJO7nz/Y8N8qQ8b+sYMQMuKQwIKwP5WiyodOcbVR d9fVhxpHzQE9RM/kGMfdKnTS5lqlwr8= 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-564-l_rCgeq0MNO1DGhdhO5m7A-1; Mon, 14 Feb 2022 22:58:01 -0500 X-MC-Unique: l_rCgeq0MNO1DGhdhO5m7A-1 Received: by mail-qv1-f69.google.com with SMTP id c8-20020a0ce7c8000000b0042c12357076so13161898qvo.6 for ; Mon, 14 Feb 2022 19:58:01 -0800 (PST) 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=IKAjo6RxmsVR3pRGixNHJUgNg83mHMbGXAvP2nBZhQ0=; b=TXa6Kpdb68BWWCBIIado8uLOiW26UNIDqz/2y1tqZc5D3wyjDCV0sN6RfrhskZemb3 XgC/riRlvb/kdSYWLVjY44stJTCJofphd58IOZonfr0J1pwGtqgZn1EQ+0byXsdWyUkt r+nU8VQJP+VKj1PTTKATXTW5brc2glyORvxCfI9p9s57DDxMxHV2ZPmGeHtv/3exCx4Z i9SgEz0z842vgyx3O6PfQyFyIgKpSsK2aWUEhm9e9Y6WFEwm0X0aIwPxHM6ZiqzabdIM r4dOGND3LzDTBvCHPpOD5BiUy+U9av86sUgyrjoYUgxlsg8Pf1lmErl95L6gx5wXDSND 7qPw== X-Gm-Message-State: AOAM530MTv5q1C/AJYwmNIC1+EGcNgVSyq17gnG4aipq/oDB5fhqzQOm C4Im+MqGvN3ELDzYz3q4YaP0d6GCjZ5v9edz8qu5I1noqoV9V3R/96xyNgpLbz6DWFVQpUcBFd6 uv+yrRQgckITTO1bQy2AvpdrCdGBTxklfzIgRTseqKJuxZRsY0G3bKrCCj5YEAa3Q X-Received: by 2002:a0c:e8cf:: with SMTP id m15mr1236495qvo.117.1644897479899; Mon, 14 Feb 2022 19:57:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJycwbfO9Q+N1ApOpMjcqgMdb1uV5co4rG6hla4lXat7Fz4Hk0NkaS4niyMBdGMFwI4TvcldEw== X-Received: by 2002:a0c:e8cf:: with SMTP id m15mr1236476qvo.117.1644897479195; Mon, 14 Feb 2022 19:57:59 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:58 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:34 +0000 Message-Id: <20220215035737.1820679-13-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 12/15] Introduce LSP:options:requested-additional-chassis 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" If used in conjunction with requested-chassis, OVN will attempt to bind the port at another location in addition to the main chassis. This is useful in live migration scenarios where it's important to prepare the environment for workloads to move to, avoiding costly flow configuration at the moment of the final port binding location change. The patch mimics behavior of requested-chassis. Corresponding database fields (pb->additional_chassis, pb->requested_additional_chassis, pb->additional_encap) are introduced as part of the patch. Signed-off-by: Ihar Hrachyshka --- controller/binding.c | 178 +++++++++++++++++++++++++++++++++---------- controller/lport.c | 19 ++++- northd/northd.c | 64 +++++++++++++--- northd/ovn-northd.c | 4 +- ovn-nb.xml | 8 ++ ovn-sb.ovsschema | 15 +++- ovn-sb.xml | 58 +++++++++++++- tests/ovn.at | 91 ++++++++++++++++++++++ 8 files changed, 379 insertions(+), 58 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index c7a13d5d5..ec8bff3d8 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -912,6 +912,26 @@ claimed_lport_set_up(const struct sbrec_port_binding *pb, } } +typedef void (*set_func)(const struct sbrec_port_binding *pb, + const struct sbrec_encap *); + +static bool +update_port_encap_if_needed(const struct sbrec_port_binding *pb, + const struct sbrec_chassis *chassis_rec, + const struct ovsrec_interface *iface_rec, + bool sb_readonly, set_func f) +{ + const struct sbrec_encap *encap_rec = + sbrec_get_port_encap(chassis_rec, iface_rec); + if (encap_rec && pb->encap != encap_rec) { + if (sb_readonly) { + return false; + } + f(pb, encap_rec); + } + return true; +} + /* Returns false if lport is not claimed due to 'sb_readonly'. * Returns true otherwise. */ @@ -928,37 +948,68 @@ claim_lport(const struct sbrec_port_binding *pb, claimed_lport_set_up(pb, parent_pb, chassis_rec, notify_up, if_mgr); } - if (pb->chassis != chassis_rec) { - if (sb_readonly) { - return false; - } + if (!pb->requested_chassis || pb->requested_chassis == chassis_rec) { + if (pb->chassis != chassis_rec) { + if (sb_readonly) { + return false; + } - if (pb->chassis) { - VLOG_INFO("Changing chassis for lport %s from %s to %s.", - pb->logical_port, pb->chassis->name, - chassis_rec->name); - } else { - VLOG_INFO("Claiming lport %s for this chassis.", pb->logical_port); - } - for (int i = 0; i < pb->n_mac; i++) { - VLOG_INFO("%s: Claiming %s", pb->logical_port, pb->mac[i]); + if (pb->chassis) { + VLOG_INFO("Changing chassis for lport %s from %s to %s.", + pb->logical_port, pb->chassis->name, + chassis_rec->name); + } else { + VLOG_INFO("Claiming lport %s for this chassis.", + pb->logical_port); + } + for (int i = 0; i < pb->n_mac; i++) { + VLOG_INFO("%s: Claiming %s", pb->logical_port, pb->mac[i]); + } + + sbrec_port_binding_set_chassis(pb, chassis_rec); + if (pb->additional_chassis == chassis_rec) { + sbrec_port_binding_set_additional_chassis(pb, NULL); + if (pb->additional_encap) { + sbrec_port_binding_set_additional_encap(pb, NULL); + } + } } + } else if (pb->requested_additional_chassis == chassis_rec) { + if (pb->additional_chassis != chassis_rec) { + if (sb_readonly) { + return false; + } - sbrec_port_binding_set_chassis(pb, chassis_rec); + if (pb->additional_chassis) { + VLOG_INFO( + "Changing additional chassis for lport %s from %s to %s.", + pb->logical_port, pb->chassis->name, chassis_rec->name); + } else { + VLOG_INFO( + "Claiming lport %s for this additional chassis.", + pb->logical_port); + } + for (int i = 0; i < pb->n_mac; i++) { + VLOG_INFO("%s: Claiming %s", pb->logical_port, pb->mac[i]); + } - if (tracked_datapaths) { - update_lport_tracking(pb, tracked_datapaths, true); + sbrec_port_binding_set_additional_chassis(pb, chassis_rec); } } + if (tracked_datapaths) { + update_lport_tracking(pb, tracked_datapaths, true); + } + /* Check if the port encap binding, if any, has changed */ - struct sbrec_encap *encap_rec = - sbrec_get_port_encap(chassis_rec, iface_rec); - if (encap_rec && pb->encap != encap_rec) { - if (sb_readonly) { - return false; - } - sbrec_port_binding_set_encap(pb, encap_rec); + if (pb->chassis == chassis_rec) { + return update_port_encap_if_needed( + pb, chassis_rec, iface_rec, sb_readonly, + &sbrec_port_binding_set_encap); + } else if (pb->additional_chassis == chassis_rec) { + return update_port_encap_if_needed( + pb, chassis_rec, iface_rec, sb_readonly, + &sbrec_port_binding_set_additional_encap); } return true; @@ -972,7 +1023,8 @@ claim_lport(const struct sbrec_port_binding *pb, * Caller should make sure that this is the case. */ static bool -release_lport_(const struct sbrec_port_binding *pb, bool sb_readonly) +release_lport_main_chassis(const struct sbrec_port_binding *pb, + bool sb_readonly) { if (pb->encap) { if (sb_readonly) { @@ -1000,11 +1052,41 @@ release_lport_(const struct sbrec_port_binding *pb, bool sb_readonly) } static bool -release_lport(const struct sbrec_port_binding *pb, bool sb_readonly, +release_lport_additional_chassis(const struct sbrec_port_binding *pb, + bool sb_readonly) +{ + if (pb->additional_encap) { + if (sb_readonly) { + return false; + } + sbrec_port_binding_set_additional_encap(pb, NULL); + } + + if (pb->additional_chassis) { + if (sb_readonly) { + return false; + } + sbrec_port_binding_set_additional_chassis(pb, NULL); + } + + VLOG_INFO("Releasing lport %s from this additional chassis.", + pb->logical_port); + return true; +} + +static bool +release_lport(const struct sbrec_port_binding *pb, + const struct sbrec_chassis *chassis_rec, bool sb_readonly, struct hmap *tracked_datapaths, struct if_status_mgr *if_mgr) { - if (!release_lport_(pb, sb_readonly)) { - return false; + if (pb->chassis == chassis_rec) { + if (!release_lport_main_chassis(pb, sb_readonly)) { + return false; + } + } else if (pb->additional_chassis == chassis_rec) { + if (!release_lport_additional_chassis(pb, sb_readonly)) { + return false; + } } update_lport_tracking(pb, tracked_datapaths, false); @@ -1023,7 +1105,8 @@ is_binding_lport_this_chassis(struct binding_lport *b_lport, const struct sbrec_chassis *chassis) { return (b_lport && b_lport->pb && chassis && - b_lport->pb->chassis == chassis); + (b_lport->pb->chassis == chassis + || b_lport->pb->additional_chassis == chassis)); } /* Returns 'true' if the 'lbinding' has binding lports of type LP_CONTAINER, @@ -1048,7 +1131,7 @@ release_binding_lport(const struct sbrec_chassis *chassis_rec, { if (is_binding_lport_this_chassis(b_lport, chassis_rec)) { remove_related_lport(b_lport->pb, b_ctx_out); - if (!release_lport(b_lport->pb, sb_readonly, + if (!release_lport(b_lport->pb, chassis_rec, sb_readonly, b_ctx_out->tracked_dp_bindings, b_ctx_out->if_mgr)) { return false; @@ -1097,22 +1180,31 @@ consider_vif_lport_(const struct sbrec_port_binding *pb, } else { /* We could, but can't claim the lport. */ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); + if (!pb->chassis || pb->chassis == b_ctx_in->chassis_rec) { + VLOG_INFO_RL(&rl, + "Not claiming lport %s, chassis %s requested-chassis %s", + pb->logical_port, b_ctx_in->chassis_rec->name, + pb->requested_chassis ? + pb->requested_chassis->name : + "(option points at non-existent chassis)"); + } else { VLOG_INFO_RL(&rl, - "Not claiming lport %s, chassis %s " - "requested-chassis %s", - pb->logical_port, - b_ctx_in->chassis_rec->name, - pb->requested_chassis ? - pb->requested_chassis->name : "(option points at " - "non-existent " - "chassis)"); + "Not claiming lport %s, chassis %s " + "requested-additional-chassis %s", + pb->logical_port, b_ctx_in->chassis_rec->name, + pb->requested_additional_chassis ? + pb->requested_additional_chassis->name : + "(option points at non-existent chassis)"); + } } } - if (pb->chassis == b_ctx_in->chassis_rec) { + if (pb->chassis == b_ctx_in->chassis_rec + || pb->additional_chassis == b_ctx_in->chassis_rec) { /* Release the lport if there is no lbinding. */ if (!lbinding_set || !can_bind) { - return release_lport(pb, !b_ctx_in->ovnsb_idl_txn, + return release_lport(pb, b_ctx_in->chassis_rec, + !b_ctx_in->ovnsb_idl_txn, b_ctx_out->tracked_dp_bindings, b_ctx_out->if_mgr); } @@ -1234,7 +1326,8 @@ consider_container_lport(const struct sbrec_port_binding *pb, * if it was bound earlier. */ if (is_binding_lport_this_chassis(container_b_lport, b_ctx_in->chassis_rec)) { - return release_lport(pb, !b_ctx_in->ovnsb_idl_txn, + return release_lport(pb, b_ctx_in->chassis_rec, + !b_ctx_in->ovnsb_idl_txn, b_ctx_out->tracked_dp_bindings, b_ctx_out->if_mgr); } @@ -1328,7 +1421,7 @@ consider_localport(const struct sbrec_port_binding *pb, /* If the port binding is claimed, then release it as localport is claimed * by any ovn-controller. */ if (pb->chassis == b_ctx_in->chassis_rec) { - if (!release_lport_(pb, !b_ctx_in->ovnsb_idl_txn)) { + if (!release_lport_main_chassis(pb, !b_ctx_in->ovnsb_idl_txn)) { return false; } @@ -1363,7 +1456,8 @@ consider_nonvif_lport_(const struct sbrec_port_binding *pb, b_ctx_out->tracked_dp_bindings, b_ctx_out->if_mgr); } else if (pb->chassis == b_ctx_in->chassis_rec) { - return release_lport(pb, !b_ctx_in->ovnsb_idl_txn, + return release_lport(pb, b_ctx_in->chassis_rec, + !b_ctx_in->ovnsb_idl_txn, b_ctx_out->tracked_dp_bindings, b_ctx_out->if_mgr); } diff --git a/controller/lport.c b/controller/lport.c index 5ad40f6d3..feab18cf8 100644 --- a/controller/lport.c +++ b/controller/lport.c @@ -129,8 +129,23 @@ lport_can_bind_on_this_chassis(const struct sbrec_chassis *chassis_rec, return !strcmp(requested_chassis_option, chassis_rec->name) || !strcmp(requested_chassis_option, chassis_rec->hostname); } - return !requested_chassis_option || !requested_chassis_option[0] - || chassis_rec == pb->requested_chassis; + if (!requested_chassis_option || !requested_chassis_option[0] + || chassis_rec == pb->requested_chassis) { + return true; + } + + const char *rac_option = smap_get(&pb->options, + "requested-additional-chassis"); + if (rac_option && rac_option[0]) { + if (pb->requested_additional_chassis) { + return (pb->requested_chassis && + chassis_rec == pb->requested_additional_chassis); + } else { + return !strcmp(rac_option, chassis_rec->name) + || !strcmp(rac_option, chassis_rec->hostname); + } + } + return false; } const struct sbrec_datapath_binding * diff --git a/northd/northd.c b/northd/northd.c index 0179b2bc9..108ccb14f 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -3139,17 +3139,17 @@ ovn_port_update_sbrec_chassis( const struct ovn_port *op) { const char *requested_chassis; /* May be NULL. */ - bool reset_requested_chassis = false; + const char *requested_additional_chassis; /* May be NULL. */ + const struct sbrec_chassis *requested_chassis_sb = NULL; + const struct sbrec_chassis *requested_additional_chassis_sb = NULL; + requested_chassis = smap_get(&op->nbsp->options, "requested-chassis"); if (requested_chassis) { - const struct sbrec_chassis *chassis = chassis_lookup( + requested_chassis_sb = 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; + if (!requested_chassis_sb) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT( 1, 1); VLOG_WARN_RL( @@ -3158,12 +3158,58 @@ ovn_port_update_sbrec_chassis( "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) { + + requested_additional_chassis = smap_get( + &op->nbsp->options, "requested-additional-chassis"); + if (requested_additional_chassis) { + requested_additional_chassis_sb = chassis_lookup( + sbrec_chassis_by_name, sbrec_chassis_by_hostname, + requested_additional_chassis); + if (!requested_additional_chassis_sb) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT( + 1, 1); + VLOG_WARN_RL( + &rl, + "Unknown chassis '%s' set as " + "options:requested-additional-chassis on LSP '%s'.", + requested_additional_chassis, op->nbsp->name); + } else if (requested_chassis_sb == requested_additional_chassis_sb) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT( + 1, 1); + VLOG_WARN_RL( + &rl, + "options:requested-chassis (%s) and " + "options:requested-additional-chassis (%s) point to the same " + "chassis on LSP '%s'. Ignoring additional chassis.", + requested_chassis, requested_additional_chassis, + op->nbsp->name); + requested_additional_chassis_sb = NULL; + } else if (!requested_chassis_sb) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT( + 1, 1); + VLOG_WARN_RL( + &rl, + "Chassis '%s' set as " + "options:requested-additional-chassis on LSP '%s', but " + "options:requested-chassis is unset. " + "Ignoring additional chassis.", + requested_additional_chassis, op->nbsp->name); + requested_additional_chassis_sb = NULL; + } + } + + if (requested_chassis_sb) { + sbrec_port_binding_set_requested_chassis(op->sb, requested_chassis_sb); + } else if (op->sb->requested_chassis) { sbrec_port_binding_set_requested_chassis(op->sb, NULL); } + if (requested_additional_chassis_sb) { + sbrec_port_binding_set_requested_additional_chassis( + op->sb, requested_additional_chassis_sb); + } else if (op->sb->requested_additional_chassis) { + sbrec_port_binding_set_requested_additional_chassis(op->sb, NULL); + } } static void diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 8a8c6d07d..984105a5f 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -100,7 +100,9 @@ static const char *rbac_fdb_update[] = static const char *rbac_port_binding_auth[] = {""}; static const char *rbac_port_binding_update[] = - {"chassis", "encap", "up", "virtual_parent"}; + {"chassis", "additional_chassis", + "encap", "additional_encap", + "up", "virtual_parent"}; static const char *rbac_mac_binding_auth[] = {""}; diff --git a/ovn-nb.xml b/ovn-nb.xml index 6a6972856..2ec3b90aa 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -1005,6 +1005,14 @@ one chassis. + + If set and used with , identifies an + additional chassis (by name or hostname) that is allowed to bind this + port. Using this option allows to configure a new location for a port + binding before the old location is ripped off. This option may be + useful in live migration scenarios, for port mirroring, etc. + + If set, this port will be bound by ovn-controller only if this same key and value is configured in the diff --git a/ovn-sb.ovsschema b/ovn-sb.ovsschema index 122614dd5..175c918a1 100644 --- a/ovn-sb.ovsschema +++ b/ovn-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Southbound", "version": "20.21.0", - "cksum": "2362446865 26963", + "cksum": "1635579573 27862", "tables": { "SB_Global": { "columns": { @@ -218,10 +218,18 @@ "refTable": "Chassis", "refType": "weak"}, "min": 0, "max": 1}}, + "additional_chassis": {"type": {"key": {"type": "uuid", + "refTable": "Chassis", + "refType": "weak"}, + "min": 0, "max": 1}}, "encap": {"type": {"key": {"type": "uuid", "refTable": "Encap", "refType": "weak"}, "min": 0, "max": 1}}, + "additional_encap": {"type": {"key": {"type": "uuid", + "refTable": "Encap", + "refType": "weak"}, + "min": 0, "max": 1}}, "mac": {"type": {"key": "string", "min": 0, "max": "unlimited"}}, @@ -236,6 +244,11 @@ "requested_chassis": {"type": {"key": {"type": "uuid", "refTable": "Chassis", "refType": "weak"}, + "min": 0, "max": 1}}, + "requested_additional_chassis": { + "type": {"key": {"type": "uuid", + "refTable": "Chassis", + "refType": "weak"}, "min": 0, "max": 1}}}, "indexes": [["datapath", "tunnel_key"], ["logical_port"]], "isRoot": true}, diff --git a/ovn-sb.xml b/ovn-sb.xml index 9ddacdf09..f43bb6804 100644 --- a/ovn-sb.xml +++ b/ovn-sb.xml @@ -2835,9 +2835,17 @@ tcp.flags = RST; - Points to supported encapsulation configurations to transmit - logical dataplane packets to this chassis. Each entry is a record that describes the configuration. + Points to preferred encapsulation configuration to transmit + logical dataplane packets to this chassis. The entry is reference to + a record. + + + + Points to preferred encapsulation configuration to transmit + logical dataplane packets to this additional chassis. The entry is + reference to a record. + + See also . @@ -2889,6 +2897,13 @@ tcp.flags = RST; + + The meaning of this column is the same as for the + . The column is used to track an additional + physical location of the logical port. Used with regular (empty + ) port bindings. + +

A list of . @@ -3047,6 +3062,33 @@ tcp.flags = RST; db="OVN_Northbound"/> is defined and contains a string matching the name or hostname of an existing chassis. + + See also + . + + + This column exists so that the ovn-controller can effectively monitor + all records destined for it, and is a + supplement to the option. The option is still + required so that the ovn-controller can check the CMS intent when the + chassis pointed to does not currently exist, which for example occurs + when the ovn-controller is stopped without passing the --restart + argument. + + This column must be a + record. This is populated by + ovn-northd when the + is defined and contains a string matching the name or hostname of an + existing chassis. + + See also . @@ -3212,6 +3254,16 @@ tcp.flags = RST; a live migration. It can also prevent similar thrashing due to a mis-configuration, if a port is accidentally created on more than one chassis. + + See also . + + + + If set and used with , identifies an + additional chassis (by name or hostname) that is allowed to bind this + port. Using this option allows to configure a new location for a port + binding before the old location is ripped off. This option may be + useful in live migration scenarios, for port mirroring, etc. diff --git a/tests/ovn.at b/tests/ovn.at index bbba41af4..3a5973459 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -13597,6 +13597,97 @@ OVN_CLEANUP([hv1]) AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD([ +AT_SETUP([options:requested-additional-chassis for logical port]) +ovn_start + +net_add n1 + +sim_add hv1 +as hv1 +check ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.11 + +sim_add hv2 +as hv2 +check ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.12 + +check ovn-nbctl ls-add ls0 +check ovn-nbctl lsp-add ls0 lsp0 + +# Allow only chassis hv1 to bind logical port lsp0. +check ovn-nbctl lsp-set-options lsp0 requested-chassis=hv1 + +as hv1 check ovs-vsctl -- add-port br-int lsp0 -- \ + set Interface lsp0 external-ids:iface-id=lsp0 +as hv2 check ovs-vsctl -- add-port br-int lsp0 -- \ + set Interface lsp0 external-ids:iface-id=lsp0 + +wait_row_count Chassis 1 name=hv1 +wait_row_count Chassis 1 name=hv2 +hv1_uuid=$(fetch_column Chassis _uuid name=hv1) +hv2_uuid=$(fetch_column Chassis _uuid name=hv2) + +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 + +# Request port binding at an additional chassis +check ovn-nbctl lsp-set-options lsp0 \ + requested-chassis=hv1 \ + requested-additional-chassis=hv2 + +wait_column "$hv1_uuid" Port_Binding chassis logical_port=lsp0 +wait_column "$hv1_uuid" Port_Binding requested_chassis logical_port=lsp0 +wait_column "$hv2_uuid" Port_Binding additional_chassis logical_port=lsp0 +wait_column "$hv2_uuid" Port_Binding requested_additional_chassis logical_port=lsp0 + +# Check that setting iface:encap-ip populates Port_Binding:additional_encap +wait_row_count Encap 2 chassis_name=hv1 +wait_row_count Encap 2 chassis_name=hv2 +encap_hv1_uuid=$(fetch_column Encap _uuid chassis_name=hv1 type=geneve) +encap_hv2_uuid=$(fetch_column Encap _uuid chassis_name=hv2 type=geneve) + +wait_column "" Port_Binding encap logical_port=lsp0 +wait_column "" Port_Binding additional_encap logical_port=lsp0 + +as hv1 check ovs-vsctl -- \ + set Interface lsp0 external-ids:encap-ip=192.168.0.11 +as hv2 check ovs-vsctl -- \ + set Interface lsp0 external-ids:encap-ip=192.168.0.12 + +wait_column "$encap_hv1_uuid" Port_Binding encap logical_port=lsp0 +wait_column "$encap_hv2_uuid" Port_Binding additional_encap logical_port=lsp0 + +# Complete moving the binding to the new location +check ovn-nbctl lsp-set-options lsp0 requested-chassis=hv2 + +wait_column "$hv2_uuid" Port_Binding chassis logical_port=lsp0 +wait_column "$hv2_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 + +# Check that additional_encap is cleared +wait_column "" Port_Binding additional_encap logical_port=lsp0 + +# Check that abrupted port migration clears additional_encap +check ovn-nbctl lsp-set-options lsp0 \ + requested-chassis=hv2 \ + requested-additional-chassis=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-nbctl lsp-set-options lsp0 requested-chassis=hv2 +wait_column "" Port_Binding additional_encap logical_port=lsp0 + +OVN_CLEANUP([hv1],[hv2]) + +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD([ AT_SETUP([options:requested-chassis for logical port]) ovn_start From patchwork Tue Feb 15 03:57:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592907 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=C3mfuiV4; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JyS5B2HPRz9sFv for ; Tue, 15 Feb 2022 14:59:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5897F83E43; Tue, 15 Feb 2022 03:59:07 +0000 (UTC) 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 n5vOMmtiI6Dw; Tue, 15 Feb 2022 03:59:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 070B783337; Tue, 15 Feb 2022 03:59:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B321FC0011; Tue, 15 Feb 2022 03:59:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7A13FC002D for ; Tue, 15 Feb 2022 03:58:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 915C840937 for ; Tue, 15 Feb 2022 03:58:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 jpkkUGrGYZ4r for ; Tue, 15 Feb 2022 03:58:05 +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 smtp2.osuosl.org (Postfix) with ESMTPS id 18B514092C for ; Tue, 15 Feb 2022 03:58:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897483; 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=QZQnq4J2OBxwLvTtwMBYs/ga3dj2IKvi2VOfHE2TbYM=; b=C3mfuiV4k+4HvwBmAwxLgRKTKQSeEQaInF748TkVhugl2GBh9Wj0wh8OF50ZFCBi5R3Z+7 X+oJ+IbFENoNneRKKDrt0jXM9kpMBBxG/RigJScKOFx4DcueB0GNaKBdwLoJ/V6kadcJI4 4nxTgNsW6JD997EmJlYKuKLtlOpOY10= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-388-gOgalxznPJ2hb5R00B5Pug-1; Mon, 14 Feb 2022 22:58:01 -0500 X-MC-Unique: gOgalxznPJ2hb5R00B5Pug-1 Received: by mail-qv1-f70.google.com with SMTP id kd18-20020a056214401200b0042de5c14702so1836850qvb.12 for ; Mon, 14 Feb 2022 19:58:01 -0800 (PST) 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=QZQnq4J2OBxwLvTtwMBYs/ga3dj2IKvi2VOfHE2TbYM=; b=hjZ3akugV2fL3aMX5GbL5lax/7zjzCAOepFZhEZ9fZm30Y4OHMefPGjw6kR+jnwOB5 czfSMcPHl2xZHeVr53h6noRGSzbqHd4sfXKUPWkdTkciHp154ZKK9B6lOUQTUXnDz1yC JklQiMauuN4e45wTKnlndzUxwp+0vIX8PKvtiglzm/fUa3wNiLTc/wzi5toNGsRdItvR cv3FYI8IlvewNrC6oB/FTidowj8ubD6lbdHhxy5+EltmG1c5E9ptIEyVAqTINOx5A99H 3VLiz8SxhTnyEfRyHx3H1/n34QIzufJXaGtSK9re3ND+KdGcdEO/Fcy6HEVD6tp6viaL d6QA== X-Gm-Message-State: AOAM533E4CA0FAiYB4x5eYZuYKZdcCVxsNpDSQoxRbBatoQw10kFBjs3 VgLKZszfL2EFnC/uiKMnmFX1EvT08Uu8cgz4gROT32utdNZ8rbiJA/Z5jrQe9WYE1sN/ltLYtrv MRXoYpvw/ziJvmRn8os6BMJjUUQs5dMJaO40GLts96Bn+FHOgLRViawZ4QE3a7QWD X-Received: by 2002:a05:6214:509a:: with SMTP id kk26mr1599859qvb.24.1644897480693; Mon, 14 Feb 2022 19:58:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwULaC8aeTC8bwFZHNgBDq7dOlsswrOwA4zeqSizYor1GMnl8nABeuR0UVZ+MusRjSPdGnxfw== X-Received: by 2002:a05:6214:509a:: with SMTP id kk26mr1599842qvb.24.1644897480167; Mon, 14 Feb 2022 19:58:00 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:57:59 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:35 +0000 Message-Id: <20220215035737.1820679-14-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 13/15] Clone packets to both port chassis 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 requested-additional-chassis is set, port binding is configured in two cluster locations. In case of live migration scenario, only one of the locations run a workload at a particular point in time. Yet, it's expected that the workload may switch to running at the additional-chassis at any moment during live migration (depends on libvirt / qemu migration progress). To speed up the switch to near instant, do the following: When a port located sends a packet to another port that has two chassis then, in addition to sending the packet to the main chassis, also send it to the additional chassis. When the sending port is bound on either the main or additional chassis, then handle the packet locally plus send it to the other chassis. This is achieved with additional flows in tables 37 and 38. Signed-off-by: Ihar Hrachyshka --- controller/physical.c | 180 +++++++++++++++++++---- tests/ovn.at | 335 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 486 insertions(+), 29 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index bc4f7c4f0..8aa94d850 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -287,12 +287,13 @@ match_outport_dp_and_port_keys(struct match *match, } static void -put_remote_port_redirect_overlay(const struct - sbrec_port_binding *binding, +put_remote_port_redirect_overlay(const struct sbrec_port_binding *binding, bool is_ha_remote, struct ha_chassis_ordered *ha_ch_ordered, enum mf_field_id mff_ovn_geneve, const struct chassis_tunnel *tun, + const struct chassis_tunnel *additional_tun, + uint32_t dp_key, uint32_t port_key, struct match *match, struct ofpbuf *ofpacts_p, @@ -301,14 +302,51 @@ put_remote_port_redirect_overlay(const struct { if (!is_ha_remote) { /* Setup encapsulation */ - if (!tun) { - return; + bool is_vtep = !strcmp(binding->type, "vtep"); + if (!additional_tun) { + /* Output to main chassis tunnel. */ + put_encapsulation(mff_ovn_geneve, tun, binding->datapath, port_key, + is_vtep, ofpacts_p); + ofpact_put_OUTPUT(ofpacts_p)->port = tun->ofport; + + ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 100, + binding->header_.uuid.parts[0], + match, ofpacts_p, &binding->header_.uuid); + } else { + /* For packets arriving from tunnels, don't clone to avoid sending + * packets received from another chassis back to it. */ + match_outport_dp_and_port_keys(match, dp_key, port_key); + match_set_reg_masked(match, MFF_LOG_FLAGS - MFF_REG0, + MLF_LOCAL_ONLY, MLF_LOCAL_ONLY); + + /* Output to main chassis tunnel. */ + put_encapsulation(mff_ovn_geneve, tun, binding->datapath, port_key, + is_vtep, ofpacts_p); + ofpact_put_OUTPUT(ofpacts_p)->port = tun->ofport; + + ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 110, + binding->header_.uuid.parts[0], match, ofpacts_p, + &binding->header_.uuid); + + /* For packets originating from this chassis, clone in addition to + * handling it locally. */ + match_outport_dp_and_port_keys(match, dp_key, port_key); + ofpbuf_clear(ofpacts_p); + + /* Output to main chassis tunnel. */ + put_encapsulation(mff_ovn_geneve, tun, binding->datapath, port_key, + is_vtep, ofpacts_p); + ofpact_put_OUTPUT(ofpacts_p)->port = tun->ofport; + + /* Output to additional chassis tunnel. */ + put_encapsulation(mff_ovn_geneve, additional_tun, + binding->datapath, port_key, is_vtep, ofpacts_p); + ofpact_put_OUTPUT(ofpacts_p)->port = additional_tun->ofport; + + ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 100, + binding->header_.uuid.parts[0], match, ofpacts_p, + &binding->header_.uuid); } - put_encapsulation(mff_ovn_geneve, tun, binding->datapath, port_key, - !strcmp(binding->type, "vtep"), - ofpacts_p); - /* Output to tunnel. */ - ofpact_put_OUTPUT(ofpacts_p)->port = tun->ofport; } else { /* Make sure all tunnel endpoints use the same encapsulation, * and set it up */ @@ -376,10 +414,11 @@ put_remote_port_redirect_overlay(const struct bundle->basis = 0; bundle->fields = NX_HASH_FIELDS_ETH_SRC; ofpact_finish_BUNDLE(ofpacts_p, &bundle); + + ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 100, + binding->header_.uuid.parts[0], + match, ofpacts_p, &binding->header_.uuid); } - ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 100, - binding->header_.uuid.parts[0], - match, ofpacts_p, &binding->header_.uuid); } @@ -728,6 +767,8 @@ put_local_common_flows(uint32_t dp_key, const struct sbrec_port_binding *pb, const struct sbrec_port_binding *parent_pb, const struct zone_ids *zone_ids, + const struct chassis_tunnel *additional_tun, + enum mf_field_id mff_ovn_geneve, struct ofpbuf *ofpacts_p, struct ovn_desired_flow_table *flow_table) { @@ -745,16 +786,42 @@ put_local_common_flows(uint32_t dp_key, ofpbuf_clear(ofpacts_p); - /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */ - match_outport_dp_and_port_keys(&match, dp_key, port_key); + if (!additional_tun) { + match_outport_dp_and_port_keys(&match, dp_key, port_key); - put_zones_ofpacts(zone_ids, ofpacts_p); + put_zones_ofpacts(zone_ids, ofpacts_p); + put_resubmit(OFTABLE_CHECK_LOOPBACK, ofpacts_p); + ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, + pb->header_.uuid.parts[0], &match, ofpacts_p, + &pb->header_.uuid); + } else { + /* For packets arriving from tunnels, don't clone again. */ + match_outport_dp_and_port_keys(&match, dp_key, port_key); + match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0, + MLF_LOCAL_ONLY, MLF_LOCAL_ONLY); - /* Resubmit to table 39. */ - put_resubmit(OFTABLE_CHECK_LOOPBACK, ofpacts_p); - ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, - pb->header_.uuid.parts[0], &match, ofpacts_p, - &pb->header_.uuid); + put_zones_ofpacts(zone_ids, ofpacts_p); + put_resubmit(OFTABLE_CHECK_LOOPBACK, ofpacts_p); + ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 110, + pb->header_.uuid.parts[0], &match, ofpacts_p, + &pb->header_.uuid); + + /* For packets originating from this chassis, clone in addition to + * handling it locally. */ + match_outport_dp_and_port_keys(&match, dp_key, port_key); + + ofpbuf_clear(ofpacts_p); + put_zones_ofpacts(zone_ids, ofpacts_p); + put_resubmit(OFTABLE_CHECK_LOOPBACK, ofpacts_p); + + put_encapsulation(mff_ovn_geneve, additional_tun, pb->datapath, + port_key, false, ofpacts_p); + ofpact_put_OUTPUT(ofpacts_p)->port = additional_tun->ofport; + + ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, + pb->header_.uuid.parts[0], &match, ofpacts_p, + &pb->header_.uuid); + } /* Table 39, Priority 100. * ======================= @@ -887,6 +954,40 @@ get_binding_peer(struct ovsdb_idl_index *sbrec_port_binding_by_name, return peer; } +static const struct chassis_tunnel * +get_additional_tunnel(const struct sbrec_port_binding *binding, + const struct sbrec_chassis *chassis, + const struct hmap *chassis_tunnels) +{ + const struct chassis_tunnel *tun = NULL; + if (!binding->additional_chassis) { + return NULL; + } + if (binding->additional_chassis == chassis) { + tun = get_port_binding_tun(binding->encap, binding->chassis, + chassis_tunnels); + if (!tun) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); + VLOG_WARN_RL( + &rl, "Failed to locate tunnel to reach main chassis %s " + "for port %s. Cloning packets disabled.", + binding->chassis->name, binding->logical_port); + } + } else { + tun = get_port_binding_tun(binding->additional_encap, + binding->additional_chassis, + chassis_tunnels); + if (!tun) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); + VLOG_WARN_RL( + &rl, "Failed to locate tunnel to reach additional chassis %s " + "for port %s. Cloning packets disabled.", + binding->additional_chassis->name, binding->logical_port); + } + } + return tun; +} + static void consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, enum mf_field_id mff_ovn_geneve, @@ -921,6 +1022,7 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, struct zone_ids binding_zones = get_zone_ids(binding, ct_zones); put_local_common_flows(dp_key, binding, NULL, &binding_zones, + NULL, mff_ovn_geneve, ofpacts_p, flow_table); ofpbuf_clear(ofpacts_p); @@ -1069,7 +1171,7 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, binding->logical_port); if (ofport && !lport_can_bind_on_this_chassis(chassis, binding)) { /* Even though there is an ofport for this port_binding, it is - * requested on a different chassis. So ignore this ofport. + * requested on different chassis. So ignore this ofport. */ ofport = 0; } @@ -1108,6 +1210,13 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, } } + /* Clone packets to additional chassis if needed. */ + const struct chassis_tunnel *additional_tun = NULL; + if (!localnet_port) { + additional_tun = get_additional_tunnel(binding, chassis, + chassis_tunnels); + } + if (!is_remote) { /* Packets that arrive from a vif can belong to a VM or * to a container located inside that VM. Packets that @@ -1118,6 +1227,7 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, /* Pass the parent port binding if the port is a nested * container. */ put_local_common_flows(dp_key, binding, parent_port, &zone_ids, + additional_tun, mff_ovn_geneve, ofpacts_p, flow_table); /* Table 0, Priority 150 and 100. @@ -1346,7 +1456,9 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, } else { put_remote_port_redirect_overlay(binding, is_ha_remote, ha_ch_ordered, mff_ovn_geneve, - tun, port_key, &match, ofpacts_p, + tun, additional_tun, + dp_key, port_key, + &match, ofpacts_p, chassis_tunnels, flow_table); } } @@ -1480,7 +1592,8 @@ consider_mc_group(struct ovsdb_idl_index *sbrec_port_binding_by_name, put_load(port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, &remote_ofpacts); put_resubmit(OFTABLE_CHECK_LOOPBACK, &remote_ofpacts); - } else if (port->chassis == chassis + } else if ((port->chassis == chassis + || port->additional_chassis == chassis) && (local_binding_get_primary_pb(local_bindings, lport_name) || !strcmp(port->type, "l3gateway"))) { put_load(port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, &ofpacts); @@ -1503,15 +1616,24 @@ consider_mc_group(struct ovsdb_idl_index *sbrec_port_binding_by_name, put_resubmit(OFTABLE_CHECK_LOOPBACK, &ofpacts); } } - } else if (port->chassis && !get_localnet_port( - local_datapaths, mc->datapath->tunnel_key)) { + } else if (!get_localnet_port(local_datapaths, + mc->datapath->tunnel_key)) { /* Add remote chassis only when localnet port not exist, * otherwise multicast will reach remote ports through localnet * port. */ - if (chassis_is_vtep(port->chassis)) { - sset_add(&vtep_chassis, port->chassis->name); - } else { - sset_add(&remote_chassis, port->chassis->name); + if (port->chassis) { + if (chassis_is_vtep(port->chassis)) { + sset_add(&vtep_chassis, port->chassis->name); + } else { + sset_add(&remote_chassis, port->chassis->name); + } + } + if (port->additional_chassis) { + if (chassis_is_vtep(port->additional_chassis)) { + sset_add(&vtep_chassis, port->additional_chassis->name); + } else { + sset_add(&remote_chassis, port->additional_chassis->name); + } } } } diff --git a/tests/ovn.at b/tests/ovn.at index 3a5973459..2c8c706df 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -13688,6 +13688,341 @@ OVN_CLEANUP([hv1],[hv2]) AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD([ +AT_SETUP([basic connectivity with options:requested-additional-chassis]) +ovn_start + +net_add n1 +for i in 1 2 3; do + sim_add hv$i + as hv$i + check ovs-vsctl add-br br-phys + ovn_attach n1 br-phys 192.168.0.$i +done + +# Disable local ARP responder to pass ARP requests through tunnels +check ovn-nbctl ls-add ls0 -- add Logical_Switch ls0 other_config vlan-passthru=true + +check ovn-nbctl lsp-add ls0 first +check ovn-nbctl lsp-add ls0 second +check ovn-nbctl lsp-add ls0 third +check ovn-nbctl lsp-add ls0 migrator +check ovn-nbctl lsp-set-addresses first "00:00:00:00:00:01 10.0.0.1" +check ovn-nbctl lsp-set-addresses second "00:00:00:00:00:02 10.0.0.2" +check ovn-nbctl lsp-set-addresses third "00:00:00:00:00:03 10.0.0.3" +check ovn-nbctl lsp-set-addresses migrator "00:00:00:00:00:ff 10.0.0.100" + +# The test scenario will migrate Migrator port between hv1 and hv2 and check +# that connectivity to and from the port is functioning properly for both +# chassis locations. Connectivity will be checked for resources located at hv1 +# (First) and hv2 (Second) as well as for hv3 (Third) that does not take part +# in port migration. +check ovn-nbctl lsp-set-options first requested-chassis=hv1 +check ovn-nbctl lsp-set-options second requested-chassis=hv2 +check ovn-nbctl lsp-set-options third requested-chassis=hv3 + +as hv1 check ovs-vsctl -- add-port br-int first -- \ + set Interface first external-ids:iface-id=first \ + options:tx_pcap=hv1/first-tx.pcap \ + options:rxq_pcap=hv1/first-rx.pcap +as hv2 check ovs-vsctl -- add-port br-int second -- \ + set Interface second external-ids:iface-id=second \ + options:tx_pcap=hv2/second-tx.pcap \ + options:rxq_pcap=hv2/second-rx.pcap +as hv3 check ovs-vsctl -- add-port br-int third -- \ + set Interface third external-ids:iface-id=third \ + options:tx_pcap=hv3/third-tx.pcap \ + options:rxq_pcap=hv3/third-rx.pcap + +# Create Migrator interfaces on both hv1 and hv2 +for hv in hv1 hv2; do + as $hv check ovs-vsctl -- add-port br-int migrator -- \ + set Interface migrator external-ids:iface-id=migrator \ + options:tx_pcap=$hv/migrator-tx.pcap \ + options:rxq_pcap=$hv/migrator-rx.pcap +done + +send_arp() { + local hv=$1 inport=$2 eth_src=$3 eth_dst=$4 spa=$5 tpa=$6 + local request=${eth_dst}${eth_src}08060001080006040001${eth_src}${spa}${eth_dst}${tpa} + as ${hv} ovs-appctl netdev-dummy/receive $inport $request + echo "${request}" +} + +reset_pcap_file() { + local hv=$1 + local iface=$2 + local pcap_file=$3 + as $hv check ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ + options:rxq_pcap=dummy-rx.pcap + check rm -f ${pcap_file}*.pcap + as $hv check ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ + options:rxq_pcap=${pcap_file}-rx.pcap +} + +reset_env() { + reset_pcap_file hv1 first hv1/first + reset_pcap_file hv2 second hv2/second + reset_pcap_file hv3 third hv3/third + reset_pcap_file hv1 migrator hv1/migrator + reset_pcap_file hv2 migrator hv2/migrator + + for port in hv1/migrator hv2/migrator hv1/first hv2/second hv3/third; do + : > $port.expected + done +} + +check_packets() { + OVN_CHECK_PACKETS([hv1/migrator-tx.pcap], [hv1/migrator.expected]) + OVN_CHECK_PACKETS([hv2/migrator-tx.pcap], [hv2/migrator.expected]) + OVN_CHECK_PACKETS([hv1/first-tx.pcap], [hv1/first.expected]) + OVN_CHECK_PACKETS([hv2/second-tx.pcap], [hv2/second.expected]) + OVN_CHECK_PACKETS([hv3/third-tx.pcap], [hv3/third.expected]) +} + +migrator_tpa=$(ip_to_hex 10 0 0 100) +first_spa=$(ip_to_hex 10 0 0 1) +second_spa=$(ip_to_hex 10 0 0 2) +third_spa=$(ip_to_hex 10 0 0 3) + +for hv in hv1 hv2 hv3; do + wait_row_count Chassis 1 name=$hv +done +hv1_uuid=$(fetch_column Chassis _uuid name=hv1) +hv2_uuid=$(fetch_column Chassis _uuid name=hv2) + +# Start with Migrator on hv1 but not hv2 +check ovn-nbctl lsp-set-options migrator requested-chassis=hv1 +wait_for_ports_up +wait_column "$hv1_uuid" Port_Binding chassis logical_port=migrator +wait_column "$hv1_uuid" Port_Binding requested_chassis logical_port=migrator +wait_column "" Port_Binding additional_chassis logical_port=migrator +wait_column "" Port_Binding requested_additional_chassis logical_port=migrator +wait_for_ports_up + +reset_env + +OVN_POPULATE_ARP + +# check that... +# unicast from First arrives to hv1:Migrator +# unicast from First doesn't arrive to hv2:Migrator +request=$(send_arp hv1 first 000000000001 0000000000ff $first_spa $migrator_tpa) +echo $request >> hv1/migrator.expected + +# mcast from First arrives to hv1:Migrator +# mcast from First doesn't arrive to hv2:Migrator +request=$(send_arp hv1 first 000000000001 ffffffffffff $first_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +# unicast from Second arrives to hv1:Migrator +# unicast from Second doesn't arrive to hv2:Migrator +request=$(send_arp hv2 second 000000000002 0000000000ff $second_spa $migrator_tpa) +echo $request >> hv1/migrator.expected + +# mcast from Second arrives to hv1:Migrator +# mcast from Second doesn't arrive to hv2:Migrator +request=$(send_arp hv2 second 000000000002 ffffffffffff $second_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv1/first.expected +echo $request >> hv3/third.expected + +# unicast from Third arrives to hv1:Migrator +# unicast from Third doesn't arrive to hv2:Migrator +request=$(send_arp hv3 third 000000000003 0000000000ff $third_spa $migrator_tpa) +echo $request >> hv1/migrator.expected + +# mcast from Third arrives to hv1:Migrator +# mcast from Third doesn't arrive to hv2:Migrator +request=$(send_arp hv3 third 000000000003 ffffffffffff $third_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected + +# unicast from hv1:Migrator arrives to First, Second, and Third +request=$(send_arp hv1 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +request=$(send_arp hv1 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +echo $request >> hv2/second.expected +request=$(send_arp hv1 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) +echo $request >> hv3/third.expected + +# unicast from hv2:Migrator doesn't arrive to First, Second, or Third +request=$(send_arp hv2 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +request=$(send_arp hv2 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +request=$(send_arp hv2 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) + +# mcast from hv1:Migrator arrives to First, Second, and Third +request=$(send_arp hv1 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +# mcast from hv2:Migrator doesn't arrive to First, Second, or Third +request=$(send_arp hv2 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) + +check_packets +reset_env + +# Start port migration hv1 -> hv2: both hypervisors are now bound +check ovn-nbctl lsp-set-options migrator requested-chassis=hv1 \ + requested-additional-chassis=hv2 +wait_for_ports_up +wait_column "$hv1_uuid" Port_Binding chassis logical_port=migrator +wait_column "$hv1_uuid" Port_Binding requested_chassis logical_port=migrator +wait_column "$hv2_uuid" Port_Binding additional_chassis logical_port=migrator +wait_column "$hv2_uuid" Port_Binding requested_additional_chassis logical_port=migrator + +# check that... +# unicast from First arrives to hv1:Migrator +# unicast from First arrives to hv2:Migrator +request=$(send_arp hv1 first 000000000001 0000000000ff $first_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected + +# mcast from First arrives to hv1:Migrator +# mcast from First arrives to hv2:Migrator +request=$(send_arp hv1 first 000000000001 ffffffffffff $first_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected +echo $request >> hv3/third.expected +echo $request >> hv2/second.expected + +# unicast from Second arrives to hv1:Migrator +# unicast from Second arrives to hv2:Migrator +request=$(send_arp hv2 second 000000000002 0000000000ff $second_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected + +# mcast from Second arrives to hv1:Migrator +# mcast from Second arrives to hv2:Migrator +request=$(send_arp hv2 second 000000000002 ffffffffffff $second_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected +echo $request >> hv3/third.expected +echo $request >> hv1/first.expected + +# unicast from Third arrives to hv1:Migrator binding +# unicast from Third arrives to hv2:Migrator binding +request=$(send_arp hv3 third 000000000003 0000000000ff $third_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected + +# mcast from Third arrives to hv1:Migrator +# mcast from Third arrives to hv2:Migrator +request=$(send_arp hv3 third 000000000003 ffffffffffff $third_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected + +# unicast from hv1:Migrator arrives to First, Second, and Third +request=$(send_arp hv1 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +request=$(send_arp hv1 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +echo $request >> hv2/second.expected +request=$(send_arp hv1 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) +echo $request >> hv3/third.expected + +# unicast from hv2:Migrator arrives to First, Second, and Third +request=$(send_arp hv2 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +request=$(send_arp hv2 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +echo $request >> hv2/second.expected +request=$(send_arp hv2 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) +echo $request >> hv3/third.expected + +# mcast from hv1:Migrator arrives to First, Second, and Third +request=$(send_arp hv1 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +# mcast from hv2:Migrator arrives to First, Second, and Third +request=$(send_arp hv2 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +check_packets +reset_env + +# Complete migration: destination is bound +check ovn-nbctl lsp-set-options migrator requested-chassis=hv2 +wait_for_ports_up +wait_column "$hv2_uuid" Port_Binding chassis logical_port=migrator +wait_column "$hv2_uuid" Port_Binding requested_chassis logical_port=migrator +wait_column "" Port_Binding additional_chassis logical_port=migrator +wait_column "" Port_Binding requested_additional_chassis logical_port=migrator + +# check that... +# unicast from Third doesn't arrive to hv1:Migrator +# unicast from Third arrives to hv2:Migrator +request=$(send_arp hv3 third 000000000003 0000000000ff $third_spa $migrator_tpa) +echo $request >> hv2/migrator.expected + +# mcast from Third doesn't arrive to hv1:Migrator +# mcast from Third arrives to hv2:Migrator +request=$(send_arp hv3 third 000000000003 ffffffffffff $third_spa $migrator_tpa) +echo $request >> hv2/migrator.expected +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected + +# unicast from First doesn't arrive to hv1:Migrator +# unicast from First arrives to hv2:Migrator +request=$(send_arp hv1 first 000000000001 0000000000ff $first_spa $migrator_tpa) +echo $request >> hv2/migrator.expected + +# mcast from First doesn't arrive to hv1:Migrator +# mcast from First arrives to hv2:Migrator binding +request=$(send_arp hv1 first 000000000001 ffffffffffff $first_spa $migrator_tpa) +echo $request >> hv2/migrator.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +# unicast from Second doesn't arrive to hv1:Migrator +# unicast from Second arrives to hv2:Migrator +request=$(send_arp hv2 second 000000000002 0000000000ff $second_spa $migrator_tpa) +echo $request >> hv2/migrator.expected + +# mcast from Second doesn't arrive to hv1:Migrator +# mcast from Second arrives to hv2:Migrator +request=$(send_arp hv2 second 000000000002 ffffffffffff $second_spa $migrator_tpa) +echo $request >> hv2/migrator.expected +echo $request >> hv1/first.expected +echo $request >> hv3/third.expected + +# unicast from hv1:Migrator doesn't arrive to First, Second, or Third +request=$(send_arp hv1 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +request=$(send_arp hv1 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +request=$(send_arp hv1 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) + +# unicast from hv2:Migrator arrives to First, Second, and Third +request=$(send_arp hv2 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +request=$(send_arp hv2 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +echo $request >> hv2/second.expected +request=$(send_arp hv2 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) +echo $request >> hv3/third.expected + +# mcast from hv1:Migrator doesn't arrive to First, Second, or Third +request=$(send_arp hv1 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) + +# mcast from hv2:Migrator arrives to First, Second, and Third +request=$(send_arp hv2 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +check_packets + +OVN_CLEANUP([hv1],[hv2],[hv3]) + +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD([ AT_SETUP([options:requested-chassis for logical port]) ovn_start From patchwork Tue Feb 15 03:57:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592902 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=MyEdIRJo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4JyS4Q0KhFz9sFv for ; Tue, 15 Feb 2022 14:58:29 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 60A24405F2; Tue, 15 Feb 2022 03:58:27 +0000 (UTC) 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 RMlegzmrd_wI; Tue, 15 Feb 2022 03:58:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id A583041E14; Tue, 15 Feb 2022 03:58:22 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5825AC0077; Tue, 15 Feb 2022 03:58:22 +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 0AFD1C0077 for ; Tue, 15 Feb 2022 03:58:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 1E035415AB for ; Tue, 15 Feb 2022 03:58:07 +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 dNcif2HXYqkb for ; Tue, 15 Feb 2022 03:58:05 +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.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 1E6BF4155D for ; Tue, 15 Feb 2022 03:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897483; 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=/7uUeMqXHVSYZ73oVWAlkiMDdKdB3qvIQRY1YYF90Z8=; b=MyEdIRJojwO0/w1cAILndAOn8g5MbE13+QrzJ1m29OyxgtugeJEBYzCgFH9wA1xi89aFFP DC/C/MCDUL5WoOS1E7uZ5d6vzJIC+N4Ry8TDTnxUA2xKyDrX++IVMKj2ihWB6GY33bc+ni nETw2D9xAAG7LMgnXNyxmkFxPDvj4io= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-587-k1HbFWl8Nj2X5U6ljsaKSg-1; Mon, 14 Feb 2022 22:58:02 -0500 X-MC-Unique: k1HbFWl8Nj2X5U6ljsaKSg-1 Received: by mail-qt1-f200.google.com with SMTP id g18-20020ac84b72000000b002cf274754c5so14063518qts.14 for ; Mon, 14 Feb 2022 19:58:02 -0800 (PST) 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=/7uUeMqXHVSYZ73oVWAlkiMDdKdB3qvIQRY1YYF90Z8=; b=h7FE4etgPCvHwvwoRtBc6fVch5ic4/pPoWQxGqPWTpT080M96eCpBUs1j9zP1HZIOE ciqgET8ItD0fjm3dIIDViyMrIM+S/uvzaEuz51OkPFG+hMglRc5sA3LNITii/Una+Zvp J6XchaY4Gpm0D9Qat7EpIQQtbUYItxahTHAkFOTppW94C0Jz88XzZZbqSBQq0Kd30fHy ddZXOYzs8Yy4fyWEbATtt8Mxi54/e7a13/6eqs8xswGOCjqQUGQL3NS5mDJ5FPdFkjDb tm8UK/uvfCKW3pDwZAD00QZVb1caUdXH2ddvIbPsx5e1Dg42LGUxqT+Hq8KD+og7oLF7 pyIQ== X-Gm-Message-State: AOAM532u42qMVpMeaP1pJTfi9R1ICVk3v5t2qnb6BQkRSAcACVjff7IO ofB3ThJyYLMe3M0n/ptn8rHDU9BgEUpyITZDGG5e96kxI2eSEQEWvbz4tRj+2+NcwzyYZK1gJgb PFxA1qlKzvA9vhy66qabZzmyIb0EbjJkRxymDKwVs6to8rTCYn/8cPK5YilvdI0sI X-Received: by 2002:ac8:5950:: with SMTP id 16mr1448956qtz.141.1644897481814; Mon, 14 Feb 2022 19:58:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJy73qob6Pzytfoi4Df9h2Z8emh+nh4zps997bf2YJmbpR6QS8SOWGvZBrIm8wu0EED+DUjQBw== X-Received: by 2002:ac8:5950:: with SMTP id 16mr1448940qtz.141.1644897481356; Mon, 14 Feb 2022 19:58:01 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:58:00 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:36 +0000 Message-Id: <20220215035737.1820679-15-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 14/15] Enforce tunneling when additional-chassis is set 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 additional-chassis is set, we cannot guarantee the upstream switch to deliver a unicast packet sent through a localnet port to both port chassis locations (pb->chassis and pb->additional_chassis). To deliver packets to both locations, switch to tunneling. Signed-off-by: Ihar Hrachyshka --- controller/physical.c | 11 +- tests/ovn.at | 360 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 365 insertions(+), 6 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index 8aa94d850..5d1598116 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -1184,7 +1184,9 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, if (!ofport) { /* It is remote port, may be reached by tunnel or localnet port */ is_remote = true; - if (localnet_port) { + /* Enforce tunneling while we clone packets to additional chassis b/c + * otherwise upstream switch won't flood the packet to both chassis. */ + if (localnet_port && !binding->additional_chassis) { ofport = u16_to_ofp(simap_get(patch_ofports, localnet_port->logical_port)); if (!ofport) { @@ -1211,11 +1213,8 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, } /* Clone packets to additional chassis if needed. */ - const struct chassis_tunnel *additional_tun = NULL; - if (!localnet_port) { - additional_tun = get_additional_tunnel(binding, chassis, - chassis_tunnels); - } + const struct chassis_tunnel *additional_tun; + additional_tun = get_additional_tunnel(binding, chassis, chassis_tunnels); if (!is_remote) { /* Packets that arrive from a vif can belong to a VM or diff --git a/tests/ovn.at b/tests/ovn.at index 2c8c706df..1ccec492d 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14023,6 +14023,366 @@ OVN_CLEANUP([hv1],[hv2],[hv3]) AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD([ +AT_SETUP([localnet connectivity with options:requested-additional-chassis]) +ovn_start + +net_add n1 +for i in 1 2 3; do + sim_add hv$i + as hv$i + check ovs-vsctl add-br br-phys + ovn_attach n1 br-phys 192.168.0.$i + check ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys +done + +# Disable local ARP responder to pass ARP requests through tunnels +check ovn-nbctl ls-add ls0 -- add Logical_Switch ls0 other_config vlan-passthru=true + +check ovn-nbctl lsp-add ls0 first +check ovn-nbctl lsp-add ls0 second +check ovn-nbctl lsp-add ls0 third +check ovn-nbctl lsp-add ls0 migrator +check ovn-nbctl lsp-set-addresses first "00:00:00:00:00:01 10.0.0.1" +check ovn-nbctl lsp-set-addresses second "00:00:00:00:00:02 10.0.0.2" +check ovn-nbctl lsp-set-addresses third "00:00:00:00:00:03 10.0.0.3" +check ovn-nbctl lsp-set-addresses migrator "00:00:00:00:00:ff 10.0.0.100" + +check ovn-nbctl lsp-add ls0 public +check ovn-nbctl lsp-set-type public localnet +check ovn-nbctl lsp-set-addresses public unknown +check ovn-nbctl lsp-set-options public network_name=phys + +# The test scenario will migrate Migrator port between hv1 and hv2 and check +# that connectivity to and from the port is functioning properly for both +# chassis locations. Connectivity will be checked for resources located at hv1 +# (First) and hv2 (Second) as well as for hv3 (Third) that does not take part +# in port migration. +check ovn-nbctl lsp-set-options first requested-chassis=hv1 +check ovn-nbctl lsp-set-options second requested-chassis=hv2 +check ovn-nbctl lsp-set-options third requested-chassis=hv3 + +as hv1 check ovs-vsctl -- add-port br-int first -- \ + set Interface first external-ids:iface-id=first \ + options:tx_pcap=hv1/first-tx.pcap \ + options:rxq_pcap=hv1/first-rx.pcap +as hv2 check ovs-vsctl -- add-port br-int second -- \ + set Interface second external-ids:iface-id=second \ + options:tx_pcap=hv2/second-tx.pcap \ + options:rxq_pcap=hv2/second-rx.pcap +as hv3 check ovs-vsctl -- add-port br-int third -- \ + set Interface third external-ids:iface-id=third \ + options:tx_pcap=hv3/third-tx.pcap \ + options:rxq_pcap=hv3/third-rx.pcap + +# Create Migrator interfaces on both hv1 and hv2 +for hv in hv1 hv2; do + as $hv check ovs-vsctl -- add-port br-int migrator -- \ + set Interface migrator external-ids:iface-id=migrator \ + options:tx_pcap=$hv/migrator-tx.pcap \ + options:rxq_pcap=$hv/migrator-rx.pcap +done + +send_arp() { + local hv=$1 inport=$2 eth_src=$3 eth_dst=$4 spa=$5 tpa=$6 + local request=${eth_dst}${eth_src}08060001080006040001${eth_src}${spa}${eth_dst}${tpa} + as ${hv} ovs-appctl netdev-dummy/receive $inport $request + echo "${request}" +} + +send_garp() { + local hv=$1 inport=$2 eth_src=$3 eth_dst=$4 spa=$5 tpa=$6 + local request=${eth_dst}${eth_src}08060001080006040002${eth_src}${spa}${eth_dst}${tpa} + as ${hv} ovs-appctl netdev-dummy/receive $inport $request + echo "${request}" +} + +reset_pcap_file() { + local hv=$1 + local iface=$2 + local pcap_file=$3 + as $hv check ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ + options:rxq_pcap=dummy-rx.pcap + check rm -f ${pcap_file}*.pcap + as $hv check ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ + options:rxq_pcap=${pcap_file}-rx.pcap +} + +reset_env() { + reset_pcap_file hv1 first hv1/first + reset_pcap_file hv2 second hv2/second + reset_pcap_file hv3 third hv3/third + reset_pcap_file hv1 migrator hv1/migrator + reset_pcap_file hv2 migrator hv2/migrator + + for port in hv1/migrator hv2/migrator hv1/first hv2/second hv3/third; do + : > $port.expected + done +} + +check_packets() { + # the test scenario gets spurious garps generated by vifs because of localnet + # attachment, hence using CONTAIN instead of strict matching + OVN_CHECK_PACKETS_CONTAIN([hv1/migrator-tx.pcap], [hv1/migrator.expected]) + OVN_CHECK_PACKETS_CONTAIN([hv2/migrator-tx.pcap], [hv2/migrator.expected]) + OVN_CHECK_PACKETS_CONTAIN([hv1/first-tx.pcap], [hv1/first.expected]) + OVN_CHECK_PACKETS_CONTAIN([hv2/second-tx.pcap], [hv2/second.expected]) + OVN_CHECK_PACKETS_CONTAIN([hv3/third-tx.pcap], [hv3/third.expected]) +} + +migrator_tpa=$(ip_to_hex 10 0 0 100) +first_spa=$(ip_to_hex 10 0 0 1) +second_spa=$(ip_to_hex 10 0 0 2) +third_spa=$(ip_to_hex 10 0 0 3) + +for hv in hv1 hv2 hv3; do + wait_row_count Chassis 1 name=$hv +done +hv1_uuid=$(fetch_column Chassis _uuid name=hv1) +hv2_uuid=$(fetch_column Chassis _uuid name=hv2) + +OVN_POPULATE_ARP + +# Start with Migrator on hv1 but not hv2 +check ovn-nbctl lsp-set-options migrator requested-chassis=hv1 +wait_column "$hv1_uuid" Port_Binding chassis logical_port=migrator +wait_column "$hv1_uuid" Port_Binding requested_chassis logical_port=migrator +wait_column "" Port_Binding additional_chassis logical_port=migrator +wait_column "" Port_Binding requested_additional_chassis logical_port=migrator +wait_for_ports_up + +# advertise location of ports through localnet port +send_garp hv1 migrator 0000000000ff ffffffffffff $migrator_spa $migrator_tpa +send_garp hv1 first 000000000001 ffffffffffff $first_spa $first_tpa +send_garp hv2 second 000000000002 ffffffffffff $second_spa $second_tpa +send_garp hv3 third 000000000003 ffffffffffff $third_spa $third_tpa +reset_env + +# check that... +# unicast from First arrives to hv1:Migrator +# unicast from First doesn't arrive to hv2:Migrator +request=$(send_arp hv1 first 000000000001 0000000000ff $first_spa $migrator_tpa) +echo $request >> hv1/migrator.expected + +# mcast from First arrives to hv1:Migrator +# mcast from First doesn't arrive to hv2:Migrator +request=$(send_arp hv1 first 000000000001 ffffffffffff $first_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +# unicast from Second arrives to hv1:Migrator +# unicast from Second doesn't arrive to hv2:Migrator +request=$(send_arp hv2 second 000000000002 0000000000ff $second_spa $migrator_tpa) +echo $request >> hv1/migrator.expected + +# mcast from Second arrives to hv1:Migrator +# mcast from Second doesn't arrive to hv2:Migrator +request=$(send_arp hv2 second 000000000002 ffffffffffff $second_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv1/first.expected +echo $request >> hv3/third.expected + +# unicast from Third arrives to hv1:Migrator +# unicast from Third doesn't arrive to hv2:Migrator +request=$(send_arp hv3 third 000000000003 0000000000ff $third_spa $migrator_tpa) +echo $request >> hv1/migrator.expected + +# mcast from Third arrives to hv1:Migrator +# mcast from Third doesn't arrive to hv2:Migrator +request=$(send_arp hv3 third 000000000003 ffffffffffff $third_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected + +# unicast from hv1:Migrator arrives to First, Second, and Third +request=$(send_arp hv1 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +request=$(send_arp hv1 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +echo $request >> hv2/second.expected +request=$(send_arp hv1 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) +echo $request >> hv3/third.expected + +# unicast from hv2:Migrator doesn't arrive to First, Second, or Third +request=$(send_arp hv2 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +request=$(send_arp hv2 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +request=$(send_arp hv2 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) + +# mcast from hv1:Migrator arrives to First, Second, and Third +request=$(send_arp hv1 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +# mcast from hv2:Migrator doesn't arrive to First, Second, or Third +request=$(send_arp hv2 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) + +check_packets +reset_env + +# Start port migration hv1 -> hv2: both hypervisors are now bound +check ovn-nbctl lsp-set-options migrator requested-chassis=hv1 \ + requested-additional-chassis=hv2 +wait_for_ports_up +wait_column "$hv1_uuid" Port_Binding chassis logical_port=migrator +wait_column "$hv1_uuid" Port_Binding requested_chassis logical_port=migrator +wait_column "$hv2_uuid" Port_Binding additional_chassis logical_port=migrator +wait_column "$hv2_uuid" Port_Binding requested_additional_chassis logical_port=migrator + +# check that... +# unicast from First arrives to hv1:Migrator +# unicast from First arrives to hv2:Migrator +request=$(send_arp hv1 first 000000000001 0000000000ff $first_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected + +# mcast from First arrives to hv1:Migrator +# mcast from First arrives to hv2:Migrator +request=$(send_arp hv1 first 000000000001 ffffffffffff $first_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected +echo $request >> hv3/third.expected +echo $request >> hv2/second.expected + +# unicast from Second arrives to hv1:Migrator +# unicast from Second arrives to hv2:Migrator +request=$(send_arp hv2 second 000000000002 0000000000ff $second_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected + +# mcast from Second arrives to hv1:Migrator +# mcast from Second arrives to hv2:Migrator +request=$(send_arp hv2 second 000000000002 ffffffffffff $second_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected +echo $request >> hv3/third.expected +echo $request >> hv1/first.expected + +# unicast from Third arrives to hv1:Migrator binding +# unicast from Third arrives to hv2:Migrator binding +request=$(send_arp hv3 third 000000000003 0000000000ff $third_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected + +# mcast from Third arrives to hv1:Migrator +# mcast from Third arrives to hv2:Migrator +request=$(send_arp hv3 third 000000000003 ffffffffffff $third_spa $migrator_tpa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected + +# unicast from hv1:Migrator arrives to First, Second, and Third +request=$(send_arp hv1 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +request=$(send_arp hv1 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +echo $request >> hv2/second.expected +request=$(send_arp hv1 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) +echo $request >> hv3/third.expected + +# unicast from hv2:Migrator arrives to First, Second, and Third +request=$(send_arp hv2 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +request=$(send_arp hv2 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +echo $request >> hv2/second.expected +request=$(send_arp hv2 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) +echo $request >> hv3/third.expected + +# mcast from hv1:Migrator arrives to First, Second, and Third +request=$(send_arp hv1 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +# mcast from hv2:Migrator arrives to First, Second, and Third +request=$(send_arp hv2 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +check_packets + +# Complete migration: destination is bound +check ovn-nbctl lsp-set-options migrator requested-chassis=hv2 +wait_column "$hv2_uuid" Port_Binding chassis logical_port=migrator +wait_column "$hv2_uuid" Port_Binding requested_chassis logical_port=migrator +wait_column "" Port_Binding additional_chassis logical_port=migrator +wait_column "" Port_Binding requested_additional_chassis logical_port=migrator +wait_for_ports_up + +check ovn-nbctl --wait=hv sync +sleep 1 + +# advertise new location of the port through localnet port +send_garp hv2 migrator 0000000000ff ffffffffffff $migrator_spa $migrator_tpa +reset_env + +# check that... +# unicast from Third doesn't arrive to hv1:Migrator +# unicast from Third arrives to hv2:Migrator +request=$(send_arp hv3 third 000000000003 0000000000ff $third_spa $migrator_tpa) +echo $request >> hv2/migrator.expected + +# mcast from Third doesn't arrive to hv1:Migrator +# mcast from Third arrives to hv2:Migrator +request=$(send_arp hv3 third 000000000003 ffffffffffff $third_spa $migrator_tpa) +echo $request >> hv2/migrator.expected +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected + +# unicast from First doesn't arrive to hv1:Migrator +# unicast from First arrives to hv2:Migrator +request=$(send_arp hv1 first 000000000001 0000000000ff $first_spa $migrator_tpa) +echo $request >> hv2/migrator.expected + +# mcast from First doesn't arrive to hv1:Migrator +# mcast from First arrives to hv2:Migrator binding +request=$(send_arp hv1 first 000000000001 ffffffffffff $first_spa $migrator_tpa) +echo $request >> hv2/migrator.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +# unicast from Second doesn't arrive to hv1:Migrator +# unicast from Second arrives to hv2:Migrator +request=$(send_arp hv2 second 000000000002 0000000000ff $second_spa $migrator_tpa) +echo $request >> hv2/migrator.expected + +# mcast from Second doesn't arrive to hv1:Migrator +# mcast from Second arrives to hv2:Migrator +request=$(send_arp hv2 second 000000000002 ffffffffffff $second_spa $migrator_tpa) +echo $request >> hv2/migrator.expected +echo $request >> hv1/first.expected +echo $request >> hv3/third.expected + +# unicast from hv1:Migrator doesn't arrive to First, Second, or Third +request=$(send_arp hv1 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +request=$(send_arp hv1 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +request=$(send_arp hv1 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) + +# unicast from hv2:Migrator arrives to First, Second, and Third +request=$(send_arp hv2 migrator 0000000000ff 000000000001 $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +request=$(send_arp hv2 migrator 0000000000ff 000000000002 $migrator_tpa $second_spa) +echo $request >> hv2/second.expected +request=$(send_arp hv2 migrator 0000000000ff 000000000003 $migrator_tpa $third_spa) +echo $request >> hv3/third.expected + +# mcast from hv1:Migrator doesn't arrive to First, Second, or Third +request=$(send_arp hv1 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) + +# mcast from hv2:Migrator arrives to First, Second, and Third +request=$(send_arp hv2 migrator 0000000000ff ffffffffffff $migrator_tpa $first_spa) +echo $request >> hv1/first.expected +echo $request >> hv2/second.expected +echo $request >> hv3/third.expected + +check_packets + +OVN_CLEANUP([hv1],[hv2],[hv3]) + +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD([ AT_SETUP([options:requested-chassis for logical port]) ovn_start From patchwork Tue Feb 15 03:57:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1592906 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=AsRAjMZv; 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 4JyS504DfKz9sFv for ; Tue, 15 Feb 2022 14:59:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 40C4C61CA3; Tue, 15 Feb 2022 03:58:58 +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 VwzI594JLRBm; Tue, 15 Feb 2022 03:58:51 +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 B66CA6F669; Tue, 15 Feb 2022 03:58:42 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7AAC8C002D; Tue, 15 Feb 2022 03:58:42 +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 1B813C007A for ; Tue, 15 Feb 2022 03:58:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E52B541545 for ; Tue, 15 Feb 2022 03:58:11 +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 diOjd1nkyPvR for ; Tue, 15 Feb 2022 03:58:08 +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.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 2631B415AC for ; Tue, 15 Feb 2022 03:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644897486; 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=AQnV1pQOYPlul8T9hUWeA4Oq+I1mWW1K6qPgLCW6PkM=; b=AsRAjMZvFG1wQhYBYWXe4t6DSXCIVpszdeUPSUFsfzVkYkqvMbcqKywOE8WEfhQXK1M7l/ zX8DTSvwdtlXnyKcJPWeSdXi358UonqkBiaWSySzPPgC/oZCjLbBO9pwbTiG8+smL9SRib seWbKJo5sbzMM71WArdlA91pVDO7YfA= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-601-rwdtDHboNxiDQEG0V4B2aw-1; Mon, 14 Feb 2022 22:58:04 -0500 X-MC-Unique: rwdtDHboNxiDQEG0V4B2aw-1 Received: by mail-qt1-f200.google.com with SMTP id y1-20020ac87041000000b002c3db9c25f8so14040009qtm.5 for ; Mon, 14 Feb 2022 19:58:04 -0800 (PST) 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=AQnV1pQOYPlul8T9hUWeA4Oq+I1mWW1K6qPgLCW6PkM=; b=B6gxA5ZEKqeVdzPOuN3R+PxAU2kR64POBxtg2mF8OYcjaR7Y9tGMVOerx2g1+FTq5o 3An+ZZ1tyyUOx+411MmiZVDyw9W5xErVKPOODjnEiBR79Enx1MhFqtzYvz2rlfsDpU8n sNCCA0lcEbUbsJOMtwY6dKhD0QDLy0JwXjfQSNUNwHfkNowG0CITKecRq6/r+Eq4gyuW MGlwRHr6KBI4MExIyFU7GR09KFVkijpytQzEEMldeh72mERRCd5fo2MaS9s7tLBc9JWf ygaRtXBWDE0km9tRbGA3Jjpuz/tE83Gp7hgi0winWLc2V0o/VAfggqXKRp9J2iV0TuhO U/hg== X-Gm-Message-State: AOAM5301GXDC8UBAnuv6Lk04QbC/LV1LrEu2aCrXwSZJZi9fHZq6AS1M jtDwLGmhe3oLByzT4VJBfx/GBZiD/fADxyu5TfG/w8w6bsBwWXEUiTwhpn89v2407OBs79KoM4T FREd6/yc+Vtcmq4bG9sZjShfsMw/m3YUoUqEfsSxGqiAsrJzRAZG9rQGxg+zqOSmu X-Received: by 2002:a05:622a:1102:: with SMTP id e2mr1520995qty.2.1644897483533; Mon, 14 Feb 2022 19:58:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxIcTDgbB2b0MFNhk5tHw1F40ZZU31a6O2AvJydTyPJx4ZCGg6pdAmXEdul6Pu960NFiImqug== X-Received: by 2002:a05:622a:1102:: with SMTP id e2mr1520984qty.2.1644897483062; Mon, 14 Feb 2022 19:58:03 -0800 (PST) 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 br30sm16753001qkb.67.2022.02.14.19.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 19:58:01 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Tue, 15 Feb 2022 03:57:37 +0000 Message-Id: <20220215035737.1820679-16-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220215035737.1820679-1-ihrachys@redhat.com> References: <20220215035737.1820679-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 15/15] Implement RARP activation strategy for ports 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 options:activation-strategy is set to "rarp" for LSP, when used in combination with options:requested-additional-chassis, the additional chassis will install special flows that would block all ingress and egress traffic for the port until a special activation event happens. For "rarp" strategy, an observation of a RARP packet sent from the port on the additional chassis is such an event. When it occurs, a special flow passes control to a controller() action handler that removes the installed blocking flows and also marks the port as options:additional-chassis-activated in southbound db. Once vswitchd processes the flow mod request, the port is ready to communicate from the new location. This feature is useful in live migration scenarios where it's not advisable to unlock the destination port location prematurily to avoid duplicate packets originating from the port. Signed-off-by: Ihar Hrachyshka --- controller/physical.c | 74 +++++++++++++++++++ controller/pinctrl.c | 161 +++++++++++++++++++++++++++++++++++++++++- controller/pinctrl.h | 2 + include/ovn/actions.h | 9 +++ lib/actions.c | 40 ++++++++++- northd/northd.c | 7 ++ northd/ovn-northd.c | 5 +- ovn-nb.xml | 10 +++ ovn-sb.xml | 15 ++++ tests/ovn.at | 160 +++++++++++++++++++++++++++++++++++++++++ utilities/ovn-trace.c | 3 + 11 files changed, 482 insertions(+), 4 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index 5d1598116..4bb0ed317 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -40,7 +40,9 @@ #include "lib/mcast-group-index.h" #include "lib/ovn-sb-idl.h" #include "lib/ovn-util.h" +#include "ovn/actions.h" #include "physical.h" +#include "pinctrl.h" #include "openvswitch/shash.h" #include "simap.h" #include "smap.h" @@ -988,6 +990,59 @@ get_additional_tunnel(const struct sbrec_port_binding *binding, return tun; } +static void +setup_rarp_activation_strategy(const struct sbrec_port_binding *binding, + struct ovn_desired_flow_table *flow_table, + struct ofpbuf *ofpacts_p) +{ + struct match match = MATCH_CATCHALL_INITIALIZER; + uint32_t dp_key = binding->datapath->tunnel_key; + uint32_t port_key = binding->tunnel_key; + + /* Unblock the port on ingress RARP. */ + match_set_metadata(&match, htonll(dp_key)); + match_set_dl_type(&match, htons(ETH_TYPE_RARP)); + match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, port_key); + ofpbuf_clear(ofpacts_p); + + size_t ofs = ofpacts_p->size; + struct ofpact_controller *oc = ofpact_put_CONTROLLER(ofpacts_p); + oc->max_len = UINT16_MAX; + oc->reason = OFPR_ACTION; + oc->pause = true; + + struct action_header ah = { + .opcode = htonl(ACTION_OPCODE_ACTIVATION_STRATEGY_RARP) + }; + ofpbuf_put(ofpacts_p, &ah, sizeof ah); + + ofpacts_p->header = oc; + oc->userdata_len = ofpacts_p->size - (ofs + sizeof *oc); + ofpact_finish_CONTROLLER(ofpacts_p, &oc); + + ofctrl_add_flow(flow_table, OFTABLE_LOG_INGRESS_PIPELINE, 1010, + binding->header_.uuid.parts[0], + &match, ofpacts_p, &binding->header_.uuid); + ofpbuf_clear(ofpacts_p); + + /* Block all non-RARP traffic for the port, both directions. */ + match_init_catchall(&match); + match_set_metadata(&match, htonll(dp_key)); + match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, port_key); + + ofctrl_add_flow(flow_table, OFTABLE_LOG_INGRESS_PIPELINE, 1000, + binding->header_.uuid.parts[0], + &match, ofpacts_p, &binding->header_.uuid); + + match_init_catchall(&match); + match_set_metadata(&match, htonll(dp_key)); + match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key); + + ofctrl_add_flow(flow_table, OFTABLE_LOG_EGRESS_PIPELINE, 1000, + binding->header_.uuid.parts[0], + &match, ofpacts_p, &binding->header_.uuid); +} + static void consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, enum mf_field_id mff_ovn_geneve, @@ -1212,6 +1267,25 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, } } + if (binding->additional_chassis == chassis) { + const char *strategy = smap_get(&binding->options, + "activation-strategy"); + if (strategy + && !smap_get_bool(&binding->options, + "additional-chassis-activated", false) + && !pinctrl_is_port_activated(dp_key, port_key)) { + if (!strcmp(strategy, "rarp")) { + setup_rarp_activation_strategy(binding, flow_table, ofpacts_p); + } else { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); + VLOG_WARN_RL(&rl, + "Unknown activation strategy defined for " + "port %s: %s", binding->logical_port, strategy); + goto out; + } + } + } + /* Clone packets to additional chassis if needed. */ const struct chassis_tunnel *additional_tun; additional_tun = get_additional_tunnel(binding, chassis, chassis_tunnels); diff --git a/controller/pinctrl.c b/controller/pinctrl.c index fd0bccdb6..ac44debe0 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -29,10 +29,12 @@ #include "lport.h" #include "mac-learn.h" #include "nx-match.h" +#include "ofctrl.h" #include "latch.h" #include "lib/packets.h" #include "lib/sset.h" #include "openvswitch/ofp-actions.h" +#include "openvswitch/ofp-flow.h" #include "openvswitch/ofp-msgs.h" #include "openvswitch/ofp-packet.h" #include "openvswitch/ofp-print.h" @@ -152,8 +154,8 @@ VLOG_DEFINE_THIS_MODULE(pinctrl); * and pinctrl_run(). * 'pinctrl_handler_seq' is used by pinctrl_run() to * wake up pinctrl_handler thread from poll_block() if any changes happened - * in 'send_garp_rarp_data', 'ipv6_ras' and 'buffered_mac_bindings' - * structures. + * in 'send_garp_rarp_data', 'ipv6_ras', 'activated_ports' and + * 'buffered_mac_bindings' structures. * * 'pinctrl_main_seq' is used by pinctrl_handler() thread to wake up * the main thread from poll_block() when mac bindings/igmp groups need to @@ -198,6 +200,17 @@ static void wait_put_mac_bindings(struct ovsdb_idl_txn *ovnsb_idl_txn); static void send_mac_binding_buffered_pkts(struct rconn *swconn) OVS_REQUIRES(pinctrl_mutex); +static void pinctrl_rarp_activation_strategy_handler(struct rconn *swconn, + const struct match *md); +static void init_activated_ports(void); +static void destroy_activated_ports(void); +static void wait_activated_ports(struct ovsdb_idl_txn *ovnsb_idl_txn); +static void run_activated_ports( + struct ovsdb_idl_txn *ovnsb_idl_txn, + struct ovsdb_idl_index *sbrec_datapath_binding_by_key, + struct ovsdb_idl_index *sbrec_port_binding_by_name) + OVS_REQUIRES(pinctrl_mutex); + static void init_send_garps_rarps(void); static void destroy_send_garps_rarps(void); static void send_garp_rarp_wait(long long int send_garp_rarp_time); @@ -522,6 +535,7 @@ pinctrl_init(void) init_ipv6_ras(); init_ipv6_prefixd(); init_buffered_packets_map(); + init_activated_ports(); init_event_table(); ip_mcast_snoop_init(); init_put_vport_bindings(); @@ -3242,6 +3256,12 @@ process_packet_in(struct rconn *swconn, const struct ofp_header *msg) ovs_mutex_unlock(&pinctrl_mutex); break; + case ACTION_OPCODE_ACTIVATION_STRATEGY_RARP: + ovs_mutex_lock(&pinctrl_mutex); + pinctrl_rarp_activation_strategy_handler(swconn, &pin.flow_metadata); + ovs_mutex_unlock(&pinctrl_mutex); + break; + default: VLOG_WARN_RL(&rl, "unrecognized packet-in opcode %"PRIu32, ntohl(ah->opcode)); @@ -3506,6 +3526,8 @@ pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, bfd_monitor_run(ovnsb_idl_txn, bfd_table, sbrec_port_binding_by_name, chassis, active_tunnels); run_put_fdbs(ovnsb_idl_txn, sbrec_fdb_by_dp_key_mac); + run_activated_ports(ovnsb_idl_txn, sbrec_datapath_binding_by_key, + sbrec_port_binding_by_key); ovs_mutex_unlock(&pinctrl_mutex); } @@ -4034,6 +4056,7 @@ pinctrl_wait(struct ovsdb_idl_txn *ovnsb_idl_txn) int64_t new_seq = seq_read(pinctrl_main_seq); seq_wait(pinctrl_main_seq, new_seq); wait_put_fdbs(ovnsb_idl_txn); + wait_activated_ports(ovnsb_idl_txn); } /* Called by ovn-controller. */ @@ -4048,6 +4071,7 @@ pinctrl_destroy(void) destroy_ipv6_ras(); destroy_ipv6_prefixd(); destroy_buffered_packets_map(); + destroy_activated_ports(); event_table_destroy(); destroy_put_mac_bindings(); destroy_put_vport_bindings(); @@ -7727,6 +7751,139 @@ pinctrl_handle_svc_check(struct rconn *swconn, const struct flow *ip_flow, } } +static struct ofpbuf * +encode_flow_mod(struct ofputil_flow_mod *fm) +{ + fm->buffer_id = UINT32_MAX; + fm->out_port = OFPP_ANY; + fm->out_group = OFPG_ANY; + return ofputil_encode_flow_mod(fm, OFPUTIL_P_OF15_OXM); +} + +struct port_pair { + uint32_t dp_key; + uint32_t port_key; + struct ovs_list list; +}; + +static struct ovs_list activated_ports; + +static void +init_activated_ports(void) +{ + ovs_list_init(&activated_ports); +} + +static void +destroy_activated_ports(void) +{ + struct port_pair *pp; + LIST_FOR_EACH_POP (pp, list, &activated_ports) { + free(pp); + } +} + +static void +wait_activated_ports(struct ovsdb_idl_txn *ovnsb_idl_txn) +{ + if (ovnsb_idl_txn && !ovs_list_is_empty(&activated_ports)) { + poll_immediate_wake(); + } +} + +static void +run_activated_ports(struct ovsdb_idl_txn *ovnsb_idl_txn, + struct ovsdb_idl_index *sbrec_datapath_binding_by_key, + struct ovsdb_idl_index *sbrec_port_binding_by_key) + OVS_REQUIRES(pinctrl_mutex) +{ + if (!ovnsb_idl_txn) { + return; + } + + const struct port_pair *pp; + LIST_FOR_EACH (pp, list, &activated_ports) { + const struct sbrec_port_binding *pb = lport_lookup_by_key( + sbrec_datapath_binding_by_key, sbrec_port_binding_by_key, + pp->dp_key, pp->port_key); + if (pb) { + sbrec_port_binding_update_options_setkey( + pb, "additional-chassis-activated", "true"); + } + } + destroy_activated_ports(); +} + +bool pinctrl_is_port_activated(int64_t dp_key, int64_t port_key) + OVS_REQUIRES(pinctrl_mutex) +{ + const struct port_pair *pp; + LIST_FOR_EACH (pp, list, &activated_ports) { + if (pp->dp_key == dp_key && pp->port_key == port_key) { + return true; + } + } + return false; +} + +static void +pinctrl_rarp_activation_strategy_handler(struct rconn *swconn, + const struct match *md) + OVS_REQUIRES(pinctrl_mutex) +{ + struct match match; + struct minimatch mmatch; + + /* Delete inport controller flow (the one that got us here */ + match_init_catchall(&match); + match_set_metadata(&match, md->flow.metadata); + match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, + md->flow.regs[MFF_LOG_INPORT - MFF_REG0]); + match_set_dl_type(&match, htons(ETH_TYPE_RARP)); + minimatch_init(&mmatch, &match); + + struct ofputil_flow_mod fm = { + .match = mmatch, + .priority = 1010, + .table_id = OFTABLE_LOG_INGRESS_PIPELINE, + .command = OFPFC_DELETE_STRICT, + }; + queue_msg(swconn, encode_flow_mod(&fm)); + minimatch_destroy(&mmatch); + + /* Delete ingress/egress drop flows to unblock the port. */ + match_init_catchall(&match); + match_set_metadata(&match, md->flow.metadata); + match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, + md->flow.regs[MFF_LOG_INPORT - MFF_REG0]); + minimatch_init(&mmatch, &match); + + fm.match = mmatch; + fm.priority = 1000; + queue_msg(swconn, encode_flow_mod(&fm)); + minimatch_destroy(&mmatch); + + match_init_catchall(&match); + match_set_metadata(&match, md->flow.metadata); + match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, + md->flow.regs[MFF_LOG_INPORT - MFF_REG0]); + minimatch_init(&mmatch, &match); + + fm.match = mmatch; + fm.table_id = OFTABLE_LOG_EGRESS_PIPELINE; + queue_msg(swconn, encode_flow_mod(&fm)); + minimatch_destroy(&mmatch); + + /* Tag the port as activated in-memory. */ + struct port_pair *pp = xmalloc(sizeof *pp); + pp->port_key = md->flow.regs[MFF_LOG_INPORT - MFF_REG0]; + pp->dp_key = ntohll(md->flow.metadata); + ovs_list_push_front(&activated_ports, &pp->list); + + /* Notify main thread on pending additional-chassis-activated updates. */ + notify_pinctrl_main(); +} + static struct hmap put_fdbs; /* MAC learning (fdb) related functions. Runs within the main diff --git a/controller/pinctrl.h b/controller/pinctrl.h index 88f18e983..c6cc66e85 100644 --- a/controller/pinctrl.h +++ b/controller/pinctrl.h @@ -56,4 +56,6 @@ void pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, void pinctrl_wait(struct ovsdb_idl_txn *ovnsb_idl_txn); void pinctrl_destroy(void); void pinctrl_set_br_int_name(char *br_int_name); + +bool pinctrl_is_port_activated(int64_t dp_key, int64_t port_key); #endif /* controller/pinctrl.h */ diff --git a/include/ovn/actions.h b/include/ovn/actions.h index cdef5fb03..524185095 100644 --- a/include/ovn/actions.h +++ b/include/ovn/actions.h @@ -113,6 +113,7 @@ struct ovn_extend_table; OVNACT(PUT_FDB, ovnact_put_fdb) \ OVNACT(GET_FDB, ovnact_get_fdb) \ OVNACT(LOOKUP_FDB, ovnact_lookup_fdb) \ + OVNACT(ACTIVATION_STRATEGY_RARP, ovnact_activation_strategy_rarp) \ /* enum ovnact_type, with a member OVNACT_ for each action. */ enum OVS_PACKED_ENUM ovnact_type { @@ -411,6 +412,11 @@ struct ovnact_handle_svc_check { struct expr_field port; /* Logical port name. */ }; +/* OVNACT_ACTIVATION_STRATEGY_RARP. */ +struct ovnact_activation_strategy_rarp { + struct ovnact ovnact; +}; + /* OVNACT_FWD_GROUP. */ struct ovnact_fwd_group { struct ovnact ovnact; @@ -672,6 +678,9 @@ enum action_opcode { /* put_fdb(inport, eth.src). */ ACTION_OPCODE_PUT_FDB, + + /* activation_strategy_rarp() */ + ACTION_OPCODE_ACTIVATION_STRATEGY_RARP, }; /* Header. */ diff --git a/lib/actions.c b/lib/actions.c index d5d8391bb..cddb6993d 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -3565,6 +3565,41 @@ ovnact_handle_svc_check_free(struct ovnact_handle_svc_check *sc OVS_UNUSED) { } +static void +parse_activation_strategy_rarp(struct action_context *ctx OVS_UNUSED) +{ + if (!lexer_force_match(ctx->lexer, LEX_T_LPAREN)) { + return; + } + + ovnact_put_ACTIVATION_STRATEGY_RARP(ctx->ovnacts); + lexer_force_match(ctx->lexer, LEX_T_RPAREN); +} + +static void +format_ACTIVATION_STRATEGY_RARP( + const struct ovnact_activation_strategy_rarp *activation OVS_UNUSED, + struct ds *s) +{ + ds_put_cstr(s, "activation_strategy_rarp();"); +} + +static void +encode_ACTIVATION_STRATEGY_RARP( + const struct ovnact_activation_strategy_rarp *activation OVS_UNUSED, + const struct ovnact_encode_params *ep, + struct ofpbuf *ofpacts) +{ + encode_controller_op(ACTION_OPCODE_ACTIVATION_STRATEGY_RARP, + ep->ctrl_meter_id, ofpacts); +} + +static void +ovnact_activation_strategy_rarp_free( + struct ovnact_activation_strategy_rarp *activation OVS_UNUSED) +{ +} + static void parse_fwd_group_action(struct action_context *ctx) { @@ -4113,6 +4148,8 @@ parse_action(struct action_context *ctx) parse_bind_vport(ctx); } else if (lexer_match_id(ctx->lexer, "handle_svc_check")) { parse_handle_svc_check(ctx); + } else if (lexer_match_id(ctx->lexer, "activation_strategy_rarp")) { + parse_activation_strategy_rarp(ctx); } else if (lexer_match_id(ctx->lexer, "fwd_group")) { parse_fwd_group_action(ctx); } else if (lexer_match_id(ctx->lexer, "handle_dhcpv6_reply")) { @@ -4356,7 +4393,8 @@ ovnact_op_to_string(uint32_t ovnact_opc) ACTION_OPCODE(BIND_VPORT) \ ACTION_OPCODE(DHCP6_SERVER) \ ACTION_OPCODE(HANDLE_SVC_CHECK) \ - ACTION_OPCODE(BFD_MSG) + ACTION_OPCODE(BFD_MSG) \ + ACTION_OPCODE(ACTIVATION_STRATEGY_RARP) #define ACTION_OPCODE(ENUM) \ case ACTION_OPCODE_##ENUM: return xstrdup(#ENUM); ACTION_OPCODES diff --git a/northd/northd.c b/northd/northd.c index 108ccb14f..ba6ac4cb8 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -3370,6 +3370,13 @@ ovn_port_update_sbrec(struct northd_input *input_data, smap_add(&options, "vlan-passthru", "true"); } + /* Retain activated flag. */ + if (op->sb->requested_additional_chassis + && smap_get_bool(&op->sb->options, + "additional-chassis-activated", false)) { + smap_add(&options, "additional-chassis-activated", "true"); + } + sbrec_port_binding_set_options(op->sb, &options); smap_destroy(&options); if (ovn_is_known_nb_lsp_type(op->nbsp->type)) { diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 984105a5f..b1f840895 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -102,7 +102,10 @@ static const char *rbac_port_binding_auth[] = static const char *rbac_port_binding_update[] = {"chassis", "additional_chassis", "encap", "additional_encap", - "up", "virtual_parent"}; + "up", "virtual_parent", + /* NOTE: we only need to update the additional-chassis-activated key, + * but RBAC_Role doesn't support mutate operation for subkeys. */ + "options"}; static const char *rbac_mac_binding_auth[] = {""}; diff --git a/ovn-nb.xml b/ovn-nb.xml index 2ec3b90aa..5ef23b1e7 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -1013,6 +1013,16 @@ useful in live migration scenarios, for port mirroring, etc. + + If set and used with , + specifies an activation strategy for the additional chassis. By + default, no activation strategy is used, meaning the additional port + location is immediately available for use. When set to "rarp", the + port is blocked for ingress and egress communication until a RARP + packet is sent from the new location. The "rarp" strategy is useful + in live migration scenarios for virtual machines. + + If set, this port will be bound by ovn-controller only if this same key and value is configured in the diff --git a/ovn-sb.xml b/ovn-sb.xml index f43bb6804..4c70657b5 100644 --- a/ovn-sb.xml +++ b/ovn-sb.xml @@ -3266,6 +3266,21 @@ tcp.flags = RST; useful in live migration scenarios, for port mirroring, etc. + + If set and used with , + specifies an activation strategy for the additional chassis. By + default, no activation strategy is used, meaning the additional port + location is immediately available for use. When set to "rarp", the + port is blocked for ingress and egress communication until a RARP + packet is sent from the new location. The "rarp" strategy is useful + in live migration scenarios for virtual machines. + + + + When is set, this option indicates + that the port was activated using the strategy specified. + + If set, this port will be bound by ovn-controller only if this same key and value is configured in the diff --git a/tests/ovn.at b/tests/ovn.at index 1ccec492d..2f77dc42f 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14383,6 +14383,166 @@ OVN_CLEANUP([hv1],[hv2],[hv3]) AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD([ +AT_SETUP([options:activation-strategy for logical port]) +ovn_start + +net_add n1 + +sim_add hv1 +as hv1 +check ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.11 + +sim_add hv2 +as hv2 +check ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.12 + +sim_add hv3 +as hv3 +check ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.13 + +# Disable local ARP responder to pass ARP requests through tunnels +check ovn-nbctl ls-add ls0 -- add Logical_Switch ls0 other_config vlan-passthru=true + +check ovn-nbctl lsp-add ls0 migrator +check ovn-nbctl lsp-set-options migrator requested-chassis=hv1 \ + requested-additional-chassis=hv2 \ + activation-strategy=rarp + +check ovn-nbctl lsp-add ls0 outside +check ovn-nbctl lsp-set-options outside requested-chassis=hv3 + +check ovn-nbctl lsp-set-addresses migrator "00:00:00:00:00:01 10.0.0.1" +check ovn-nbctl lsp-set-addresses outside "00:00:00:00:00:02 10.0.0.2" + +for hv in hv1 hv2; do + as $hv check ovs-vsctl -- add-port br-int migrator -- \ + set Interface migrator external-ids:iface-id=migrator \ + options:tx_pcap=$hv/migrator-tx.pcap \ + options:rxq_pcap=$hv/migrator-rx.pcap +done +as hv3 check ovs-vsctl -- add-port br-int outside -- \ + set Interface outside external-ids:iface-id=outside + +wait_row_count Chassis 1 name=hv1 +wait_row_count Chassis 1 name=hv2 +hv1_uuid=$(fetch_column Chassis _uuid name=hv1) +hv2_uuid=$(fetch_column Chassis _uuid name=hv2) + +wait_column "$hv1_uuid" Port_Binding chassis logical_port=migrator +wait_column "$hv1_uuid" Port_Binding requested_chassis logical_port=migrator +wait_column "$hv2_uuid" Port_Binding additional_chassis logical_port=migrator +wait_column "$hv2_uuid" Port_Binding requested_additional_chassis logical_port=migrator + +OVN_POPULATE_ARP + +send_arp() { + local hv=$1 inport=$2 eth_src=$3 eth_dst=$4 spa=$5 tpa=$6 + local request=${eth_dst}${eth_src}08060001080006040001${eth_src}${spa}${eth_dst}${tpa} + as ${hv} ovs-appctl netdev-dummy/receive $inport $request + echo "${request}" +} + +send_rarp() { + local hv=$1 inport=$2 eth_src=$3 eth_dst=$4 spa=$5 tpa=$6 + local request=${eth_dst}${eth_src}80350001080006040001${eth_src}${spa}${eth_dst}${tpa} + as ${hv} ovs-appctl netdev-dummy/receive $inport $request +} + +reset_pcap_file() { + local hv=$1 + local iface=$2 + local pcap_file=$3 + as $hv check ovs-vsctl -- set Interface $iface options:tx_pcap=dummy-tx.pcap \ + options:rxq_pcap=dummy-rx.pcap + check rm -f ${pcap_file}*.pcap + as $hv check ovs-vsctl -- set Interface $iface options:tx_pcap=${pcap_file}-tx.pcap \ + options:rxq_pcap=${pcap_file}-rx.pcap +} + +reset_env() { + reset_pcap_file hv1 migrator hv1/migrator + reset_pcap_file hv2 migrator hv2/migrator + reset_pcap_file hv3 outside hv3/outside + + for port in hv1/migrator hv2/migrator hv3/outside; do + : > $port.expected + done +} + +check_packets() { + OVN_CHECK_PACKETS([hv1/migrator-tx.pcap], [hv1/migrator.expected]) + OVN_CHECK_PACKETS([hv2/migrator-tx.pcap], [hv2/migrator.expected]) + OVN_CHECK_PACKETS([hv3/outside-tx.pcap], [hv3/outside.expected]) +} + +migrator_spa=$(ip_to_hex 10 0 0 1) +outside_spa=$(ip_to_hex 10 0 0 2) + +reset_env + +# Packet from hv3:Outside arrives to hv1:Migrator +# hv3:Outside cannot reach hv2:Migrator because it is blocked by RARP strategy +request=$(send_arp hv3 outside 000000000002 000000000001 $outside_spa $migrator_spa) +echo $request >> hv1/migrator.expected + +check_packets +reset_env + +# Packet from hv1:Migrator arrives to hv3:Outside +request=$(send_arp hv1 migrator 000000000001 000000000002 $migrator_spa $outside_spa) +echo $request >> hv3/outside.expected + +check_packets +reset_env + +# hv2:Migrator cannot reach to hv3:Outside because it is blocked by RARP strategy +request=$(send_arp hv2 migrator 000000000001 000000000002 $migrator_spa $outside_spa) + +check_packets +reset_env + +# Now activate hv2:Migrator location +send_rarp hv2 migrator 000000000001 ffffffffffff $migrator_spa $migrator_spa +reset_env + +pb_uuid=$(ovn-sbctl --bare --columns _uuid find Port_Binding logical_port=migrator) +ovn-sbctl get port_binding $pb_uuid options:additional-chassis-activated +OVS_WAIT_UNTIL([test xtrue = x$(ovn-sbctl get port_binding $pb_uuid options:additional-chassis-activated | tr -d '""')]) + +# Now packet arrives to both locations +request=$(send_arp hv3 outside 000000000002 000000000001 $outside_spa $migrator_spa) +echo $request >> hv1/migrator.expected +echo $request >> hv2/migrator.expected + +check_packets +reset_env + +# Packet from hv1:Migrator still arrives to hv3:Outside +request=$(send_arp hv1 migrator 000000000001 000000000002 $migrator_spa $outside_spa) +echo $request >> hv3/outside.expected + +check_packets +reset_env + +# hv2:Migrator can now reach to hv3:Outside because RARP strategy activated it +request=$(send_arp hv2 migrator 000000000001 000000000002 $migrator_spa $outside_spa) +echo $request >> hv3/outside.expected + +check_packets + +# complete port migration and check that -activated flag is reset +check ovn-nbctl lsp-set-options migrator requested-chassis=hv2 +OVS_WAIT_UNTIL([test x = x$(ovn-sbctl get port_binding $pb_uuid options:additional-chassis-activated)]) + +OVN_CLEANUP([hv1],[hv2]) + +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD([ AT_SETUP([options:requested-chassis for logical port]) ovn_start diff --git a/utilities/ovn-trace.c b/utilities/ovn-trace.c index 0795913d3..097d8c9bb 100644 --- a/utilities/ovn-trace.c +++ b/utilities/ovn-trace.c @@ -2811,6 +2811,9 @@ trace_actions(const struct ovnact *ovnacts, size_t ovnacts_len, /* Nothing to do for tracing. */ break; + case OVNACT_ACTIVATION_STRATEGY_RARP: + break; + case OVNACT_GET_FDB: execute_get_fdb(ovnact_get_GET_FDB(a), dp, uflow); break;