From patchwork Thu Feb 17 15:16:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594316 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=Zk6L4DRX; 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 4Jzz331MgHz9sFk for ; Fri, 18 Feb 2022 02:17:35 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 1AB2D41547; Thu, 17 Feb 2022 15:17:33 +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 eEHt6whCwPim; Thu, 17 Feb 2022 15:17:31 +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 1C19041BF7; Thu, 17 Feb 2022 15:17:30 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5BB5CC0072; Thu, 17 Feb 2022 15:17:28 +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 B9554C000B for ; Thu, 17 Feb 2022 15:17:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9A4ED41832 for ; Thu, 17 Feb 2022 15:17:26 +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 Tkg_oeigiKTf for ; Thu, 17 Feb 2022 15:17:26 +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 C1D9B41547 for ; Thu, 17 Feb 2022 15:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111044; 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=Zk6L4DRXE+1BQgjUEfd9icZvJSluRQGGOXOmntRjV+YcN08zcTXwa2B8v8b8HKvI86AMOe 63BBhhyfWzgNpuXIoxwVuwKWVdxvmsEigMLIlTNmj1pydzfaaVV3NGa0ZHDDfuODtVvb3+ SMtUoHzuSIqP14NxBne+IldzL6fhy8g= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-321-9JUZcsmZOGuMKfUiXV0v-A-1; Thu, 17 Feb 2022 10:17:23 -0500 X-MC-Unique: 9JUZcsmZOGuMKfUiXV0v-A-1 Received: by mail-qk1-f199.google.com with SMTP id i26-20020a05620a075a00b0047ec29823c0so4431043qki.6 for ; Thu, 17 Feb 2022 07:17:23 -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=Gdvl9CLXqYkv+oTID0WrED9XiRFhM1e6bxEYMTu8HODpPYa76jGfuoL6iJXUC6R1wM IFUxw5ilGrpU6Rlt4h5CgBOwkz8JCgnAcR9BjkqLOI7tg4jkwZbPZBneccCO4J+iMO5j xxcrD2Z7LyEX0WbBAhEG0q+7sK3NofzNuP9l8OxmWsXkqIshp4epey8Rbykkjsw1qgj7 FVhZwDTOIcAYe8x2FyxO9I39za6Jvp3+fL4b4GFXr7poqzd/eMye9vlXnCeUxTCJjt8g A/k6W+0jVW3c7YyFTgd90scDJE830QVInVy/Qq70DS4ZHzMxt1bnjvKyoQMBfjFFr9W5 RB0w== X-Gm-Message-State: AOAM532EeqMm+i/iL/LBweIbMD+440OhqI+vMubL+nyVmF+ldWiQAXP+ E4xOykZLh8TjGqjM5qx2A+ZbZOKoQ2LgWLYMEChhm1eyOs2VPN6QYdMDW/PsjCr/EK+FMZ7PrXa Yx0VIO7gMlkEtDLr+9bx7735GBNE79Vv6YfawB1mPh8tv1PG9uojq8Rl8so0G5UcY X-Received: by 2002:a05:620a:4727:b0:47e:2c07:efdf with SMTP id bs39-20020a05620a472700b0047e2c07efdfmr1867585qkb.399.1645111042910; Thu, 17 Feb 2022 07:17:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXd+B8Hhn2fXBqk3lXFETcg5M+Jmd2h4P7dUYww0GXwUwJlEC/IWIyZx3ouQUarlpOdDGgmQ== X-Received: by 2002:a05:620a:4727:b0:47e:2c07:efdf with SMTP id bs39-20020a05620a472700b0047e2c07efdfmr1867564qkb.399.1645111042615; Thu, 17 Feb 2022 07:17:22 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:22 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:16:57 +0000 Message-Id: <20220217151712.2292329-2-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 01/16] 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 Thu Feb 17 15:16:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594317 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=gnHEgChI; 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 4Jzz3430hWz9sFk for ; Fri, 18 Feb 2022 02:17:36 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 4C4486F740; Thu, 17 Feb 2022 15:17:34 +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 3mMPjrPCUI85; Thu, 17 Feb 2022 15:17:33 +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 DB19F6F734; Thu, 17 Feb 2022 15:17:31 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C5243C0070; Thu, 17 Feb 2022 15:17:30 +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 677F3C0079 for ; Thu, 17 Feb 2022 15:17:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 45CA983EC1 for ; Thu, 17 Feb 2022 15:17:28 +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 IJLj6Wo5XbqH for ; Thu, 17 Feb 2022 15:17:27 +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 9FEE583EBA for ; Thu, 17 Feb 2022 15:17:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111046; 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=gnHEgChIdigIfaOlk2iWrUinuTazppYUCVZs0wJvDVrliwVMVZuW57Eadm7SXUXI51Obnf yqOYHUZLmhCnYBnSU8CGX3e7qeDZQwQi8pyy8J/EbWPZUJT4fCeo4dUIMGqUoKHJhmbr6Y ZekCw7zHZH5jaj+fbQUWW+uQwRBWawA= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-624-nxHxsHSsP3iZYvUlTCSUmQ-1; Thu, 17 Feb 2022 10:17:25 -0500 X-MC-Unique: nxHxsHSsP3iZYvUlTCSUmQ-1 Received: by mail-qk1-f197.google.com with SMTP id t10-20020a37aa0a000000b00605b9764f71so4394292qke.22 for ; Thu, 17 Feb 2022 07:17:25 -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=qGRJhnrGNU3JFMFyc4svRjFSyJd0Z9HoFA3EBjxY6faSp95qvYNflLNKc9dbojWDYy JoNXbtxHGyCz1QivfBNtZkOjniX7i7AkTW2RU0g58GDRmbQoWvbUiUdr4M7cQOBYVlJg PFq4gn4HY5/78XxudIiCKZc0Du3ULjLYRNODCiEq9EQQjYl+qQSP5iFKP7vegiQNiXMH rrC5FLfhntkm9tu0Xdl+NO46occ2Ed0ZD/BXCXIWKeYRrmSjfWCZtiAcGCqxhxxRt9V/ rBho1ZKmH4fIgtU0BwPtq3zUWuatxMUD3LsmfgUwbVH5pOXnaviijMRmu+hpwvgelNze sjRw== X-Gm-Message-State: AOAM531t68gT2ELFfaUL/a1hLI2A8v8yGX0QGZSjPyf7F24dH0sBHtTy 4v2c0U5IUnlaRujqxIbvfB4ZvRagKHkL5vM9mdD29CBswokrBIFYK8PQZ/L+XvnqwTuwDgT+Sc5 p8awH94rQk4CPp8BUnwjy4Rx5jfXHn4kvfP4NR/MSHKk7zpWCzqvXXFx7u7cuVRMY X-Received: by 2002:a05:620a:4622:b0:5f1:8f9d:3684 with SMTP id br34-20020a05620a462200b005f18f9d3684mr1799391qkb.401.1645111044449; Thu, 17 Feb 2022 07:17:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0lk5zRN3onVwXDQOAdWrXqAUXkuP+v1VYVnUt5XgEikmpWsKbjrpO5SJG7brXCkjProl6GQ== X-Received: by 2002:a05:620a:4622:b0:5f1:8f9d:3684 with SMTP id br34-20020a05620a462200b005f18f9d3684mr1799366qkb.401.1645111044160; Thu, 17 Feb 2022 07:17:24 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:23 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:16:58 +0000 Message-Id: <20220217151712.2292329-3-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 02/16] 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 Thu Feb 17 15:16:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594318 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=FcsWHkvj; 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 4Jzz370KGpz9sFk for ; Fri, 18 Feb 2022 02:17:38 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 32E7A41E5C; Thu, 17 Feb 2022 15:17:36 +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 PPvpZY80XYzZ; Thu, 17 Feb 2022 15:17:34 +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 5782D41E8C; Thu, 17 Feb 2022 15:17:33 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 18468C0079; Thu, 17 Feb 2022 15:17:33 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id D9E8EC0081 for ; Thu, 17 Feb 2022 15:17:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C822A41BEF for ; Thu, 17 Feb 2022 15:17:29 +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 vSa4Kp9Rv9ta for ; Thu, 17 Feb 2022 15:17:29 +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 221D441BC3 for ; Thu, 17 Feb 2022 15:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111048; 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=FcsWHkvjxElf/3Y6Au5bJJGHALXSTXK4Fa22PH3sPjSy5loKS+yriboTGi/x6Ny7hZCLGE cb1Ervpa3z8ZDZsKt5SglwimYMMwmMNaAfkmwqOWGH0tSt5jWfBlbHBIXaqoC8ybHB3nsW zwUf+Bh/4g5qg02lqovrVkLBwj/J7M8= 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-618-yLZDXXmtPySRv8485mG6Pw-1; Thu, 17 Feb 2022 10:17:27 -0500 X-MC-Unique: yLZDXXmtPySRv8485mG6Pw-1 Received: by mail-qv1-f70.google.com with SMTP id cg14-20020a05621413ce00b0042c2706a4beso5559378qvb.23 for ; Thu, 17 Feb 2022 07:17:27 -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=tQwoerclgWGrz+009344Wg+HzSqfTildnJ1sKEhhsNSPUQMpwhq2o6ki11vksELX3a cPLxLYjBHR1HaYQAowbXS4Z8Ivv8tXbthPNJ0k7BbHYI8yc03ENzwmEx0ROArlLKMo2t e5WWhFON6bM98APESnOi3RIzyyfqiTdYqSkiDoo+n9Tx3zZpVz8eOERmcXjxSIBrdmK6 cJNIPnQhIMHqUr/2o2UB5K35eMhAfq1FnRZ2lCnqTsjuilwAee6b+esDs7tXZnv4dNl9 YGDE3cgMHfLyaqD3zW9EZZmYkKt0NyIFfULOgWzcxYfusN/YeuDu68lQX4e/cUzGOhkN DbfA== X-Gm-Message-State: AOAM5316PUY+IZoyIvtEhWt1KpJOPFvWBW+wTdvC9PMfMJdXNEk+vk4F BtZ6vTKhKP/2zxaB89QVQ4/2h6MjZ/KtQlKU+FbBt9WunSQyX+wGRtdcgYhmVZXf1ifhKYkT29u BVezp9I8it9CA6FSwuj6V0tQQue+xqM1seUWRGJBGDdcWQrfKveMKr7C3mTzoB2eW X-Received: by 2002:ac8:5bc2:0:b0:2cd:7962:1cf3 with SMTP id b2-20020ac85bc2000000b002cd79621cf3mr2764979qtb.581.1645111046092; Thu, 17 Feb 2022 07:17:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdR18+3iXl2XBkqY7QIsOy2UfRPDdt6tLX2SlfwlrB0Grt+yibT42Q0qD8pQiVORLKLT7dZQ== X-Received: by 2002:ac8:5bc2:0:b0:2cd:7962:1cf3 with SMTP id b2-20020ac85bc2000000b002cd79621cf3mr2764946qtb.581.1645111045808; Thu, 17 Feb 2022 07:17:25 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:24 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:16:59 +0000 Message-Id: <20220217151712.2292329-4-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 03/16] 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 Thu Feb 17 15:17:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594319 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=MYFgcHmj; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jzz381KDYz9sFk for ; Fri, 18 Feb 2022 02:17:40 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BB01641C30; Thu, 17 Feb 2022 15:17:37 +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 1DNW0lwo6DgZ; Thu, 17 Feb 2022 15:17:36 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 3EE664258F; Thu, 17 Feb 2022 15:17:35 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 64F5FC007E; Thu, 17 Feb 2022 15:17:34 +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 5D1B9C0072 for ; Thu, 17 Feb 2022 15:17:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 4BD8D61C50 for ; Thu, 17 Feb 2022 15:17:31 +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 WFh04_Osxcia for ; Thu, 17 Feb 2022 15:17:30 +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 smtp3.osuosl.org (Postfix) with ESMTPS id A206E6F727 for ; Thu, 17 Feb 2022 15:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111049; 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=MYFgcHmj2TEcj/KBS+PB4VDA9Cf2AaI+kL7ZVzOpBECljdFnYEX/MkQ0NVRI4MH1uAy4/x NcIVTHMvHWpxpd3ctF8iw39xhd3ay0dy5QjLvME8o1OMt7fke5TOViJIouBD0nvnoXCbP5 aKZRkJgoxE7nKlsAuI4+KZi+H9qtntc= 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-674-vKfQz1_OPSSyBTmmnYAGvg-1; Thu, 17 Feb 2022 10:17:28 -0500 X-MC-Unique: vKfQz1_OPSSyBTmmnYAGvg-1 Received: by mail-qv1-f71.google.com with SMTP id kl13-20020a056214518d00b0042cb237f86bso5687258qvb.0 for ; Thu, 17 Feb 2022 07:17:28 -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=QiXqBXoR75udPg9wj7rPV3qRdZtFab4z7KOaDMO0pfPHDiLO6CEu5kdEVXOh+eNQUr T0Ca5IK9ddk0EzytOrw4sbQ2DFr7TKBgpOvBaT/4W5mMR6sSVSh7Sdq6nK84LH3icSSm P51XgoywYUqV4oHTBVogCQQwGIHSyqxavEb6NbyDEFRSwMKK4x3AVNzDZKPpFbtgoFhI naDKhe2bo/cW6e5fL+fDeNrboXahtngn8cZivOHVByk6Btg99YJyxoIQGOIdm1cxU51R jaGdhVEGYNX64/SkzRZW5q0RC3N4+P8nI8APOeOpE2dhNRQi0nOpiiJiMRtUQINYEGYA Uwmg== X-Gm-Message-State: AOAM530YlWsv52Tay/RTco9Jh57Nmko1SSk/jZmEZuOA+nhcts5UoLMN EohCLPxofP/6cjDZqS61+Bbe9UmNidYFOneMN7fwifj1OoUAGdC7il8DQYMht0AaOYxwiRxPDPr k4h5hj9JwJa4GXKLibWZs3velEmHmU0BQHF8dH7NZxdHR7B/NkuYQEcDiQL9sjEC+ X-Received: by 2002:a05:620a:1912:b0:4e0:edfe:bf82 with SMTP id bj18-20020a05620a191200b004e0edfebf82mr1853867qkb.339.1645111047675; Thu, 17 Feb 2022 07:17:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJ0cmsqZdwAuDgSUqEgsASapjlEXdULswMFsQCKuH6/Bn0BIbHJcUXUZUCSclXaFGixlzb5w== X-Received: by 2002:a05:620a:1912:b0:4e0:edfe:bf82 with SMTP id bj18-20020a05620a191200b004e0edfebf82mr1853834qkb.339.1645111047366; Thu, 17 Feb 2022 07:17:27 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:26 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:00 +0000 Message-Id: <20220217151712.2292329-5-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 04/16] 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 Thu Feb 17 15:17:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594321 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=eUU3diBN; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jzz3D16tNz9sFw for ; Fri, 18 Feb 2022 02:17:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A82D7425B8; Thu, 17 Feb 2022 15:17:39 +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 loVIgm_aT07A; Thu, 17 Feb 2022 15:17:38 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id E056E4259B; Thu, 17 Feb 2022 15:17:36 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 37C8EC0079; Thu, 17 Feb 2022 15:17:36 +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 1AE3CC0079 for ; Thu, 17 Feb 2022 15:17:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 2957741E9B for ; Thu, 17 Feb 2022 15:17:34 +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 8qlpEiC1zuiu for ; Thu, 17 Feb 2022 15:17:32 +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 9E27C41E5B for ; Thu, 17 Feb 2022 15:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111051; 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=eUU3diBNPgI/cBo3gJza/AjHOn2mFA8cZoFBwShX9tAnitP2restLLQ1mgeakS8zaZ5ORy 76h2vasl592D8eE8FUWpAQfmhfvZprZxEuT+kfIWveSwEb+udBRHhn4zp8AsnwTWxhFtjJ nf6cBdpGbMA55k16OK68Grz5PJ1hz+g= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-gTEEtr7XMDaUFNG7eRbBbw-1; Thu, 17 Feb 2022 10:17:30 -0500 X-MC-Unique: gTEEtr7XMDaUFNG7eRbBbw-1 Received: by mail-qk1-f198.google.com with SMTP id z1-20020ae9f441000000b00507a22b2d00so4420034qkl.8 for ; Thu, 17 Feb 2022 07:17:30 -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=wHYSYB1hFeF5G/Gwo7XpxqaEonkqRTCG8PUBdJl4o3YhQUHWAMSQjpsIN4Dy92WKVC LqbmI7LgpiEzn6CQamcJ+m9d18v8d9gjS2FvZ560NJQJx/04tFOoLrbtCu1aykYNZMg0 hA1SmK9rKp8yIj+cU0i4fY/sGUWxE1ZNgiSXOCGd6AqBq8tqweFDBm/37UmRKbTliG9v XT7QGmTpxT27tqQjv0M/ul4TjkQrZrVtKsZtBsV++mPeLn46nVJRjp0bG6W3NcnXTYEZ w7A5732u/qkLF1trxZpBHD7UZQ78RLQZAbx5qH24m8sXOCJDpmXnPLr3CMxFMGSaw00C SWEQ== X-Gm-Message-State: AOAM532wRreK1yv0eqxmbUEflfKN3WPzCJbWJMj6GaE2QiRzib83OPhg nVYrj14hx4IvA+GkgFaab3lox0TFnJrkjbJ9ObLV74+mc/xQbssyKLgi0VG3eNUUgDBUMnV/CjL 37wKUwEJEqiZ31TSNTzHftAMJW22an4alWA9Y9mA0pB6EpXMdraGQkrrtgxe3QP5q X-Received: by 2002:a05:622a:608:b0:2c5:fa98:9325 with SMTP id z8-20020a05622a060800b002c5fa989325mr2844981qta.393.1645111049430; Thu, 17 Feb 2022 07:17:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFSZlJ9n0x2NW1r9l2V9kmvmcJeeFgF9s3kY+SscBnoqNYJcbdZexMEI4dv1A9xfJtTZmlhg== X-Received: by 2002:a05:622a:608:b0:2c5:fa98:9325 with SMTP id z8-20020a05622a060800b002c5fa989325mr2844952qta.393.1645111049123; Thu, 17 Feb 2022 07:17:29 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:28 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:01 +0000 Message-Id: <20220217151712.2292329-6-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 05/16] 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 Thu Feb 17 15:17:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594320 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=g7BkQIOT; 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 4Jzz3C5njgz9sFk for ; Fri, 18 Feb 2022 02:17:43 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id C49D96F731; Thu, 17 Feb 2022 15:17:41 +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 DzjR_nVQ4oxy; Thu, 17 Feb 2022 15:17:40 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 6BF066F747; Thu, 17 Feb 2022 15:17:39 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2C6EEC007A; Thu, 17 Feb 2022 15:17:39 +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 03BEFC0039 for ; Thu, 17 Feb 2022 15:17:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 696B241E7E for ; Thu, 17 Feb 2022 15:17:35 +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 z4zm4vOu_NpW for ; Thu, 17 Feb 2022 15:17:34 +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 D42F941E8E for ; Thu, 17 Feb 2022 15:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111052; 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=g7BkQIOTbEwrBgXT5qnMDJd55jQ9Gw3dGaf5LBtN2NkDYsMiiHWwnsTobGZOxItkIBPe0B kC5ejhR3FKpANItzY1uLTK5asPLtz6dXeLz33oHfz2SP0Yxp+Oj6nOCuIdOOjQJn7c0gcs /1OLQxdcmzuH0ydLJaTBDAA8FwqKyRQ= 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-342-AD45zE9-N0i8uitDTLeEsg-1; Thu, 17 Feb 2022 10:17:31 -0500 X-MC-Unique: AD45zE9-N0i8uitDTLeEsg-1 Received: by mail-qv1-f69.google.com with SMTP id g2-20020a0562141cc200b004123b0abe18so5640847qvd.2 for ; Thu, 17 Feb 2022 07:17:31 -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=GRWz2U8l7a8iywEwTjoQAkkpeKKnOUVs+N0DfGFGpQubLOLJmhXeq18Mh7NpNj0zR+ GlD0n84n0GmKMygXvfzSTZky9Ma2nZqcJ+EMYUTgRikBexkx4Sowjr7lKeNoFO6peJVX Mgzs9OtGw4pYoPJzm/smPP7BMz9DyWb4wGonaoBOof4tIE25ka1BPdFv7qj6svPNSHee Vwlntkvvs5WWAgFL2m7b4qgYe6inMZcLvXT6JF3C7i9Z/dI5XWrIHdzDxuWUKHT6cjrC gk6BgW8hN5lmaPiQr+NyOj5QDohtk+6Jsk5XlAxK3GYlCAFbyCFRNlL3nFXdMu8hm7/H UT0g== X-Gm-Message-State: AOAM530RTsRNQFOJ+qtZb/XefV+ygLK6tnT22NiOFQFeQdLeTm7487yi Inv5nPoVUfrbjkYxQT5+ZhW84RXhYACG6zijaPfZC6NxyL/Ap+Z25fB0FJ76dpEzNBI9KRfzw4B 0tMBtwfZkwji51Dj2etKQdr/GJn6Tma1RWdJ5RCxmLz4TgF0N+YH3UoM9Ttu7ggiN X-Received: by 2002:ac8:7f88:0:b0:2d4:be34:a302 with SMTP id z8-20020ac87f88000000b002d4be34a302mr2739359qtj.263.1645111050845; Thu, 17 Feb 2022 07:17:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPGweS06W4Kf93pIsidYro0x6OunOcxKVcLzMq3ZsumT3o4OlMRTkprUW/zxksQLQzaiNRog== X-Received: by 2002:ac8:7f88:0:b0:2d4:be34:a302 with SMTP id z8-20020ac87f88000000b002d4be34a302mr2739330qtj.263.1645111050581; Thu, 17 Feb 2022 07:17:30 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:29 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:02 +0000 Message-Id: <20220217151712.2292329-7-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 06/16] 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 Thu Feb 17 15:17:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594322 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=L1iJEZYO; 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 4Jzz3M4YCvz9sFw for ; Fri, 18 Feb 2022 02:17:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8EC446F7C7; Thu, 17 Feb 2022 15:17:49 +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 PxxwjAK9JX1o; Thu, 17 Feb 2022 15:17:46 +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 954DA6F790; Thu, 17 Feb 2022 15:17:44 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 744F9C0021; Thu, 17 Feb 2022 15:17:44 +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 2AF7CC0031 for ; Thu, 17 Feb 2022 15:17:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 424446F73B for ; Thu, 17 Feb 2022 15:17:37 +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 wl9-810fd-ny for ; Thu, 17 Feb 2022 15:17:36 +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 smtp3.osuosl.org (Postfix) with ESMTPS id 0AE5D6F73A for ; Thu, 17 Feb 2022 15:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111055; 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=L1iJEZYOGk5B8gDO/WS60UUyX3/Tpn+b65SIpOAnhex3i1Px3Xi8cWTFqhrU6Fsei95JKs ObiyAuI8UHj3xwfsvf7BXh9Rw6BnJfIDM+UEVkEo2mCjecDzYflg5ybP5Om01AZ3yBNRve VNfs1lG1Nsp3xgrExwFx2EGgjONRGzo= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-402-k3vRjbXjMrKErL4yzEAA4w-1; Thu, 17 Feb 2022 10:17:33 -0500 X-MC-Unique: k3vRjbXjMrKErL4yzEAA4w-1 Received: by mail-qk1-f199.google.com with SMTP id t17-20020a05620a035100b0060df15e2977so485853qkm.21 for ; Thu, 17 Feb 2022 07:17:33 -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=DahHgzHca6tizwMD4ybbcnEfjVDZgaTaEY6A/NxgjRrlP/99jOy5ouo5JimzTyWjQd wkNGMQGxe24m8jYHg9yOJAn5/EKNxGW8aO8zjhSqoIvHm9TnO6PbOPwloE5yeIMn/xTC ko/tpLTzs/6RWjqyulbKrOYWbNJX0302HHVdZEmHpFNVKtjLc3O2H6aU+ROrGWVlb4Il 5fCx53BW+7qkSDHnjYx8xihfL+ARJXyyUnIMafrZP31O0vKNmQ+VW9y5vG1w23m0ddC5 GUwkgvBlRK4wC9mT8cnOwhDdaRmLHq6n1M6w5Pddu7hbRkQP1V2WyM8IksPz2CwUNYuV 1Qgg== X-Gm-Message-State: AOAM531//wD8f2C1gfAyqGUdyu4ID+uS3sUhzCmTPoyiYfCDXu4BOyMs Y6dxNTlYGK7Ggq+vCY6wwsEYxuktcv1kAdPQQO9UoR9GmIEWBwlm9KRXcGJjtNPyDz0rx3fWjY8 BO5g9ZkoKM1cC+JKBBbaBv8wBvAhjVRTTjR+xDtYLFo9E7tSrIFjpuev3LpKnnRbN X-Received: by 2002:a05:622a:100a:b0:2ca:f688:4ecb with SMTP id d10-20020a05622a100a00b002caf6884ecbmr2792349qte.377.1645111052832; Thu, 17 Feb 2022 07:17:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwP+PWBlU1+4ZQgNkU7emL7+0knQSKeXq2GxSH0RgKU4ghjXvPz8p7siQuCw2Khf6ilMIwB1g== X-Received: by 2002:a05:622a:100a:b0:2ca:f688:4ecb with SMTP id d10-20020a05622a100a00b002caf6884ecbmr2792313qte.377.1645111052423; Thu, 17 Feb 2022 07:17:32 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:31 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:03 +0000 Message-Id: <20220217151712.2292329-8-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 07/16] 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 Thu Feb 17 15:17:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594323 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=fFU0gXeb; 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 4Jzz3T6S7dz9sFk for ; Fri, 18 Feb 2022 02:17:57 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0680A6F79C; Thu, 17 Feb 2022 15:17:56 +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 pXSsRDhX9zN5; Thu, 17 Feb 2022 15:17:54 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 3FA7F6F7D0; Thu, 17 Feb 2022 15:17:51 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1CB7EC0070; Thu, 17 Feb 2022 15:17: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 13492C0031 for ; Thu, 17 Feb 2022 15:17:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E979041E6E for ; Thu, 17 Feb 2022 15:17:40 +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 O7I28kLfOm6T for ; Thu, 17 Feb 2022 15:17:37 +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 890A141EB9 for ; Thu, 17 Feb 2022 15:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111056; 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=3i+AT+yuqe7mLhow8gzK7QZWtyhH3uRp8X73cpIjJeQ=; b=fFU0gXebcrUX/sCmkV7V8PA7bcWkHlSt8I7h32zs8yz3F5inzNwa2gnr8pbIuUfXS9oTQ6 nE478w9fueFMtBCII/jfOYp7red7LZ3mZgv349QCn8zodgbnCh2fWE+50/k8MVjATUcD1G bEP5PLkXAWfVix0yR/a7FhzWhzCycs4= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-178-lXw1y7-uOTCeLT5AEQIBow-1; Thu, 17 Feb 2022 10:17:35 -0500 X-MC-Unique: lXw1y7-uOTCeLT5AEQIBow-1 Received: by mail-qk1-f199.google.com with SMTP id t17-20020a05620a035100b0060df15e2977so485934qkm.21 for ; Thu, 17 Feb 2022 07:17:35 -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=3i+AT+yuqe7mLhow8gzK7QZWtyhH3uRp8X73cpIjJeQ=; b=WwY4adN0brapJvVmWGfLNGdrIxpZE5SUfZR1UM89YgJJZjUH3fK1hDG0TDW0gpeldr hVIFxjY09484ycyAlrW5+TwLJ0rY+HT/uDPSd4MV4YpsLd7oYmB6LCVoCYKxZy8TjquG wcWFo2MEqNqWN/GQGsn4SS3ITqtHS2GOvSRsXmmvvWl8oYXXYL44a9+GgPwg6f1Bzj29 QJBiCLlIiCgIzg/pgWuwR92+7XrVypbBp1+RxlSnm66gSfidoevq37HW3J/aqiRoGzI2 K4ParOuUhrnsWty4om9i5YWDRbX2N94XuJeODJ6BIP3wiBD2AgZITR0l30gV+oaZepE/ gJ/Q== X-Gm-Message-State: AOAM531a9m5o0yUeofOwGDEG2Wl8lG08fTvABPGPxiO6WzG0iIwtPcBT /xbv/qsQ1DYGw+6k/WjGgGeaM1K7nTuk7fxhOkeaO+8xYwIwxW3YjHyMRKjPxv5qg0HqV5aiRwl VihDQy2S+Eclkjf9QrJ7J6E3Ak5f8tTzdoNDlNLb2WGEfwnIXAlm+5Yuh350bKuqK X-Received: by 2002:a05:620a:346:b0:60d:d6f3:baa5 with SMTP id t6-20020a05620a034600b0060dd6f3baa5mr1779828qkm.419.1645111054363; Thu, 17 Feb 2022 07:17:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvEJnF/MfpNrfRo4OhL7zBKcSZ74YxxfFiGX7u4ZOWbIuZiidzwKu4uhb9IiNVv9860uPH6A== X-Received: by 2002:a05:620a:346:b0:60d:d6f3:baa5 with SMTP id t6-20020a05620a034600b0060dd6f3baa5mr1779808qkm.419.1645111054053; Thu, 17 Feb 2022 07:17:34 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:33 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:04 +0000 Message-Id: <20220217151712.2292329-9-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 08/16] 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 | 50 ++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index e0afd83ab..dea7dc1c2 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); @@ -843,17 +849,7 @@ load_logical_ingress_metadata(const struct sbrec_port_binding *binding, 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); - } - } + put_zones_ofpacts(zone_ids, ofpacts_p); /* Set MFF_LOG_DATAPATH and MFF_LOG_INPORT. */ uint32_t dp_key = binding->datapath->tunnel_key; @@ -995,15 +991,7 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, struct zone_ids zone_ids = get_zone_ids(distributed_binding, ct_zones); - 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 Thu Feb 17 15:17:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594324 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=EFqQGkZi; 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 4Jzz3b2WQxz9sFk for ; Fri, 18 Feb 2022 02:18:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id A911783F80; Thu, 17 Feb 2022 15:18:00 +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 TS9zxDP7GJtF; Thu, 17 Feb 2022 15:17:59 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 369F183FA8; Thu, 17 Feb 2022 15:17:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0E9A5C0021; Thu, 17 Feb 2022 15:17:57 +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 372FEC000B for ; Thu, 17 Feb 2022 15:17:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CCCDE425C3 for ; Thu, 17 Feb 2022 15:17:40 +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 uIHwh0KQHTA2 for ; Thu, 17 Feb 2022 15:17:39 +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 616F2425B3 for ; Thu, 17 Feb 2022 15:17:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111058; 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=ITK/hPaqXRbOCii2PXbQymECDPqsbpxUGOSWAVO+8lk=; b=EFqQGkZiVREXHX9O4A2ANjxpOLi1p34dO0lpctAKRE+4l6cZvhPS+nK++12eisYpD3kIPs JtlwzWPc4+U0lqemroRFqIa7ityp9h014E9NEzHF19nsTf3CdNpV5uz3vsUzvHaOEalb4j 7g/BCo7X0im5sTzLXqIPbHJP7sgSzVs= 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-304-S1iSsRnNP9u1r8CJH3fVmA-1; Thu, 17 Feb 2022 10:17:36 -0500 X-MC-Unique: S1iSsRnNP9u1r8CJH3fVmA-1 Received: by mail-qv1-f72.google.com with SMTP id e9-20020a0cf749000000b0042bf697ff6bso5616015qvo.5 for ; Thu, 17 Feb 2022 07:17:36 -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=ITK/hPaqXRbOCii2PXbQymECDPqsbpxUGOSWAVO+8lk=; b=NKR3ErEJ48KDrXpPpDTuiUBrBCXtcqivarUb5olh91fMqazaLckm8Z5MUhHq8ODPQc CtC/PyNcCZ62I78BLJvQBr0mRXeE7XuuE+FGgxCS5PADlu5zPaJsUxj6aIKyuDpHLULk j1Ei7Yr/Feg8EZp+is2RoHlemE2llS9a7oUfuxxZDNklokSU6MCPyPp4G4bRHoMxD4kT KRX0FCtAghsvMk1eBOHkwdrglqoaCYvfb0X0l/aUUEClp6ZYyY5boKhdcU4+x92oPE7M lDEfOu4NhWT5PhSu4V8vFpmjPqA6i04kIeuwvJ6TYJ6v43E9TtIYVpj395HJ0dJFeYl+ 8haA== X-Gm-Message-State: AOAM532ZW8JxKOmeoRvY7ESuOqDzxK+/j1/RGVFusZBvK0CINbyavqlX WdteL8ZCE6D4kW8VGZgLhJvLQUHouKjAIVtyHejLC7jt8uP0ISGi09uPBylMkLL9nRitxAgmOUk lquqv964Zdh4mu4S81YjyfW50DIuwk3pPilRC+hKZ8EYgcJSoYW2qLaznQL3pqcVY X-Received: by 2002:a05:622a:107:b0:2c6:b59f:3136 with SMTP id u7-20020a05622a010700b002c6b59f3136mr2786755qtw.357.1645111055827; Thu, 17 Feb 2022 07:17:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxihD18aPNcM8+iHH8zRpKHf4sMGRhMWOcVJQAs2sE1dekwjucLG9rTYkJ+Sm9okFhtqp1j0Q== X-Received: by 2002:a05:622a:107:b0:2c6:b59f:3136 with SMTP id u7-20020a05622a010700b002c6b59f3136mr2786735qtw.357.1645111055551; Thu, 17 Feb 2022 07:17:35 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:34 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:05 +0000 Message-Id: <20220217151712.2292329-10-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 09/16] 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 dea7dc1c2..d28772ed8 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 */ @@ -1079,8 +1076,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 Thu Feb 17 15:17:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594326 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=TnPIi4Qz; 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 4Jzz3p5Smqz9sFk for ; Fri, 18 Feb 2022 02:18:14 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5FE818405D; Thu, 17 Feb 2022 15:18:12 +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 yMnK6PQ-1EKc; Thu, 17 Feb 2022 15:18:11 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 97DF783FA7; Thu, 17 Feb 2022 15:18:10 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 590BCC007C; Thu, 17 Feb 2022 15:18:09 +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 6865AC0070 for ; Thu, 17 Feb 2022 15:18:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 30B0F425D9 for ; Thu, 17 Feb 2022 15:17:43 +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 Y4GU7bSf-hdo for ; Thu, 17 Feb 2022 15:17:41 +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 8C6C7425AD for ; Thu, 17 Feb 2022 15:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111059; 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=3/xuEjptTni5z9onIFdjaphP+PSlIq6Xz7uYihw0Y2U=; b=TnPIi4QzQtxtpOJ8G27xO7DL135vzpKiE9VMrtg4WxsbdFUzhRlXMEqXBg+24Qa5clN9Bd Z4eERUU8KA4N4KIpF1Sv1m3fO+f/rucC+Bn/6Uk1u7hyjyzRgeVNVqHoXQm6n6h0Hr41k9 ceAmN5mRVwXj6BkYkCS7D+9yki9nA+M= 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-655-q83Kc22WP2qnJsAypZPUjw-1; Thu, 17 Feb 2022 10:17:38 -0500 X-MC-Unique: q83Kc22WP2qnJsAypZPUjw-1 Received: by mail-qv1-f70.google.com with SMTP id 3-20020a0562140d0300b0042d7c7ac26aso5617021qvh.7 for ; Thu, 17 Feb 2022 07:17:38 -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=3/xuEjptTni5z9onIFdjaphP+PSlIq6Xz7uYihw0Y2U=; b=Z4vT9BYOtCdAllfshhkN3kDPSUEgjOqiercq5965y/NEMkHaJYaDHI8RZwHwwo0mXQ iMP1a8nlfE/eBGg0zvhwTld5jZbq3vWzog1L8fi3Z1VRXiVMoQLrv0jSyWd09eDsQ5uS FLNfP8eEwgHJW5Uca5y9wHwfswPC2T/vfenssHaEBb0eqzmimI6iPXCA/e9/daJtZMda uBk0CVKxoYdTjtSO+H/ZUFTGFmgnbnXEoTSfeZZzScD9Nzc6nt2H2Zh/QTjr/yK3p9wR 75y5Rj+tf5y8o6f39yMcKK1hY1qidkKIaATDzSZ3SVJ1sxVteKgmEmQIK8RrdmRyKsnr IFKQ== X-Gm-Message-State: AOAM533tPSVqKHu/kgPds8rb+FMlOBS5X5Se+KsOLZGmsDiZaIKG3nJI /B/M+tgD/ckTbMs8FwC/da5e8ONOWPyqhhHfVQC3vK5dooUteJFVpBFaV3d3iUbfDVvB7KJxsLC en6EEBAlupJUSzvsRi2WrVsIsfqfarULq6LlTH38yyj//mnMSdFRhsNQ0iY+4A4ht X-Received: by 2002:a37:4653:0:b0:47b:8670:4abd with SMTP id t80-20020a374653000000b0047b86704abdmr1894499qka.546.1645111057210; Thu, 17 Feb 2022 07:17:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZu062p3sbCeKmOczhfZY/xKSKL/hg7II+dRhtWr13W5s0tpF1BOyOzy4mmkq/J4l/jvrWSA== X-Received: by 2002:a37:4653:0:b0:47b:8670:4abd with SMTP id t80-20020a374653000000b0047b86704abdmr1894478qka.546.1645111056948; Thu, 17 Feb 2022 07:17:36 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:36 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:06 +0000 Message-Id: <20220217151712.2292329-11-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 10/16] 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 d28772ed8..a3eddd100 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -1709,6 +1709,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 Thu Feb 17 15:17:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594325 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=fu2ukSbz; 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 4Jzz3m3Kq2z9sFk for ; Fri, 18 Feb 2022 02:18:12 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D7C1D42035; Thu, 17 Feb 2022 15:18:09 +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 JbVM_UyUm7GU; Thu, 17 Feb 2022 15:18:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 3BDE241E5B; Thu, 17 Feb 2022 15:18:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0E591C0031; Thu, 17 Feb 2022 15:18:07 +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 3576EC0021 for ; Thu, 17 Feb 2022 15:18:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C165083FB7 for ; Thu, 17 Feb 2022 15:17:42 +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 37FrBkKeRBG1 for ; Thu, 17 Feb 2022 15:17:41 +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 853D883FB2 for ; Thu, 17 Feb 2022 15:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111060; 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=fu2ukSbzTWcPPqQMyubZlnGELoBLOFG/VzSJX2nrU13Xg91VZ0KnxttngyN2LgkejGY6BC +FcMvRr7gUv0mBPTXGSn6CbO7I0PyviJyyiNnEd3vDfECj4c7t6/5xXcWYXrAOHH/tI4m/ PcpgAcsAvfPCHdw6P+F7IUvqa+7nOOw= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-470--UNuQT9dNR2OoAHAdc5b3g-1; Thu, 17 Feb 2022 10:17:39 -0500 X-MC-Unique: -UNuQT9dNR2OoAHAdc5b3g-1 Received: by mail-qk1-f197.google.com with SMTP id de36-20020a05620a372400b00508b2c3063eso4423142qkb.12 for ; Thu, 17 Feb 2022 07:17:39 -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=xbVBdpY1F0CagPM8PZirA55y1tix+0kdeH6GMp2CMmnTlckwcSq3eox0JcuiczjZu4 lTSQzPBkha0+nOtaTX6o2Zxn34uSYZ7mlVTgyz9w81wQ+p7H47SBCYFH02lpyK3DuTa7 bZkJGmNSGjWLfwgV3wJwB1rmFXpRWFv1uMpHN+U5sxetsct83jzTMq8q/BRtOmMK9Av9 staAmK30cUgMLWe0ilK+xFfVzc5TKpUrF0hCY/DboAwBqPywIaSbGimoPgua6PqQNu/I czKjsQv/gA4tSLzNU/H4/ARPG5n7VF/4zo2waeDxOSM1m2M/L9mYopPjpu6nsgyoJrC8 XStQ== X-Gm-Message-State: AOAM531G75geJwlft7PSpYpsKYAdkKqE9u8EnVbvUYU3p/5gN+bYpf8o MWP3yig3mrHlcP3Ih8KVOfdmzQ0LwZ4zSb9tJr9jCpHEB5mjA3NKVScgervWKYf3O4UHskzKkXB rMYv5Dsd8oElu9T3sO92ic8Oeyv1dyyGNGQ12J6bGp8VFL4iNXIsNk85IiKw6FMj4 X-Received: by 2002:a05:620a:4727:b0:47e:2c07:efdf with SMTP id bs39-20020a05620a472700b0047e2c07efdfmr1868658qkb.399.1645111058568; Thu, 17 Feb 2022 07:17:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzBDeL3n2XWWknnsOSzShSCz4fl55fXvtPNvcNC58d47fw15KwJx9enAeEvzFlIDh/3LP1sg== X-Received: by 2002:a05:620a:4727:b0:47e:2c07:efdf with SMTP id bs39-20020a05620a472700b0047e2c07efdfmr1868628qkb.399.1645111058230; Thu, 17 Feb 2022 07:17:38 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:37 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:07 +0000 Message-Id: <20220217151712.2292329-12-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 11/16] 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 Thu Feb 17 15:17:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594330 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=FL5+FFUP; 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 4Jzz4x34Z9z9sFk for ; Fri, 18 Feb 2022 02:19:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id DB6586FCA2; Thu, 17 Feb 2022 15:19:10 +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 9fwPkRcZ-HtO; Thu, 17 Feb 2022 15:19:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 22C2C6FC90; Thu, 17 Feb 2022 15:19:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D3CCBC0021; Thu, 17 Feb 2022 15:19:06 +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 03A60C0039 for ; Thu, 17 Feb 2022 15:19:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id AE6366F75D for ; Thu, 17 Feb 2022 15:17:54 +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 pKNcQzDlIiGj for ; Thu, 17 Feb 2022 15:17:50 +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 A16516F7C3 for ; Thu, 17 Feb 2022 15:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111067; 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=hXaakl6+qQrmeyt/aCE7sUDcY0mnPc47TBUmrhYwGs8=; b=FL5+FFUPk0XhzzDqk8Qgs0JzuhnH2XyEailh+sIdlaMnDD9pqgT2W/i6Oqq6In/sBDY4IN vATLERu97bgsJtMAAhpmUamiHCXkdAJlzZRieAQaQNxmfwWk5Sq0nfFwFt4+Ata/FRHEOV BqnsWIdN3gfnyfUGJpuEK6mAdvN0TI0= 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-79-PEoY8SW5OPWllmIIx4Vtog-1; Thu, 17 Feb 2022 10:17:43 -0500 X-MC-Unique: PEoY8SW5OPWllmIIx4Vtog-1 Received: by mail-qv1-f70.google.com with SMTP id jv14-20020a05621429ee00b004300c413db6so5631783qvb.1 for ; Thu, 17 Feb 2022 07:17:43 -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=hXaakl6+qQrmeyt/aCE7sUDcY0mnPc47TBUmrhYwGs8=; b=HEzFp2d9pOK48t20DqqbO+q8ix1OLezVSpw0xGk/OabO1EjIsPu1eJySIWQZW0lp66 HYvM/sxT9hBy9TjE7p5+b4cpMLi76LFNGebHMxVflMPzgZWkOc75Q94eN8kprqoXEGhl rpn7R30D9lpxALrAhxoShxjPX7kWo/gXam6/vnKspNhZMzhLVaNEHeHhbX2NpW3Q0JQe lG84F79d6R6GrL4JrFyxq4xyWDF0DvmUq7qN4oqBuMOawTy0XStNg7YJfpVQLNKTje2V tvLD6PMek79AEJ5i1xXqZJ2++/8vSgbwOtzx7HIMZSlwS/oPuGHI9daJD8pQzqj0mWsf WPdA== X-Gm-Message-State: AOAM531U/3Z/F0DiWSML4QrHvkGbyqr9tpDqpBinrNoVnQ2szXq30M38 9TK0ie9jhX961MQxn4NgeUX511QrtDRt9Qk1ZQt7WhD2aoUS/GZc265uhfYS78FPJ3FtfWX4XF/ anXHOzrMC6CMbw6mZKBB/bn+A2AlLPqzKYtB9UF29F2DIrMRzb97Yvn7f5+6hKKRf X-Received: by 2002:a37:9c92:0:b0:60d:d77e:e643 with SMTP id f140-20020a379c92000000b0060dd77ee643mr1678117qke.252.1645111061946; Thu, 17 Feb 2022 07:17:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGP8wWWyEip4eeuFEaJ+eLP//79zPfHB4ov2HfEeGCbKQtuROpXeTaK3ArXqdLKMiEYL8FcQ== X-Received: by 2002:a37:9c92:0:b0:60d:d77e:e643 with SMTP id f140-20020a379c92000000b0060dd77ee643mr1678063qke.252.1645111061248; Thu, 17 Feb 2022 07:17:41 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:40 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:08 +0000 Message-Id: <20220217151712.2292329-13-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 12/16] 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 +- northd/ovn-sb.dlopts | 2 + northd/ovn_northd.dl | 148 +++++++++++++++++++++++++++++++---- ovn-nb.xml | 8 ++ ovn-sb.ovsschema | 17 ++++- ovn-sb.xml | 58 +++++++++++++- tests/ovn.at | 91 ++++++++++++++++++++++ 10 files changed, 517 insertions(+), 72 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/northd/ovn-sb.dlopts b/northd/ovn-sb.dlopts index 99b65f101..7d6c3d105 100644 --- a/northd/ovn-sb.dlopts +++ b/northd/ovn-sb.dlopts @@ -25,7 +25,9 @@ --output-only Logical_Flow --ro IP_Multicast.seq_no --ro Port_Binding.chassis +--ro Port_Binding.additional_chassis --ro Port_Binding.encap +--ro Port_Binding.additional_encap --ro Port_Binding.virtual_parent --ro SB_Global.connections --ro SB_Global.external_ids diff --git a/northd/ovn_northd.dl b/northd/ovn_northd.dl index 2fe73959c..16b33a661 100644 --- a/northd/ovn_northd.dl +++ b/northd/ovn_northd.dl @@ -122,6 +122,23 @@ RequestedChassis(name, chassis) :- RequestedChassis(hostname, chassis) :- sb::Chassis(._uuid = chassis, .hostname=hostname). +function get_requested_additional_chassis(options: Map) : istring = { + var requested_additional_chassis = match(options.get(i"requested-additional-chassis")) { + None -> i"", + Some{requested_additional_chassis} -> requested_additional_chassis, + }; + requested_additional_chassis +} + +relation RequestedAdditionalChassis( + name: istring, + chassis: uuid, +) +RequestedAdditionalChassis(name, chassis) :- + sb::Chassis(._uuid = chassis, .name=name). +RequestedAdditionalChassis(hostname, chassis) :- + sb::Chassis(._uuid = chassis, .hostname=hostname). + /* Proxy table for Out_Datapath_Binding: contains all Datapath_Binding fields, * except tunnel id, which is allocated separately (see PortTunKeyAllocation). */ relation OutProxy_Port_Binding ( @@ -137,7 +154,8 @@ relation OutProxy_Port_Binding ( mac: Set, nat_addresses: Set, external_ids: Map, - requested_chassis: Option + requested_chassis: Option, + requested_additional_chassis: Option ) /* Case 1a: Create a Port_Binding per logical switch port that is not of type @@ -154,7 +172,8 @@ OutProxy_Port_Binding(._uuid = lsp._uuid, .mac = lsp.addresses, .nat_addresses = set_empty(), .external_ids = eids, - .requested_chassis = None) :- + .requested_chassis = None, + .requested_additional_chassis = None) :- sp in &SwitchPort(.lsp = lsp, .sw = sw), SwitchPortNewDynamicTag(lsp._uuid, opt_tag), var tag = match (opt_tag) { @@ -181,8 +200,51 @@ OutProxy_Port_Binding(._uuid = lsp._uuid, }. /* Case 1b: Create a Port_Binding per logical switch port that is not of type + * "router" and has options "requested-chassis" pointing at non-existent + * chassis name or hostname. */ +OutProxy_Port_Binding(._uuid = lsp._uuid, + .logical_port = lsp.name, + .__type = lsp.__type, + .gateway_chassis = set_empty(), + .ha_chassis_group = sp.hac_group_uuid, + .options = options, + .datapath = sw._uuid, + .parent_port = lsp.parent_name, + .tag = tag, + .mac = lsp.addresses, + .nat_addresses = set_empty(), + .external_ids = eids, + .requested_chassis = None, + .requested_additional_chassis = None) :- + sp in &SwitchPort(.lsp = lsp, .sw = sw), + SwitchPortNewDynamicTag(lsp._uuid, opt_tag), + var tag = match (opt_tag) { + None -> lsp.tag, + Some{t} -> Some{t} + }, + lsp.__type != i"router", + var chassis_name_or_hostname = get_requested_chassis(lsp.options), + chassis_name_or_hostname != i"", + not RequestedChassis(chassis_name_or_hostname, _), + var eids = { + var eids = lsp.external_ids; + match (lsp.external_ids.get(i"neutron:port_name")) { + None -> (), + Some{name} -> eids.insert(i"name", name) + }; + eids + }, + var options = { + var options = lsp.options; + if (sw.other_config.get(i"vlan-passthru") == Some{i"true"}) { + options.insert(i"vlan-passthru", i"true") + }; + options + }. + +/* Case 1c: Create a Port_Binding per logical switch port that is not of type * "router" and has options "requested-chassis" pointing at chassis name or - * hostname. */ + * hostname, and "requested-additional-chassis" unset. */ OutProxy_Port_Binding(._uuid = lsp._uuid, .logical_port = lsp.name, .__type = lsp.__type, @@ -195,7 +257,8 @@ OutProxy_Port_Binding(._uuid = lsp._uuid, .mac = lsp.addresses, .nat_addresses = set_empty(), .external_ids = eids, - .requested_chassis = Some{requested_chassis}) :- + .requested_chassis = Some{requested_chassis}, + .requested_additional_chassis = None) :- sp in &SwitchPort(.lsp = lsp, .sw = sw), SwitchPortNewDynamicTag(lsp._uuid, opt_tag), var tag = match (opt_tag) { @@ -206,6 +269,8 @@ OutProxy_Port_Binding(._uuid = lsp._uuid, var chassis_name_or_hostname = get_requested_chassis(lsp.options), chassis_name_or_hostname != i"", RequestedChassis(chassis_name_or_hostname, requested_chassis), + var additional_chassis_name_or_hostname = get_requested_additional_chassis(lsp.options), + additional_chassis_name_or_hostname == i"", var eids = { var eids = lsp.external_ids; match (lsp.external_ids.get(i"neutron:port_name")) { @@ -222,8 +287,9 @@ OutProxy_Port_Binding(._uuid = lsp._uuid, options }. -/* Case 1c: Create a Port_Binding per logical switch port that is not of type - * "router" and has options "requested-chassis" pointing at non-existent +/* Case 1d: Create a Port_Binding per logical switch port that is not of type + * "router" and has options "requested-chassis" pointing at chassis name or + * hostname, and "requested-additional-chassis" pointing at non-existent * chassis name or hostname. */ OutProxy_Port_Binding(._uuid = lsp._uuid, .logical_port = lsp.name, @@ -237,7 +303,8 @@ OutProxy_Port_Binding(._uuid = lsp._uuid, .mac = lsp.addresses, .nat_addresses = set_empty(), .external_ids = eids, - .requested_chassis = None) :- + .requested_chassis = Some{requested_chassis}, + .requested_additional_chassis = None) :- sp in &SwitchPort(.lsp = lsp, .sw = sw), SwitchPortNewDynamicTag(lsp._uuid, opt_tag), var tag = match (opt_tag) { @@ -247,7 +314,56 @@ OutProxy_Port_Binding(._uuid = lsp._uuid, lsp.__type != i"router", var chassis_name_or_hostname = get_requested_chassis(lsp.options), chassis_name_or_hostname != i"", - not RequestedChassis(chassis_name_or_hostname, _), + RequestedChassis(chassis_name_or_hostname, requested_chassis), + var additional_chassis_name_or_hostname = get_requested_additional_chassis(lsp.options), + additional_chassis_name_or_hostname != i"", + not RequestedAdditionalChassis(additional_chassis_name_or_hostname, _), + var eids = { + var eids = lsp.external_ids; + match (lsp.external_ids.get(i"neutron:port_name")) { + None -> (), + Some{name} -> eids.insert(i"name", name) + }; + eids + }, + var options = { + var options = lsp.options; + if (sw.other_config.get(i"vlan-passthru") == Some{i"true"}) { + options.insert(i"vlan-passthru", i"true") + }; + options + }. + +/* Case 1e: Create a Port_Binding per logical switch port that is not of type + * "router" and has options "requested-chassis" and + * "requested-additional-chassis" pointing at chassis name or hostname. */ +OutProxy_Port_Binding(._uuid = lsp._uuid, + .logical_port = lsp.name, + .__type = lsp.__type, + .gateway_chassis = set_empty(), + .ha_chassis_group = sp.hac_group_uuid, + .options = options, + .datapath = sw._uuid, + .parent_port = lsp.parent_name, + .tag = tag, + .mac = lsp.addresses, + .nat_addresses = set_empty(), + .external_ids = eids, + .requested_chassis = Some{requested_chassis}, + .requested_additional_chassis = Some{requested_additional_chassis}) :- + sp in &SwitchPort(.lsp = lsp, .sw = sw), + SwitchPortNewDynamicTag(lsp._uuid, opt_tag), + var tag = match (opt_tag) { + None -> lsp.tag, + Some{t} -> Some{t} + }, + lsp.__type != i"router", + var chassis_name_or_hostname = get_requested_chassis(lsp.options), + chassis_name_or_hostname != i"", + RequestedChassis(chassis_name_or_hostname, requested_chassis), + var additional_chassis_name_or_hostname = get_requested_additional_chassis(lsp.options), + additional_chassis_name_or_hostname != i"", + RequestedAdditionalChassis(additional_chassis_name_or_hostname, requested_additional_chassis), var eids = { var eids = lsp.external_ids; match (lsp.external_ids.get(i"neutron:port_name")) { @@ -292,7 +408,8 @@ OutProxy_Port_Binding(._uuid = lsp._uuid, .mac = lsp.addresses, .nat_addresses = nat_addresses, .external_ids = eids, - .requested_chassis = None) :- + .requested_chassis = None, + .requested_additional_chassis = None) :- SwitchPortLBIPs(.port = &SwitchPort{.lsp = lsp, .sw = sw, .peer = peer}, .lbips = lbips), var eids = { @@ -387,7 +504,8 @@ OutProxy_Port_Binding(._uuid = lrp._uuid, .mac = set_singleton(i"${lrp.mac} ${lrp.networks.map(ival).to_vec().join(\" \")}"), .nat_addresses = set_empty(), .external_ids = lrp.external_ids, - .requested_chassis = None) :- + .requested_chassis = None, + .requested_additional_chassis = None) :- rp in &RouterPort(.lrp = lrp, .router = router, .peer = peer), RouterPortRAOptionsComplete(lrp._uuid, options0), (var __type, var options1) = match (router.options.get(i"chassis")) { @@ -583,7 +701,8 @@ OutProxy_Port_Binding(._uuid = cr_lrp_uuid, .mac = set_singleton(i"${lrp.mac} ${lrp.networks.map(ival).to_vec().join(\" \")}"), .nat_addresses = set_empty(), .external_ids = lrp.external_ids, - .requested_chassis = None) :- + .requested_chassis = None, + .requested_additional_chassis = None) :- DistributedGatewayPort(lrp, lr_uuid, cr_lrp_uuid), DistributedGatewayPortHAChassisGroup(lrp, hacg_uuid), var redirect_type = match (lrp.options.get(i"redirect-type")) { @@ -629,7 +748,8 @@ sb::Out_Port_Binding(._uuid = pbinding._uuid, .nat_addresses = pbinding.nat_addresses, .external_ids = pbinding.external_ids, .up = Some{up}, - .requested_chassis = pbinding.requested_chassis) :- + .requested_chassis = pbinding.requested_chassis, + .requested_additional_chassis = pbinding.requested_additional_chassis) :- pbinding in OutProxy_Port_Binding(), PortTunKeyAllocation(pbinding._uuid, tunkey), QueueIDAllocation(pbinding._uuid, qid), @@ -1477,7 +1597,9 @@ sb::Out_RBAC_Permission ( .table = i"Port_Binding", .authorization = set_singleton(i""), .insert_delete = false, - .update = [i"chassis", i"encap", i"up", i"virtual_parent"].to_set() + .update = [i"chassis", i"additional_chassis", + i"encap", i"additional_encap", + i"up", i"virtual_parent"].to_set() ). sb::Out_RBAC_Permission ( 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..49e28e2c1 100644 --- a/ovn-sb.ovsschema +++ b/ovn-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Southbound", - "version": "20.21.0", - "cksum": "2362446865 26963", + "version": "20.22.0", + "cksum": "753680782 27879", "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 Thu Feb 17 15:17:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594327 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=RaxwXaWy; 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 4Jzz4F1s18z9sFk for ; Fri, 18 Feb 2022 02:18:37 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5FAA5420E8; Thu, 17 Feb 2022 15:18:34 +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 wMKAR8SATWfj; Thu, 17 Feb 2022 15:18:31 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 94F744202C; Thu, 17 Feb 2022 15:18:29 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 647AFC0021; Thu, 17 Feb 2022 15:18:29 +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 30C56C0031 for ; Thu, 17 Feb 2022 15:18:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id C538641EE1 for ; Thu, 17 Feb 2022 15:17:50 +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 tVdA7j9m4dfB for ; Thu, 17 Feb 2022 15:17:47 +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 A918C41E95 for ; Thu, 17 Feb 2022 15:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111065; 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=oYc5AwTZL5jgAUe7LvXyE0ypl76EK/9aHNFxEAZEnCw=; b=RaxwXaWywM8i3JYmU0oizf4eHXM4X8MevHIvZ9ik2rZNDXfVR1apgi86hHMbeOjLEn7kL4 TRhIfzvhNbAkIGlfFD0MRfTVRO2A9bFY2DKDuI/XrWFNXlmegYAlmJtqQWJo0XOqgPdcf7 r32s2E8pWGreyfk10VdYhOTmuQhh2bU= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-384-EtjIFWRVNdKnWMrM6TYEvg-1; Thu, 17 Feb 2022 10:17:44 -0500 X-MC-Unique: EtjIFWRVNdKnWMrM6TYEvg-1 Received: by mail-qk1-f198.google.com with SMTP id b19-20020a05620a0cd300b005f1771f5631so3120113qkj.10 for ; Thu, 17 Feb 2022 07:17:44 -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=oYc5AwTZL5jgAUe7LvXyE0ypl76EK/9aHNFxEAZEnCw=; b=XTgdl6eled3ksugxdOq9tuMJTIyepdgJvWV1BXAwyuTS4Rua/QQSXE6v4KjiYB8wqX obH5srJw9MGPooto5BsKtnNUpafUz9TLRLReuvzssfoXbMZ6/0KtBylfSPPTp9Wwy5FJ s3y2sjnjPQcoZZDmr572zmD+5M6OLBDG8vt/Fvfv1RkX9kyKHr2udfM0cRpuQne5BbO7 k/DD+BkS436Rs0oNL6nXVty5tovBXe9QKiWVs4fo+0S4J8bRPPPKPrLjOMfZQ8qAvStX +PXkNRbBfVOXYM4Bwhpw/diDjslcLBtT1OcTUPYs/ku6ZctN5j5OwjtvVo7vlrG3FRhb 7SYg== X-Gm-Message-State: AOAM530zsZtvwyVPRUdzuW9AdgTb9LcBhsKfUg4i+yOkKTO5CNfREc/G ojc4jhtKkKg7mzM3j+FcgyeApU5BFutCpgIeQh1NPqLHu8CDNlB9lzTLRuKE3hdMf8zL+bzBcyS un3o3/hTn6ZdWfGG4QnzQOtIQ9IYCo/Q7xQOpYiujCWkLNNcVuE8CIL3bv+nqeCjS X-Received: by 2002:a37:b541:0:b0:475:4524:bb4b with SMTP id e62-20020a37b541000000b004754524bb4bmr1880309qkf.149.1645111063216; Thu, 17 Feb 2022 07:17:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOyGU8bYUz86jBEZvbaLVVwPHiPfDVUqtgJragIqAuVHi8QdlBKXLlnXbSau1qyLFghWFNGw== X-Received: by 2002:a37:b541:0:b0:475:4524:bb4b with SMTP id e62-20020a37b541000000b004754524bb4bmr1880244qkf.149.1645111062341; Thu, 17 Feb 2022 07:17:42 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:41 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:09 +0000 Message-Id: <20220217151712.2292329-14-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 13/16] 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 a3eddd100..ec4e8543a 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. * ======================= @@ -877,6 +944,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, @@ -911,6 +1012,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); @@ -1051,7 +1153,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; } @@ -1090,6 +1192,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 @@ -1100,6 +1209,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. @@ -1328,7 +1438,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); } } @@ -1462,7 +1574,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); @@ -1485,15 +1598,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 Thu Feb 17 15:17:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594328 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=UJRlCAa1; 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 4Jzz4l4sh2z9sFk for ; Fri, 18 Feb 2022 02:19:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E20BD84072; Thu, 17 Feb 2022 15:19: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 h08tg1tLeUJi; Thu, 17 Feb 2022 15:19:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 9CD9283FDD; Thu, 17 Feb 2022 15:18:59 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 70AF1C0021; Thu, 17 Feb 2022 15:18:59 +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 1F1B9C0031 for ; Thu, 17 Feb 2022 15:18:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id CD9BE6F7CD for ; Thu, 17 Feb 2022 15:17:53 +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 B50GAmprwanW for ; Thu, 17 Feb 2022 15:17: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 smtp3.osuosl.org (Postfix) with ESMTPS id 8513D6F781 for ; Thu, 17 Feb 2022 15:17:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111067; 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=fsZrwFIfQL1PSLU1hJ1qWkNxLGFaaVE4kgpQmKgzlCQ=; b=UJRlCAa1JXWCbVAKYRXnwgqTrE1fD5o2Sk4MyxL+Y/lNIOBA2/FZRr8enPwL+6sPWU/kLo 6eQfYkB8zN7yEQe+1tgmglgeqKzc6gDvzaQ+h1u/DO+FMcCf1IpYc4Xj2chi8cUbz0HjER JopEW/qEDOvDQLFFKjq9oWLWoO/hzh0= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-382-i5y7ENfANBGT7KWXZ9MPJA-1; Thu, 17 Feb 2022 10:17:46 -0500 X-MC-Unique: i5y7ENfANBGT7KWXZ9MPJA-1 Received: by mail-qk1-f200.google.com with SMTP id x16-20020a05620a449000b00508582d0db2so4459911qkp.0 for ; Thu, 17 Feb 2022 07:17: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=fsZrwFIfQL1PSLU1hJ1qWkNxLGFaaVE4kgpQmKgzlCQ=; b=qZz660hNex4SEWP/r9xzG/eO0orkmvUATAZy1CF6LOsPE0J40NMNO1W71yN2nFLPq/ IGM3si3WyWpTAE4WDgI4LhK/ibD6X7BnFSl14QZIPQno9nA5HJ/vfp4wo8Z8gjooMCyc 6Qg+99jxoYbZFwVo3iP4E4jahKWEQReYmVFs9HZBEBmb1dk9cd825rO9ak3zCJIuJ05A 7R3E4tleUwvjD0XJsbGFwAIuBj+icWDwV+JQT1tBx9zlOkTaOQryrA6u991cOy6UPUcp NMoXPnndoxr9Cey/SkXpbl3yJfyavd+RnTzBP7svQEOKKJIyY70wlAjn0g4tM4aPtLTi 5awg== X-Gm-Message-State: AOAM530Qagnz4eG9h2xH4uosAkniHJf3X9nXxDw9F94hBzqAaW+MO+7g VrUgVYHZQRK/U9Bfb9INC9WAd7OOzwexG/5ShMM6+DCICQNl/H1GvVS0PYDwbDQsgmiuiZ/bwoS E25K3B7ZEOKAGjanVTYyk1vvnpP67vCO3wlq8cdMN4gXt228QssOOlt48Kynl2Yii X-Received: by 2002:a37:5e85:0:b0:506:d10a:4a4e with SMTP id s127-20020a375e85000000b00506d10a4a4emr1820925qkb.285.1645111064215; Thu, 17 Feb 2022 07:17:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxatbvKPclEahuaFACErRsmMkFmL4G7JkXB1cKE9W7Y+EuU3S5QWERjzc8g71Jk8fe2jfHY0A== X-Received: by 2002:a37:5e85:0:b0:506:d10a:4a4e with SMTP id s127-20020a375e85000000b00506d10a4a4emr1820891qkb.285.1645111063775; Thu, 17 Feb 2022 07:17:43 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:42 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:10 +0000 Message-Id: <20220217151712.2292329-15-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 14/16] 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 ec4e8543a..47ad3da33 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -1166,7 +1166,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) { @@ -1193,11 +1195,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 Thu Feb 17 15:17:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594331 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=GLuxnvpt; 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 4Jzz5M40BPz9sFw for ; Fri, 18 Feb 2022 02:19:35 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5597D42102; Thu, 17 Feb 2022 15:19: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 7JIRzrmbDqsK; Thu, 17 Feb 2022 15:19:27 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id A1CD24216F; Thu, 17 Feb 2022 15:19:20 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6DF67C0021; Thu, 17 Feb 2022 15:19:20 +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 120CEC0021 for ; Thu, 17 Feb 2022 15:19:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3F8DD83F55 for ; Thu, 17 Feb 2022 15:17:57 +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 WFNn_xvjZiBq for ; Thu, 17 Feb 2022 15:17: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.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 5D60E84011 for ; Thu, 17 Feb 2022 15:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111070; 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=Yze99ACJPHMpfLbTS72SccBjzpI3hMm76JqUis03y0U=; b=GLuxnvptd0OAne7B/nDjo0nlgGX0L41uahe6jlsuYTNMTc81TuH8GBl+XDvi2/ZMW9En0v OIqv8er7t8yg0EkOzkQhpO9pKBhtvunkztwDseibUpc7z2E+NpZYZZyrRl7GYx4ABLpayN StW0Fz7X3bVZtL5QyWdyeGXC33Jj/ic= 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-294-l1P8IDUQOcKx-dfjskPiCw-1; Thu, 17 Feb 2022 10:17:49 -0500 X-MC-Unique: l1P8IDUQOcKx-dfjskPiCw-1 Received: by mail-qv1-f70.google.com with SMTP id eu2-20020ad44f42000000b0042bfcac4a52so5583310qvb.16 for ; Thu, 17 Feb 2022 07:17: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=Yze99ACJPHMpfLbTS72SccBjzpI3hMm76JqUis03y0U=; b=VQ/doIUpuESiy1hZnB3wIPrElNuPUrU0WrSMAYpdAkQ2+UR7c8mLxym4LsqNKyrrpn SNn2xztR1TMLKHC5zMX8Crbk8wnmHk3geG5y7MsZX4X24Q1vr4RXhfN2XplEsK1slyOr +otGBatLBU613nb/tj+D/iVWXh4jUebb8xqpFo8ZtjKxj1WEdUQru1jq2tdVwIx/QBVT Agy+dOdY9Azo6yOMricHffBZ0WzsOOSkCAwWSHzOCfIlNeLo3TiM1QusF54NUC3d/SwM TEAQG3jiZ3/k/RyWvB9I0TKenWn0DwE9Y98+mYc1uHCzP0JOm5khpCLLMbqGYWGr4LTr EvHA== X-Gm-Message-State: AOAM531h5mdwVImfoxUs4U41CVFwOWUCnN6RoruezKf0uxwyaAzaWOu8 nHUxqFqJj79+J0hvrqHnP7VLZvD9J1YA69lZle+O/TdgLtLAiXctXGTce7q9bOKuX+aOVxBd5/q CKlm+BkDtU1wr1SK+WJxD0pMDH21FtVnQmOPKhezSyX+BkJkR7c1JRPXJDvr9E9O6 X-Received: by 2002:a05:6214:27cb:b0:424:e51d:5018 with SMTP id ge11-20020a05621427cb00b00424e51d5018mr2360793qvb.81.1645111066942; Thu, 17 Feb 2022 07:17:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgk4kAYX29k8plMcizOBy9Eh+wXjuKIMgM0Hx/UUZs5NhOLja9B6VeDNMvg6dtFRTZiDhYeQ== X-Received: by 2002:a05:6214:27cb:b0:424:e51d:5018 with SMTP id ge11-20020a05621427cb00b00424e51d5018mr2360731qvb.81.1645111066235; Thu, 17 Feb 2022 07:17:46 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:44 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:11 +0000 Message-Id: <20220217151712.2292329-16-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 15/16] 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 +- northd/ovn_northd.dl | 27 ++++++- ovn-nb.xml | 10 +++ ovn-sb.xml | 15 ++++ tests/ovn.at | 161 ++++++++++++++++++++++++++++++++++++++++++ utilities/ovn-trace.c | 3 + 12 files changed, 507 insertions(+), 7 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index 47ad3da33..f80665573 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" @@ -978,6 +980,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, @@ -1194,6 +1249,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..af9279bb4 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/northd/ovn_northd.dl b/northd/ovn_northd.dl index 16b33a661..6df9ca84c 100644 --- a/northd/ovn_northd.dl +++ b/northd/ovn_northd.dl @@ -372,13 +372,19 @@ OutProxy_Port_Binding(._uuid = lsp._uuid, }; eids }, - var options = { + var options0 = { var options = lsp.options; if (sw.other_config.get(i"vlan-passthru") == Some{i"true"}) { options.insert(i"vlan-passthru", i"true") }; options - }. + }, + PreserveAdditionalChassisActivated(lsp._uuid, activated), + var options1 = match (activated) { + None -> map_empty(), + Some{value} -> [i"additional-chassis-activated" -> value] + }, + var options = options0.union(options1). relation SwitchPortLBIPs( port: Intern, @@ -1592,6 +1598,8 @@ sb::Out_RBAC_Permission ( .update = [i"type", i"options", i"ip"].to_set() ). +/* NOTE: we only need to update the additional-chassis-activated key, + * but RBAC_Role doesn't support mutate operation for subkeys. */ sb::Out_RBAC_Permission ( ._uuid = 128'hd8ceff1a_2b11_48bd_802f_4a991aa4e908, .table = i"Port_Binding", @@ -1599,7 +1607,8 @@ sb::Out_RBAC_Permission ( .insert_delete = false, .update = [i"chassis", i"additional_chassis", i"encap", i"additional_encap", - i"up", i"virtual_parent"].to_set() + i"up", i"virtual_parent", + i"options"].to_set() ). sb::Out_RBAC_Permission ( @@ -8895,6 +8904,18 @@ PreserveIPv6RAPDList(lrp_uuid, None) :- &nb::Logical_Router_Port(._uuid = lrp_uuid), not sb::Port_Binding(._uuid = lrp_uuid). +/* + * This allows ovn-northd to preserve options:additional-chassis-activated, + * which is set by ovn-controller. + */ +relation PreserveAdditionalChassisActivated(lsp_uuid: uuid, activated: Option) +PreserveAdditionalChassisActivated(lsp_uuid, activated) :- + sb::Port_Binding(._uuid = lsp_uuid, .options = options), + var activated = options.get(i"additional-chassis-activated"). +PreserveAdditionalChassisActivated(lsp_uuid, None) :- + &nb::Logical_Switch_Port(._uuid = lsp_uuid), + not sb::Port_Binding(._uuid = lsp_uuid). + /* * Tag allocation for nested containers. */ 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..a0698c362 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14383,6 +14383,167 @@ 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 + +AT_CHECK([ovn-sbctl find port_binding logical_port=migrator | grep -q additional-chassis-activated], [1]) + +# 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) +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; From patchwork Thu Feb 17 15:17:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1594329 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=hKyNnopO; 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 4Jzz4r3T71z9sFk for ; Fri, 18 Feb 2022 02:19:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 271E584015; Thu, 17 Feb 2022 15:19:05 +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 sCZMuteZ5r5Y; Thu, 17 Feb 2022 15:19:04 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 8FFF184019; Thu, 17 Feb 2022 15:19:02 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 65F4CC0039; Thu, 17 Feb 2022 15:19:02 +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 29E2BC0072 for ; Thu, 17 Feb 2022 15:19:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 71F6A41EA2 for ; Thu, 17 Feb 2022 15:17:57 +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 vkfuJZ89SDJS for ; Thu, 17 Feb 2022 15:17:55 +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 8A78642002 for ; Thu, 17 Feb 2022 15:17:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645111073; 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=JdCexRJd4kxzveRtLbVeu6xqtBg4tDSWEhBfGH/anQA=; b=hKyNnopOlMstQSQZnyMWrmlJlG7WpYfbUbbg1nJh20l59KT8aXTfSDVx3rOt9CbkizKB5q ju3t1gg6FdklA76W1pDMb3euFggU/oXmfpEi1g8w+2oooE2crdNA03k8JqGlpcXYKBL8gW /khojNpYVwQxHHM5mauOd9NDHBHOLPM= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-491-VPNdmiSXNkmI63GH4QzejQ-1; Thu, 17 Feb 2022 10:17:49 -0500 X-MC-Unique: VPNdmiSXNkmI63GH4QzejQ-1 Received: by mail-qk1-f200.google.com with SMTP id b19-20020a05620a0cd300b005f1771f5631so3120350qkj.10 for ; Thu, 17 Feb 2022 07:17: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=JdCexRJd4kxzveRtLbVeu6xqtBg4tDSWEhBfGH/anQA=; b=hxoDOeX7lPucdBDDJuK/pz+p+pSgdVF1PENB1+2B5MQ1sp/huaK+YILM1EICLnCPYB DsUR9oQOqhQ+4376NdNbIFCkJ4FCEQMV/FcddVNs6sqWdu904NhEeLfyoS6OucdLaJR/ Ekgi19r3u72gDjg1E4b/Boz6yBJS7EVxeHbxrDZFAYZI40HfmIHj6tYa5aiYy4s+LJjp WIvCqUHPPTaj0FR6072IeE27epRid10o2okWgBuucXq7EtIaY8W2cPKWoraTOszBW7Lr JsWDiMKOIvXN4AudUJdi+83iE/mA+bWNzeu5u3FRZcK+jwDXRoUav2xyhB6EfZHXWgkR jpfQ== X-Gm-Message-State: AOAM533UZMu8bT6DYM4sf+es4VgCafLtrF8e0PRx+FLu6tAjWTF9srDd 27a1CS6zx38KmRQj586a3ndEAASgdp+oXFUcIwD6M53ng7v9aZ2xUoYbkYtReoLmxE6cOuV1lVT IyS2wKDRxLT9TyyYJbOW5mFgO9Ucocn+MP29gXvAX4TgLawSkzsho6XGDyo2Dr9AV X-Received: by 2002:a05:622a:608:b0:2c5:fa98:9325 with SMTP id z8-20020a05622a060800b002c5fa989325mr2846621qta.393.1645111067997; Thu, 17 Feb 2022 07:17:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXH1xEWHlUdCTmckda/ojuCnVfjYzeOrB3GGnTvJaF9JiEVxJhlgv0WrZzpYoMRL5CG7cn2w== X-Received: by 2002:a05:622a:608:b0:2c5:fa98:9325 with SMTP id z8-20020a05622a060800b002c5fa989325mr2846585qta.393.1645111067535; Thu, 17 Feb 2022 07:17:47 -0800 (PST) Received: from fedora34.localdomain (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.gmail.com with ESMTPSA id p66sm6937371qkf.12.2022.02.17.07.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 07:17:46 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Thu, 17 Feb 2022 15:17:12 +0000 Message-Id: <20220217151712.2292329-17-ihrachys@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220217151712.2292329-1-ihrachys@redhat.com> References: <20220217151712.2292329-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 v3 16/16] Reinject RARP packet when activation-strategy=rarp 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" It takes some time for vswitchd to remove the blocking flows, so we need to wait for the flow_mod message handled before reinjecting the received RARP packet into the pipeline. Use a barrier to indicate the message processed by vswitchd. Signed-off-by: Ihar Hrachyshka --- controller/pinctrl.c | 103 ++++++++++++++++++++++++++++++++++++++++--- tests/ovn.at | 8 +++- 2 files changed, 105 insertions(+), 6 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index af9279bb4..d95a5d8bf 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -201,7 +201,14 @@ 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); + const struct match *md, + struct dp_packet *pkt_in); + +static void init_pending_rarp_packets(void); +static void destroy_pending_rarp_packets(void); +static void flush_pending_rarp_packets(struct rconn *swconn, uint32_t xid) + OVS_REQUIRES(pinctrl_mutex); + static void init_activated_ports(void); static void destroy_activated_ports(void); static void wait_activated_ports(struct ovsdb_idl_txn *ovnsb_idl_txn); @@ -536,6 +543,7 @@ pinctrl_init(void) init_ipv6_prefixd(); init_buffered_packets_map(); init_activated_ports(); + init_pending_rarp_packets(); init_event_table(); ip_mcast_snoop_init(); init_put_vport_bindings(); @@ -3258,7 +3266,8 @@ process_packet_in(struct rconn *swconn, const struct ofp_header *msg) case ACTION_OPCODE_ACTIVATION_STRATEGY_RARP: ovs_mutex_lock(&pinctrl_mutex); - pinctrl_rarp_activation_strategy_handler(swconn, &pin.flow_metadata); + pinctrl_rarp_activation_strategy_handler(swconn, &pin.flow_metadata, + &packet); ovs_mutex_unlock(&pinctrl_mutex); break; @@ -3319,6 +3328,10 @@ pinctrl_recv(struct rconn *swconn, const struct ofp_header *oh, } else if (type == OFPTYPE_PACKET_IN) { COVERAGE_INC(pinctrl_total_pin_pkts); process_packet_in(swconn, oh); + } else if (type == OFPTYPE_BARRIER_REPLY) { + ovs_mutex_lock(&pinctrl_mutex); + flush_pending_rarp_packets(swconn, ntohl(oh->xid)); + ovs_mutex_unlock(&pinctrl_mutex); } else { if (VLOG_IS_DBG_ENABLED()) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(30, 300); @@ -4072,6 +4085,7 @@ pinctrl_destroy(void) destroy_ipv6_prefixd(); destroy_buffered_packets_map(); destroy_activated_ports(); + destroy_pending_rarp_packets(); event_table_destroy(); destroy_put_mac_bindings(); destroy_put_vport_bindings(); @@ -7760,6 +7774,70 @@ encode_flow_mod(struct ofputil_flow_mod *fm) return ofputil_encode_flow_mod(fm, OFPUTIL_P_OF15_OXM); } +struct rarp_packet { + uint32_t xid; + int64_t dp_key; + int64_t port_key; + struct dp_packet *pkt; + struct ovs_list list; +}; + +static struct ovs_list pending_rarp_packets; + +static void +init_pending_rarp_packets(void) +{ + ovs_list_init(&pending_rarp_packets); +} + +static void +destroy_pending_rarp_packets(void) +{ + struct rarp_packet *rp; + LIST_FOR_EACH_POP (rp, list, &pending_rarp_packets) { + free(rp->pkt); + free(rp); + } +} + +static void flush_pending_rarp_packets(struct rconn *swconn, uint32_t xid) + OVS_REQUIRES(pinctrl_mutex) +{ + struct rarp_packet *rp, *next; + LIST_FOR_EACH_SAFE (rp, next, list, &pending_rarp_packets) { + if (rp->xid != xid) { + continue; + } + /* Blocking flows are now gone; re-inject RARP message. */ + uint64_t ofpacts_stub[4096 / 8]; + struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(ofpacts_stub); + enum ofp_version version = rconn_get_version(swconn); + put_load(rp->dp_key, MFF_LOG_DATAPATH, 0, 64, &ofpacts); + put_load(rp->port_key, MFF_LOG_INPORT, 0, 32, &ofpacts); + struct ofpact_resubmit *resubmit = ofpact_put_RESUBMIT(&ofpacts); + resubmit->in_port = OFPP_CONTROLLER; + resubmit->table_id = OFTABLE_LOG_INGRESS_PIPELINE; + + struct ofputil_packet_out po = { + .packet = dp_packet_data(rp->pkt), + .packet_len = dp_packet_size(rp->pkt), + .buffer_id = UINT32_MAX, + .ofpacts = ofpacts.data, + .ofpacts_len = ofpacts.size, + }; + match_set_in_port(&po.flow_metadata, OFPP_CONTROLLER); + + enum ofputil_protocol proto; + proto = ofputil_protocol_from_ofp_version(version); + queue_msg(swconn, ofputil_encode_packet_out(&po, proto)); + ofpbuf_uninit(&ofpacts); + + ovs_list_remove(&rp->list); + free(rp->pkt); + free(rp); + } +} + struct port_pair { uint32_t dp_key; uint32_t port_key; @@ -7828,7 +7906,8 @@ bool pinctrl_is_port_activated(int64_t dp_key, int64_t port_key) static void pinctrl_rarp_activation_strategy_handler(struct rconn *swconn, - const struct match *md) + const struct match *md, + struct dp_packet *pkt_in) OVS_REQUIRES(pinctrl_mutex) { struct match match; @@ -7874,10 +7953,24 @@ pinctrl_rarp_activation_strategy_handler(struct rconn *swconn, queue_msg(swconn, encode_flow_mod(&fm)); minimatch_destroy(&mmatch); + ovs_be32 xid = queue_msg( + swconn, ofputil_encode_barrier_request(OFP15_VERSION)); + + /* Delay delivery of RARP to when blocking flows are deleted. */ + uint32_t port_key = md->flow.regs[MFF_LOG_INPORT - MFF_REG0]; + uint32_t dp_key = ntohll(md->flow.metadata); + + struct rarp_packet *rp = xmalloc(sizeof *rp); + rp->xid = ntohl(xid); + rp->port_key = port_key; + rp->dp_key = dp_key; + rp->pkt = dp_packet_clone(pkt_in); + ovs_list_push_back(&pending_rarp_packets, &rp->list); + /* 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); + pp->port_key = port_key; + pp->dp_key = dp_key; ovs_list_push_front(&activated_ports, &pp->list); /* Notify main thread on pending additional-chassis-activated updates. */ diff --git a/tests/ovn.at b/tests/ovn.at index a0698c362..f6c2e309f 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14450,6 +14450,7 @@ 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 + echo "${request}" } reset_pcap_file() { @@ -14508,7 +14509,12 @@ reset_env AT_CHECK([ovn-sbctl find port_binding logical_port=migrator | grep -q additional-chassis-activated], [1]) # Now activate hv2:Migrator location -send_rarp hv2 migrator 000000000001 ffffffffffff $migrator_spa $migrator_spa +request=$(send_rarp hv2 migrator 000000000001 ffffffffffff $migrator_spa $migrator_spa) + +# RARP was reinjected into the pipeline +echo $request >> hv3/outside.expected + +check_packets reset_env pb_uuid=$(ovn-sbctl --bare --columns _uuid find Port_Binding logical_port=migrator)