From patchwork Wed Jan 19 13:39:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1581781 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=idaQaTpk; 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 4Jf6FZ11g8z9tD5 for ; Thu, 20 Jan 2022 00:39:46 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4767E40915; Wed, 19 Jan 2022 13:39:43 +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 J3WNHRSz-hXs; Wed, 19 Jan 2022 13:39:41 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 7F4D240912; Wed, 19 Jan 2022 13:39:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4CCFAC0039; Wed, 19 Jan 2022 13:39:40 +0000 (UTC) X-Original-To: ovs-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 8044BC0039 for ; Wed, 19 Jan 2022 13:39:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BE1664155C for ; Wed, 19 Jan 2022 13:39:38 +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 8DUEF1Jvb5oY for ; Wed, 19 Jan 2022 13:39: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 smtp4.osuosl.org (Postfix) with ESMTPS id 4D30A410A7 for ; Wed, 19 Jan 2022 13:39:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642599576; 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=PTOaytt4/Y7X+AKZ8Yv061Sa23kWcKBJaNL6Wjzl7TE=; b=idaQaTpkm7pfkHpDBToR7OJxcWiSUq3raqeJvFCSyca+3EImuAD+ftZBRwURjm5X4Dh1iK x/tqPQ5fqW7KlgLyFFbrDFjw4UtqepbTzvTbuO8hjn83IagkPsaRfph9QBHiuPX4emDKzK Fjq3zU3cw2QWxzJ38v/KiH+M9yHCiHc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-160-mFdSpHvhOeGMSWAT8ZC_7A-1; Wed, 19 Jan 2022 08:39:34 -0500 X-MC-Unique: mFdSpHvhOeGMSWAT8ZC_7A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EA3FF1091DA0; Wed, 19 Jan 2022 13:39:33 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.192.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6DB97E2FB; Wed, 19 Jan 2022 13:39:31 +0000 (UTC) From: Dumitru Ceara To: ovs-dev@openvswitch.org Date: Wed, 19 Jan 2022 14:39:28 +0100 Message-Id: <20220119133925.25792.71760.stgit@dceara.remote.csb> In-Reply-To: <20220119133906.25792.90079.stgit@dceara.remote.csb> References: <20220119133906.25792.90079.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 1/2] tests: Factor out multicast related helpers. 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" These were duplicated a few times already. Signed-off-by: Dumitru Ceara --- tests/ovn-macros.at | 193 +++++++++++++++++++++++++++++ tests/ovn.at | 338 +++------------------------------------------------ 2 files changed, 212 insertions(+), 319 deletions(-) diff --git a/tests/ovn-macros.at b/tests/ovn-macros.at index 21b7d985e..91d2dafc8 100644 --- a/tests/ovn-macros.at +++ b/tests/ovn-macros.at @@ -552,6 +552,199 @@ netdev_dummy_receive() { fi } +# send_igmp_v3_report INPORT HV ETH_SRC IP_SRC IP_CSUM GROUP REC_TYPE +# IGMP_CSUM OUTFILE +# +# This shell function causes an IGMPv3 report to be received on INPORT of HV. +# The packet's content has Ethernet destination 01:00:5E:00:00:22 and source +# ETH_SRC (exactly 12 hex digits). Ethernet type is set to IP. +# GROUP is the IP multicast group to be joined/to leave (based on REC_TYPE). +# REC_TYPE == 04: join GROUP +# REC_TYPE == 03: leave GROUP +# The packet hexdump is also stored in OUTFILE. +# +send_igmp_v3_report() { + local inport=$1 hv=$2 eth_src=$3 ip_src=$4 ip_chksum=$5 group=$6 + local rec_type=$7 igmp_chksum=$8 outfile=$9 + + local eth_dst=01005e000016 + local ip_dst=$(ip_to_hex 224 0 0 22) + local ip_ttl=01 + local ip_ra_opt=94040000 + + local igmp_type=2200 + local num_rec=00000001 + local aux_dlen=00 + local num_src=0000 + + local eth=${eth_dst}${eth_src}0800 + local ip=46c0002800004000${ip_ttl}02${ip_chksum}${ip_src}${ip_dst}${ip_ra_opt} + local igmp=${igmp_type}${igmp_chksum}${num_rec}${rec_type}${aux_dlen}${num_src}${group} + local packet=${eth}${ip}${igmp} + + echo ${packet} >> ${outfile} + check as $hv ovs-appctl netdev-dummy/receive ${inport} ${packet} +} + +# store_igmp_v3_query ETH_SRC IP_SRC IP_CSUM OUTFILE +# +# This shell function builds an IGMPv3 general query from ETH_SRC and IP_SRC +# and stores the hexdump of the packet in OUTFILE. +# +store_igmp_v3_query() { + local eth_src=$1 ip_src=$2 ip_chksum=$3 outfile=$4 + + local eth_dst=01005e000001 + local ip_dst=$(ip_to_hex 224 0 0 1) + local ip_ttl=01 + local igmp_type=11 + local max_resp=0a + local igmp_chksum=eeeb + local addr=00000000 + + local eth=${eth_dst}${eth_src}0800 + local ip=4500002000004000${ip_ttl}02${ip_chksum}${ip_src}${ip_dst} + local igmp=${igmp_type}${max_resp}${igmp_chksum}${addr}000a0000 + local packet=${eth}${ip}${igmp} + + echo ${packet} >> ${outfile} +} + +# send_ip_multicast_pkt INPORT HV ETH_SRC ETH_DST IP_SRC IP_DST IP_LEN TTL +# IP_CHKSUM IP_PROTO DATA +# +# This shell function causes an IP multicast packet to be received on INPORT +# of HV. +# The hexdump of the packet is stored in OUTFILE. +# +send_ip_multicast_pkt() { + local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 + local ip_src=$5 ip_dst=$6 ip_len=$7 ip_ttl=$8 ip_chksum=$9 proto=${10} + local data=${11} + + local eth=${eth_dst}${eth_src}0800 + local ip=450000${ip_len}95f14000${ip_ttl}${proto}${ip_chksum}${ip_src}${ip_dst} + local packet=${eth}${ip}${data} + + check as $hv ovs-appctl netdev-dummy/receive ${inport} ${packet} +} + +# store_ip_multicast_pkt ETH_SRC ETH_DST IP_SRC IP_DST IP_LEN TTL +# IP_CHKSUM IP_PROTO DATA OUTFILE +# +# This shell function builds an IP multicast packet and stores the hexdump of +# the packet in OUTFILE. +# +store_ip_multicast_pkt() { + local eth_src=$1 eth_dst=$2 + local ip_src=$3 ip_dst=$4 ip_len=$5 ip_ttl=$6 ip_chksum=$7 proto=$8 + local data=$9 outfile=${10} + + local eth=${eth_dst}${eth_src}0800 + local ip=450000${ip_len}95f14000${ip_ttl}${proto}${ip_chksum}${ip_src}${ip_dst} + local packet=${eth}${ip}${data} + + echo ${packet} >> ${outfile} +} + +# send_mld_v2_report INPORT HV ETH_SRC IP_SRC GROUP REC_TYPE +# MLD_CSUM OUTFILE +# +# This shell function causes an MLDv2 report to be received on INPORT of HV. +# The packet's content has Ethernet destination 33:33:00:00:00:16 and source +# ETH_SRC (exactly 12 hex digits). Ethernet type is set to IPv6. +# GROUP is the IPv6 multicast group to be joined/to leave (based on REC_TYPE). +# REC_TYPE == 04: join GROUP +# REC_TYPE == 03: leave GROUP +# The packet hexdump is also stored in OUTFILE. +# +send_mld_v2_report() { + local inport=$1 hv=$2 eth_src=$3 ip_src=$4 group=$5 + local rec_type=$6 mld_chksum=$7 outfile=$8 + + local eth_dst=333300000016 + local ip_dst=ff020000000000000000000000000016 + local ip_ttl=01 + local ip_ra_opt=3a00050200000100 + + local mld_type=8f + local mld_code=00 + local num_rec=0001 + local aux_dlen=00 + local num_src=0000 + + local eth=${eth_dst}${eth_src}86dd + local ip=60000000002400${ip_ttl}${ip_src}${ip_dst}${ip_ra_opt} + local mld=${mld_type}${mld_code}${mld_chksum}0000${num_rec}${rec_type}${aux_dlen}${num_src}${group} + local packet=${eth}${ip}${mld} + + echo ${packet} >> ${outfile} + check as $hv ovs-appctl netdev-dummy/receive ${inport} ${packet} +} + +# store_mld_query ETH_SRC IP_SRC OUTFILE +# +# This shell function builds an MLD general query from ETH_SRC and IP_SRC +# and stores the hexdump of the packet in OUTFILE. +# +store_mld_query() { + local eth_src=$1 ip_src=$2 outfile=$3 + + local eth_dst=333300000000 + local ip_dst=ff020000000000000000000000000001 + local ip_ttl=01 + local ip_ra_opt=3a00050200000000 + + local mld_type=82 + local mld_code=00 + local max_resp=03e8 + local mld_chksum=7b3d + local addr=00000000000000000000000000000000 + + local eth=${eth_dst}${eth_src}86dd + local ip=60000000002400${ip_ttl}${ip_src}${ip_dst}${ip_ra_opt} + local mld=${mld_type}${mld_code}${mld_chksum}${max_resp}0000${addr}00010000 + local packet=${eth}${ip}${mld} + + echo ${packet} >> ${outfile} +} + +# send_ip6_multicast_pkt INPORT HV ETH_SRC ETH_DST IP_SRC IP_DST IP_LEN TTL +# IP_PROTO DATA +# +# This shell function causes an IP multicast packet to be received on INPORT +# of HV. +# +send_ip6_multicast_pkt() { + local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 + local ip_src=$5 ip_dst=$6 ip_len=$7 ip_ttl=$8 proto=$9 + local data=${10} + + local eth=${eth_dst}${eth_src}86dd + local ip=60000000${ip_len}${proto}${ip_ttl}${ip_src}${ip_dst} + local packet=${eth}${ip}${data} + + check as $hv ovs-appctl netdev-dummy/receive ${inport} ${packet} +} + +# store_ip6_multicast_pkt ETH_SRC ETH_DST IP_SRC IP_DST IP_LEN TTL +# IP_PROTO DATA OUTFILE +# +# This shell function builds an IP multicast packet and stores the hexdump of +# the packet in OUTFILE. +# +store_ip6_multicast_pkt() { + local eth_src=$1 eth_dst=$2 + local ip_src=$3 ip_dst=$4 ip_len=$5 ip_ttl=$6 proto=$7 + local data=$8 outfile=$9 + + local eth=${eth_dst}${eth_src}86dd + local ip=60000000${ip_len}${proto}${ip_ttl}${ip_src}${ip_dst} + local packet=${eth}${ip}${data} + + echo ${packet} >> ${outfile} +} + OVS_END_SHELL_HELPERS m4_define([OVN_POPULATE_ARP], [AT_CHECK(ovn_populate_arp__, [0], [ignore])]) diff --git a/tests/ovn.at b/tests/ovn.at index 92e284e8a..ad08a7d63 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -19041,105 +19041,6 @@ options:rxq_pcap=dummy-rx.pcap options:rxq_pcap=${pcap_file}-rx.pcap } -# -# send_igmp_v3_report INPORT HV ETH_SRC IP_SRC IP_CSUM GROUP REC_TYPE -# IGMP_CSUM OUTFILE -# -# This shell function causes an IGMPv3 report to be received on INPORT of HV. -# The packet's content has Ethernet destination 01:00:5E:00:00:22 and source -# ETH_SRC (exactly 12 hex digits). Ethernet type is set to IP. -# GROUP is the IP multicast group to be joined/to leave (based on REC_TYPE). -# REC_TYPE == 04: join GROUP -# REC_TYPE == 03: leave GROUP -# The packet hexdump is also stored in OUTFILE. -# -send_igmp_v3_report() { - local inport=$1 hv=$2 eth_src=$3 ip_src=$4 ip_chksum=$5 group=$6 - local rec_type=$7 igmp_chksum=$8 outfile=$9 - - local eth_dst=01005e000016 - local ip_dst=$(ip_to_hex 224 0 0 22) - local ip_ttl=01 - local ip_ra_opt=94040000 - - local igmp_type=2200 - local num_rec=00000001 - local aux_dlen=00 - local num_src=0000 - - local eth=${eth_dst}${eth_src}0800 - local ip=46c0002800004000${ip_ttl}02${ip_chksum}${ip_src}${ip_dst}${ip_ra_opt} - local igmp=${igmp_type}${igmp_chksum}${num_rec}${rec_type}${aux_dlen}${num_src}${group} - local packet=${eth}${ip}${igmp} - - echo ${packet} >> ${outfile} - check as $hv ovs-appctl netdev-dummy/receive ${inport} ${packet} -} - -# -# store_igmp_v3_query ETH_SRC IP_SRC IP_CSUM OUTFILE -# -# This shell function builds an IGMPv3 general query from ETH_SRC and IP_SRC -# and stores the hexdump of the packet in OUTFILE. -# -store_igmp_v3_query() { - local eth_src=$1 ip_src=$2 ip_chksum=$3 outfile=$4 - - local eth_dst=01005e000001 - local ip_dst=$(ip_to_hex 224 0 0 1) - local ip_ttl=01 - local igmp_type=11 - local max_resp=0a - local igmp_chksum=eeeb - local addr=00000000 - - local eth=${eth_dst}${eth_src}0800 - local ip=4500002000004000${ip_ttl}02${ip_chksum}${ip_src}${ip_dst} - local igmp=${igmp_type}${max_resp}${igmp_chksum}${addr}000a0000 - local packet=${eth}${ip}${igmp} - - echo ${packet} >> ${outfile} -} - -# -# send_ip_multicast_pkt INPORT HV ETH_SRC ETH_DST IP_SRC IP_DST IP_LEN TTL -# IP_CHKSUM IP_PROTO DATA -# -# This shell function causes an IP multicast packet to be received on INPORT -# of HV. -# The hexdump of the packet is stored in OUTFILE. -# -send_ip_multicast_pkt() { - local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 - local ip_src=$5 ip_dst=$6 ip_len=$7 ip_ttl=$8 ip_chksum=$9 proto=${10} - local data=${11} - - local eth=${eth_dst}${eth_src}0800 - local ip=450000${ip_len}95f14000${ip_ttl}${proto}${ip_chksum}${ip_src}${ip_dst} - local packet=${eth}${ip}${data} - - check as $hv ovs-appctl netdev-dummy/receive ${inport} ${packet} -} - -# -# store_ip_multicast_pkt ETH_SRC ETH_DST IP_SRC IP_DST IP_LEN TTL -# IP_CHKSUM IP_PROTO DATA OUTFILE -# -# This shell function builds an IP multicast packet and stores the hexdump of -# the packet in OUTFILE. -# -store_ip_multicast_pkt() { - local eth_src=$1 eth_dst=$2 - local ip_src=$3 ip_dst=$4 ip_len=$5 ip_ttl=$6 ip_chksum=$7 proto=$8 - local data=$9 outfile=${10} - - local eth=${eth_dst}${eth_src}0800 - local ip=450000${ip_len}95f14000${ip_ttl}${proto}${ip_chksum}${ip_src}${ip_dst} - local packet=${eth}${ip}${data} - - echo ${packet} >> ${outfile} -} - ovn-nbctl ls-add sw1 ovn-nbctl ls-add sw2 ovn-nbctl ls-add sw3 @@ -19726,105 +19627,6 @@ options:rxq_pcap=dummy-rx.pcap options:rxq_pcap=${pcap_file}-rx.pcap } -# -# send_igmp_v3_report INPORT HV ETH_SRC IP_SRC IP_CSUM GROUP REC_TYPE -# IGMP_CSUM OUTFILE -# -# This shell function causes an IGMPv3 report to be received on INPORT of HV. -# The packet's content has Ethernet destination 01:00:5E:00:00:22 and source -# ETH_SRC (exactly 12 hex digits). Ethernet type is set to IP. -# GROUP is the IP multicast group to be joined/to leave (based on REC_TYPE). -# REC_TYPE == 04: join GROUP -# REC_TYPE == 03: leave GROUP -# The packet hexdump is also stored in OUTFILE. -# -send_igmp_v3_report() { - local inport=$1 hv=$2 eth_src=$3 ip_src=$4 ip_chksum=$5 group=$6 - local rec_type=$7 igmp_chksum=$8 outfile=$9 - - local eth_dst=01005e000016 - local ip_dst=$(ip_to_hex 224 0 0 22) - local ip_ttl=01 - local ip_ra_opt=94040000 - - local igmp_type=2200 - local num_rec=00000001 - local aux_dlen=00 - local num_src=0000 - - local eth=${eth_dst}${eth_src}0800 - local ip=46c0002800004000${ip_ttl}02${ip_chksum}${ip_src}${ip_dst}${ip_ra_opt} - local igmp=${igmp_type}${igmp_chksum}${num_rec}${rec_type}${aux_dlen}${num_src}${group} - local packet=${eth}${ip}${igmp} - - echo ${packet} >> ${outfile} - check as $hv ovs-appctl netdev-dummy/receive ${inport} ${packet} -} - -# -# store_igmp_v3_query ETH_SRC IP_SRC IP_CSUM OUTFILE -# -# This shell function builds an IGMPv3 general query from ETH_SRC and IP_SRC -# and stores the hexdump of the packet in OUTFILE. -# -store_igmp_v3_query() { - local eth_src=$1 ip_src=$2 ip_chksum=$3 outfile=$4 - - local eth_dst=01005e000001 - local ip_dst=$(ip_to_hex 224 0 0 1) - local ip_ttl=01 - local igmp_type=11 - local max_resp=0a - local igmp_chksum=eeeb - local addr=00000000 - - local eth=${eth_dst}${eth_src}0800 - local ip=4500002000004000${ip_ttl}02${ip_chksum}${ip_src}${ip_dst} - local igmp=${igmp_type}${max_resp}${igmp_chksum}${addr}000a0000 - local packet=${eth}${ip}${igmp} - - echo ${packet} >> ${outfile} -} - -# -# send_ip_multicast_pkt INPORT HV ETH_SRC ETH_DST IP_SRC IP_DST IP_LEN TTL -# IP_CHKSUM IP_PROTO DATA -# -# This shell function causes an IP multicast packet to be received on INPORT -# of HV. -# The hexdump of the packet is stored in OUTFILE. -# -send_ip_multicast_pkt() { - local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 - local ip_src=$5 ip_dst=$6 ip_len=$7 ip_ttl=$8 ip_chksum=$9 proto=${10} - local data=${11} - - local eth=${eth_dst}${eth_src}0800 - local ip=450000${ip_len}95f14000${ip_ttl}${proto}${ip_chksum}${ip_src}${ip_dst} - local packet=${eth}${ip}${data} - - check as $hv ovs-appctl netdev-dummy/receive ${inport} ${packet} -} - -# -# store_ip_multicast_pkt ETH_SRC ETH_DST IP_SRC IP_DST IP_LEN TTL -# IP_CHKSUM IP_PROTO DATA OUTFILE -# -# This shell function builds an IP multicast packet and stores the hexdump of -# the packet in OUTFILE. -# -store_ip_multicast_pkt() { - local eth_src=$1 eth_dst=$2 - local ip_src=$3 ip_dst=$4 ip_len=$5 ip_ttl=$6 ip_chksum=$7 proto=$8 - local data=$9 outfile=${10} - - local eth=${eth_dst}${eth_src}0800 - local ip=450000${ip_len}95f14000${ip_ttl}${proto}${ip_chksum}${ip_src}${ip_dst} - local packet=${eth}${ip}${data} - - echo ${packet} >> ${outfile} -} - check ovn-nbctl ls-add sw1 \ -- lsp-add sw1 sw1-p1 @@ -19981,108 +19783,6 @@ options:rxq_pcap=dummy-rx.pcap options:rxq_pcap=${pcap_file}-rx.pcap } -# -# send_mld_v2_report INPORT HV ETH_SRC IP_SRC GROUP REC_TYPE -# MLD_CSUM OUTFILE -# -# This shell function causes an MLDv2 report to be received on INPORT of HV. -# The packet's content has Ethernet destination 33:33:00:00:00:16 and source -# ETH_SRC (exactly 12 hex digits). Ethernet type is set to IPv6. -# GROUP is the IPv6 multicast group to be joined/to leave (based on REC_TYPE). -# REC_TYPE == 04: join GROUP -# REC_TYPE == 03: leave GROUP -# The packet hexdump is also stored in OUTFILE. -# -send_mld_v2_report() { - local inport=$1 hv=$2 eth_src=$3 ip_src=$4 group=$5 - local rec_type=$6 mld_chksum=$7 outfile=$8 - - local eth_dst=333300000016 - local ip_dst=ff020000000000000000000000000016 - local ip_ttl=01 - local ip_ra_opt=3a00050200000100 - - local mld_type=8f - local mld_code=00 - local num_rec=0001 - local aux_dlen=00 - local num_src=0000 - - local eth=${eth_dst}${eth_src}86dd - local ip=60000000002400${ip_ttl}${ip_src}${ip_dst}${ip_ra_opt} - local mld=${mld_type}${mld_code}${mld_chksum}0000${num_rec}${rec_type}${aux_dlen}${num_src}${group} - local packet=${eth}${ip}${mld} - - echo ${packet} >> ${outfile} - check as $hv ovs-appctl netdev-dummy/receive ${inport} ${packet} -} - -# -# store_mld_query ETH_SRC IP_SRC OUTFILE -# -# This shell function builds an MLD general query from ETH_SRC and IP_SRC -# and stores the hexdump of the packet in OUTFILE. -# -store_mld_query() { - local eth_src=$1 ip_src=$2 outfile=$3 - - local eth_dst=333300000000 - local ip_dst=ff020000000000000000000000000001 - local ip_ttl=01 - local ip_ra_opt=3a00050200000000 - - local mld_type=82 - local mld_code=00 - local max_resp=03e8 - local mld_chksum=7b3d - local addr=00000000000000000000000000000000 - - local eth=${eth_dst}${eth_src}86dd - local ip=60000000002400${ip_ttl}${ip_src}${ip_dst}${ip_ra_opt} - local mld=${mld_type}${mld_code}${mld_chksum}${max_resp}0000${addr}00010000 - local packet=${eth}${ip}${mld} - - echo ${packet} >> ${outfile} -} - -# -# send_ip_multicast_pkt INPORT HV ETH_SRC ETH_DST IP_SRC IP_DST IP_LEN TTL -# IP_PROTO DATA -# -# This shell function causes an IP multicast packet to be received on INPORT -# of HV. -# -send_ip_multicast_pkt() { - local inport=$1 hv=$2 eth_src=$3 eth_dst=$4 - local ip_src=$5 ip_dst=$6 ip_len=$7 ip_ttl=$8 proto=$9 - local data=${10} - - local eth=${eth_dst}${eth_src}86dd - local ip=60000000${ip_len}${proto}${ip_ttl}${ip_src}${ip_dst} - local packet=${eth}${ip}${data} - - check as $hv ovs-appctl netdev-dummy/receive ${inport} ${packet} -} - -# -# store_ip_multicast_pkt ETH_SRC ETH_DST IP_SRC IP_DST IP_LEN TTL -# IP_PROTO DATA OUTFILE -# -# This shell function builds an IP multicast packet and stores the hexdump of -# the packet in OUTFILE. -# -store_ip_multicast_pkt() { - local eth_src=$1 eth_dst=$2 - local ip_src=$3 ip_dst=$4 ip_len=$5 ip_ttl=$6 proto=$7 - local data=$8 outfile=$9 - - local eth=${eth_dst}${eth_src}86dd - local ip=60000000${ip_len}${proto}${ip_ttl}${ip_src}${ip_dst} - local packet=${eth}${ip}${data} - - echo ${packet} >> ${outfile} -} - check ovn-nbctl ls-add sw1 check ovn-nbctl ls-add sw2 check ovn-nbctl ls-add sw3 @@ -20257,13 +19957,13 @@ ovn-sbctl dump-flows > sbflows3 # joined. > expected > expected_empty -send_ip_multicast_pkt hv1-vif2 hv1 \ +send_ip6_multicast_pkt hv1-vif2 hv1 \ 000000000001 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ 93407a69000e1b5e61736461640a -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000001 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ @@ -20293,13 +19993,13 @@ as hv1 reset_pcap_file hv1-vif1 hv1/vif1 as hv2 reset_pcap_file hv2-vif1 hv2/vif1 > expected > expected_empty -send_ip_multicast_pkt hv1-vif2 hv1 \ +send_ip6_multicast_pkt hv1-vif2 hv1 \ 000000000001 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ 93407a69000e1b5e61736461640a -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000001 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ @@ -20336,12 +20036,12 @@ as hv1 reset_pcap_file hv1-vif2 hv1/vif2 as hv2 reset_pcap_file hv2-vif1 hv2/vif1 as hv2 reset_pcap_file hv2-vif2 hv2/vif2 > expected -send_ip_multicast_pkt hv1-vif2 hv1 \ +send_ip6_multicast_pkt hv1-vif2 hv1 \ 000000000001 333300000001 \ 10000000000000000000000000000042 ff020000000000000000000000000001 \ 000e 01 11 \ 93407a69000eb90361736461640a -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000001 333300000001 \ 10000000000000000000000000000042 ff020000000000000000000000000001 \ 000e 01 11 \ @@ -20410,7 +20110,7 @@ as hv2 reset_pcap_file hv2-vif2 hv2/vif2 as hv2 reset_pcap_file hv2-vif3 hv2/vif3 as hv2 reset_pcap_file hv2-vif4 hv2/vif4 -send_ip_multicast_pkt hv2-vif4 hv2 \ +send_ip6_multicast_pkt hv2-vif4 hv2 \ 000000000001 333300000001 \ 00100000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 02 11 \ @@ -20465,18 +20165,18 @@ as hv2 reset_pcap_file hv2-vif2 hv2/vif2 as hv2 reset_pcap_file hv2-vif3 hv2/vif3 as hv2 reset_pcap_file hv2-vif4 hv2/vif4 -send_ip_multicast_pkt hv2-vif4 hv2 \ +send_ip6_multicast_pkt hv2-vif4 hv2 \ 000000000001 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 02 11 \ 93407a69000e1b5e61736461640a -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000100 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ 93407a69000e1b5e61736461640a \ expected_routed_sw1 -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000200 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ @@ -20520,24 +20220,24 @@ as hv2 reset_pcap_file hv2-vif2 hv2/vif2 as hv2 reset_pcap_file hv2-vif3 hv2/vif3 as hv2 reset_pcap_file hv2-vif4 hv2/vif4 -send_ip_multicast_pkt hv2-vif4 hv2 \ +send_ip6_multicast_pkt hv2-vif4 hv2 \ 000000000001 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 02 11 \ 93407a69000e1b5e61736461640a -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000100 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ 93407a69000e1b5e61736461640a \ expected_routed_sw1 -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000200 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ 93407a69000e1b5e61736461640a \ expected_routed_sw2 -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000001 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 02 11 \ @@ -20547,13 +20247,13 @@ store_ip_multicast_pkt \ # TODO: MLD Relay duplicates IP multicast packets in some conditions, for # more details see TODO.rst, section "IP Multicast Relay". Once that issue is # fixed the duplicated packets should not appear anymore. -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000100 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ 93407a69000e1b5e61736461640a \ expected_routed_sw1 -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000200 333300000001 \ 10000000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ @@ -20614,18 +20314,18 @@ wait_row_count IGMP_Group 1 address='"ff0a:dead:beef::1"' check ovn-nbctl --wait=hv sync # Send traffic from sw1-p21 -send_ip_multicast_pkt hv2-vif1 hv2 \ +send_ip6_multicast_pkt hv2-vif1 hv2 \ 000000000001 333300000001 \ 00100000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 02 11 \ 93407a69000e2b4e61736461640a -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000001 333300000001 \ 00100000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 02 11 \ 93407a69000e2b4e61736461640a \ expected_switched -store_ip_multicast_pkt \ +store_ip6_multicast_pkt \ 000000000200 333300000001 \ 00100000000000000000000000000042 ff0adeadbeef00000000000000000001 \ 000e 01 11 \ From patchwork Wed Jan 19 13:39:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1581782 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=Gg7etcLl; 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 4Jf6GF0jsTz9tD5 for ; Thu, 20 Jan 2022 00:40:21 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id EF5BC4091A; Wed, 19 Jan 2022 13:40:18 +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 tZy8wD0bYZ41; Wed, 19 Jan 2022 13:40:17 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 585364052F; Wed, 19 Jan 2022 13:40:16 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 103DDC0039; Wed, 19 Jan 2022 13:40:16 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1006AC002F for ; Wed, 19 Jan 2022 13:40:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 80351404E0 for ; Wed, 19 Jan 2022 13:40:08 +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 4FS1xYIEpYFg for ; Wed, 19 Jan 2022 13:40:07 +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 224914091B for ; Wed, 19 Jan 2022 13:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642599605; 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=nmO3DaHhG5zVIcrIOYj1jIC5IM3gtJjWzCgmZ8NA2oA=; b=Gg7etcLlmDO1BNYP6ItAGsmT3boW6GkLpnJ5Se94l+OFs6YBbPUzfLKT4gqoKReDhnvqEZ +H6uj4eTvceeLuvDNRtTYQ9BBbsO3td7cmZ39PD0KAIcIDJlUdbTEu/y6sdKG5BGvwoP2I LZE1WYss2OAkLV62dqC/geRkuLwO/OE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-558-EFuISD36NUesmjnhpQbTkg-1; Wed, 19 Jan 2022 08:39:46 -0500 X-MC-Unique: EFuISD36NUesmjnhpQbTkg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E2193482D; Wed, 19 Jan 2022 13:39:45 +0000 (UTC) Received: from dceara.remote.csb (unknown [10.39.192.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C0F5105B1F4; Wed, 19 Jan 2022 13:39:44 +0000 (UTC) From: Dumitru Ceara To: ovs-dev@openvswitch.org Date: Wed, 19 Jan 2022 14:39:41 +0100 Message-Id: <20220119133939.25792.84110.stgit@dceara.remote.csb> In-Reply-To: <20220119133906.25792.90079.stgit@dceara.remote.csb> References: <20220119133906.25792.90079.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 2/2] ovn-ic: physical: Support multicast_group flooding on IC transit switches. 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" Forwarding on logical patch ports that are part of a multicast group normally happens on the local chassis. With interconnect transit switch, however, this doesn't work properly because patch ports in the local AZ might not correspond to patch ports in the remote AZ. This allows forwarding IP multicast traffic across different AZs when the gateway routers in each AZ are configured to relay multicast and to unconditionally flood on the gateway ports connected to the transit switch. This patch also adds a unit test to cover this scenario. This is not really a feature, just a case that was missed due to the fact that OVN-IC [0] and static IP multicast flood configuration [1] were developed more or less at the same time. [0] a3e4436c232 ("ovn-ic: Interconnection port controller.") [1] 79308138891a ("ovn-northd: Add static IP multicast flood configuration") Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=2028981 Signed-off-by: Dumitru Ceara --- controller/local_data.c | 1 controller/local_data.h | 1 controller/physical.c | 20 +++++ lib/ovn-util.c | 6 ++ lib/ovn-util.h | 1 northd/northd.c | 6 ++ tests/ovn.at | 174 +++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 206 insertions(+), 3 deletions(-) diff --git a/controller/local_data.c b/controller/local_data.c index 86050f335..1857bfd1b 100644 --- a/controller/local_data.c +++ b/controller/local_data.c @@ -67,6 +67,7 @@ local_datapath_alloc(const struct sbrec_datapath_binding *dp) struct local_datapath *ld = xzalloc(sizeof *ld); ld->datapath = dp; ld->is_switch = datapath_is_switch(dp); + ld->is_transit_switch = datapath_is_transit_switch(dp); shash_init(&ld->external_ports); /* memory accounting - common part. */ local_datapath_usage += sizeof *ld; diff --git a/controller/local_data.h b/controller/local_data.h index 287f95af0..9306ddf15 100644 --- a/controller/local_data.h +++ b/controller/local_data.h @@ -44,6 +44,7 @@ struct local_datapath { struct hmap_node hmap_node; const struct sbrec_datapath_binding *datapath; bool is_switch; + bool is_transit_switch; /* The localnet port in this datapath, if any (at most one is allowed). */ const struct sbrec_port_binding *localnet_port; diff --git a/controller/physical.c b/controller/physical.c index aa651b876..6bfa2304d 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -1421,7 +1421,8 @@ consider_mc_group(struct ovsdb_idl_index *sbrec_port_binding_by_name, struct ovn_desired_flow_table *flow_table) { uint32_t dp_key = mc->datapath->tunnel_key; - if (!get_local_datapath(local_datapaths, dp_key)) { + struct local_datapath *ldp = get_local_datapath(local_datapaths, dp_key); + if (!ldp) { return; } @@ -1444,7 +1445,10 @@ consider_mc_group(struct ovsdb_idl_index *sbrec_port_binding_by_name, * - For logical patch ports, add actions to 'remote_ofpacts' * instead. (If we put them in 'ofpacts', then the output * would happen on every hypervisor in the multicast group, - * effectively duplicating the packet.) + * effectively duplicating the packet.) The only exception + * is in case of transit switches (used by OVN-IC). We need + * patch ports to be processed on the remote side, after + * crossing the AZ boundary. * * - For chassisredirect ports, add actions to 'ofpacts' to * set the output port to be the router patch port for which @@ -1473,7 +1477,17 @@ consider_mc_group(struct ovsdb_idl_index *sbrec_port_binding_by_name, const char *lport_name = (port->parent_port && *port->parent_port) ? port->parent_port : port->logical_port; - if (!strcmp(port->type, "patch") || !strcmp(port->type, "localport")) { + if (!strcmp(port->type, "patch")) { + if (ldp->is_transit_switch) { + put_load(port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, + &ofpacts); + put_resubmit(OFTABLE_CHECK_LOOPBACK, &ofpacts); + } else { + put_load(port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, + &remote_ofpacts); + put_resubmit(OFTABLE_CHECK_LOOPBACK, &remote_ofpacts); + } + } else if (!strcmp(port->type, "localport")) { put_load(port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, &remote_ofpacts); put_resubmit(OFTABLE_CHECK_LOOPBACK, &remote_ofpacts); diff --git a/lib/ovn-util.c b/lib/ovn-util.c index c3da413aa..e6d0f7356 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -565,6 +565,12 @@ datapath_is_switch(const struct sbrec_datapath_binding *ldp) return smap_get(&ldp->external_ids, "logical-switch") != NULL; } +bool +datapath_is_transit_switch(const struct sbrec_datapath_binding *ldp) +{ + return smap_get(&ldp->external_ids, "interconn-ts") != NULL; +} + int datapath_snat_ct_zone(const struct sbrec_datapath_binding *dp) { diff --git a/lib/ovn-util.h b/lib/ovn-util.h index b212c64b7..743d28745 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -118,6 +118,7 @@ uint32_t ovn_logical_flow_hash(uint8_t table_id, enum ovn_pipeline pipeline, uint32_t ovn_logical_flow_hash_datapath(const struct uuid *logical_datapath, uint32_t hash); bool datapath_is_switch(const struct sbrec_datapath_binding *); +bool datapath_is_transit_switch(const struct sbrec_datapath_binding *ldp); int datapath_snat_ct_zone(const struct sbrec_datapath_binding *ldp); void ovn_conn_show(struct unixctl_conn *conn, int argc OVS_UNUSED, const char *argv[] OVS_UNUSED, void *idl_); diff --git a/northd/northd.c b/northd/northd.c index c714227b2..ecda98979 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -4289,6 +4289,12 @@ static void ovn_multicast_add(struct hmap *mcgroups, const struct multicast_group *group, struct ovn_port *port) { + /* Store the chassis redirect port otherwise traffic will not be tunneled + * properly. + */ + if (port->cr_port) { + port = port->cr_port; + } ovn_multicast_add_ports(mcgroups, port->od, group, &port, 1); } diff --git a/tests/ovn.at b/tests/ovn.at index ad08a7d63..957eb7850 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -22570,6 +22570,180 @@ OVN_CLEANUP_IC AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD([ +AT_SETUP([interconnection - static multicast]) + +# Logical network: +# +# AZ1 | AZ2 +# --------------------------------------------------------------------- +# | +# | +-- LR2 --- LS2 --- LSP2 (sender) +# | / +# LSP1 --- LS1 --- LR1 --- TS --- +# (receiver) | \ +# | +-- LR3 --- LS3 --- LSP3 (receiver) +# +# LS1, LS2, LS3 configured to flood unregistered IP multicast. +# LR1, LR2, LR3 configured to relay IP multicast. +# LR1-LS1 configured to flood IP multicast traffic unconditionally. +# LR3-LS3 configured to flood IP multicast traffic unconditionally. + +AT_CAPTURE_FILE([exp]) +AT_CAPTURE_FILE([rcv]) +check_packets() { + > exp + > rcv + if test "$1" = --uniq; then + sort="sort -u"; shift + else + sort=sort + fi + for tuple in "$@"; do + set $tuple; pcap=$1 type=$2 + echo "--- $pcap" | tee -a exp >> rcv + $sort "$type" >> exp + $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $pcap | $sort >> rcv + echo | tee -a exp >> rcv + done + + $at_diff exp rcv >/dev/null +} + +ovn_init_ic_db +ovn_start az1 +ovn_start az2 + +net_add n1 + +sim_add hv1 +as hv1 +check ovs-vsctl add-br br-phys +ovn_az_attach az1 n1 br-phys 192.168.1.1 16 +check ovs-vsctl -- add-port br-int hv1-vif1 \ + -- set interface hv1-vif1 external-ids:iface-id=lsp1 \ + options:tx_pcap=hv1/vif1-tx.pcap \ + options:rxq_pcap=hv1/vif1-rx.pcap +check ovs-vsctl set open . external-ids:ovn-is-interconn=true + +sim_add hv2 +as hv2 +check ovs-vsctl add-br br-phys +ovn_az_attach az2 n1 br-phys 192.168.2.1 16 +check ovs-vsctl -- add-port br-int hv2-vif1 \ + -- set interface hv2-vif1 external-ids:iface-id=lsp2 \ + options:tx_pcap=hv2/vif1-tx.pcap \ + options:rxq_pcap=hv2/vif1-rx.pcap +check ovs-vsctl -- add-port br-int hv2-vif2 \ + -- set interface hv2-vif2 external-ids:iface-id=lsp3 \ + options:tx_pcap=hv2/vif2-tx.pcap \ + options:rxq_pcap=hv2/vif2-rx.pcap +check ovs-vsctl set open . external-ids:ovn-is-interconn=true + +AT_CHECK([ovn-ic-nbctl create Transit_Switch name=ts], [0], [ignore]) +check ovn_as az1 ovn-nbctl wait-until logical_switch ts +check ovn_as az2 ovn-nbctl wait-until logical_switch ts + +ovn_as az1 +check ovn-nbctl lr-add lr1 \ + -- lrp-add lr1 lr1-ts 00:00:00:01:00:01 42.42.42.1/24 \ + -- lrp-add lr1 lr1-ls1 00:00:00:01:01:00 43.43.43.1/24 \ + -- lrp-set-gateway-chassis lr1-ts hv1 +check ovn-nbctl ls-add ls1 \ + -- lsp-add ls1 ls1-lr1 \ + -- lsp-set-addresses ls1-lr1 router \ + -- lsp-set-type ls1-lr1 router \ + -- lsp-set-options ls1-lr1 router-port=lr1-ls1 \ + -- lsp-add ls1 lsp1 +check ovn-nbctl lsp-add ts ts-lr1 \ + -- lsp-set-addresses ts-lr1 router \ + -- lsp-set-type ts-lr1 router \ + -- lsp-set-options ts-lr1 router-port=lr1-ts +wait_for_ports_up + +ovn_as az2 +check ovn-nbctl lr-add lr2 \ + -- lrp-add lr2 lr2-ts 00:00:00:02:00:01 42.42.42.2/24 \ + -- lrp-add lr2 lr2-ls2 00:00:00:02:01:00 44.44.44.1/24 \ + -- lrp-set-gateway-chassis lr2-ts hv2 +check ovn-nbctl ls-add ls2 \ + -- lsp-add ls2 ls2-lr2 \ + -- lsp-set-addresses ls2-lr2 router \ + -- lsp-set-type ls2-lr2 router \ + -- lsp-set-options ls2-lr2 router-port=lr2-ls2 \ + -- lsp-add ls2 lsp2 +check ovn-nbctl lsp-add ts ts-lr2 \ + -- lsp-set-addresses ts-lr2 router \ + -- lsp-set-type ts-lr2 router \ + -- lsp-set-options ts-lr2 router-port=lr2-ts + +check ovn-nbctl lr-add lr3 \ + -- lrp-add lr3 lr3-ts 00:00:00:02:00:02 42.42.42.3/24 \ + -- lrp-add lr3 lr3-ls3 00:00:00:02:02:00 44.44.45.1/24 \ + -- lrp-set-gateway-chassis lr3-ts hv2 +check ovn-nbctl ls-add ls3 \ + -- lsp-add ls3 ls3-lr3 \ + -- lsp-set-addresses ls3-lr3 router \ + -- lsp-set-type ls3-lr3 router \ + -- lsp-set-options ls3-lr3 router-port=lr3-ls3 \ + -- lsp-add ls3 lsp3 +check ovn-nbctl lsp-add ts ts-lr3 \ + -- lsp-set-addresses ts-lr3 router \ + -- lsp-set-type ts-lr3 router \ + -- lsp-set-options ts-lr3 router-port=lr3-ts + +wait_for_ports_up + +dnl Enable unregistered IP multicast flooding and IP multicast relay. +ovn_as az1 +check ovn-nbctl set logical_switch ls1 other_config:mcast_snoop="true" \ + other_config:mcast_flood_unregistered="true" +check ovn-nbctl set logical_router lr1 options:mcast_relay="true" +check ovn-nbctl set logical_router_port lr1-ls1 options:mcast_flood="true" + +ovn_as az2 +check ovn-nbctl set logical_switch ls2 other_config:mcast_snoop="true" \ + other_config:mcast_flood_unregistered="true" +check ovn-nbctl set logical_router lr2 options:mcast_relay="true" +check ovn-nbctl set logical_router_port lr2-ts options:mcast_flood="true" +check ovn-nbctl set logical_switch ls3 other_config:mcast_snoop="true" \ + other_config:mcast_flood_unregistered="true" +check ovn-nbctl set logical_router lr3 options:mcast_relay="true" +check ovn-nbctl set logical_router_port lr3-ls3 options:mcast_flood="true" + +check ovn_as az1 ovn-nbctl --wait=hv sync +check ovn_as az2 ovn-nbctl --wait=hv sync + +# Pre-populate the hypervisors' ARP tables so that we don't lose any +# packets for ARP resolution (native tunneling doesn't queue packets +# for ARP resolution). +OVN_POPULATE_ARP + +# Send an IP multicast packet from lsp2, it should be forwarded +# statically to lsp1 and lsp3. +> expected_az1 +> expected_az2 +send_ip_multicast_pkt hv2-vif1 hv2 \ + 000000000001 01005e000144 \ + $(ip_to_hex 44 44 44 2) $(ip_to_hex 239 0 1 68) 1e 20 7c6b 11 \ + e518e518000aed350000 +store_ip_multicast_pkt \ + 000000010100 01005e000144 \ + $(ip_to_hex 44 44 44 2) $(ip_to_hex 239 0 1 68) 1e 1e 7e6b 11 \ + e518e518000aed350000 expected_az1 +store_ip_multicast_pkt \ + 000000020200 01005e000144 \ + $(ip_to_hex 44 44 44 2) $(ip_to_hex 239 0 1 68) 1e 1e 7e6b 11 \ + e518e518000aed350000 expected_az2 + +OVS_WAIT_UNTIL( + [check_packets 'hv1/vif1-tx.pcap expected_az1' \ + 'hv2/vif2-tx.pcap expected_az2'], + [$at_diff -F'^---' exp rcv]) + +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD([ AT_SETUP([ECMP static routes]) ovn_start