From patchwork Wed Aug 7 20:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1970260 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IXRB3g7T; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WfMq85hgJz1ydk for ; Thu, 8 Aug 2024 06:54:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 244B0406E3; Wed, 7 Aug 2024 20:54:11 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id tEyeWb0PrQ0d; Wed, 7 Aug 2024 20:54:09 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C261A406CE Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IXRB3g7T Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id C261A406CE; Wed, 7 Aug 2024 20:54:09 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A08CBC002B; Wed, 7 Aug 2024 20:54: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 AA5E7C002A for ; Wed, 7 Aug 2024 20:54:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A647F406D3 for ; Wed, 7 Aug 2024 20:54:08 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id EkmOSx5kkVra for ; Wed, 7 Aug 2024 20:54:08 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=mkp@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org C2F02406CE Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C2F02406CE 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 C2F02406CE for ; Wed, 7 Aug 2024 20:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723064046; 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; bh=f51pApWC0yTclT+tvNZmyAbUk9GRQHLFQip2ztJpBvs=; b=IXRB3g7T40o/DBOI3nodGElbtsgTcOWiCkysmeHcAI08EVqxIL9wBc56B2BhKb9ncjMJav ZtMI8dI8dqYoAf273QkpiHSvpyk2Fg2EDqfkR9/1Xg8OwzK0R2nEIenu/51tkbsQ4KW1Et m6j5BbmPdwLJEBgC/u9aGIA6aWYvNBo= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-UvO8F11bPsS6EyO1DMnaaA-1; Wed, 07 Aug 2024 16:54:05 -0400 X-MC-Unique: UvO8F11bPsS6EyO1DMnaaA-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 970701944B2C for ; Wed, 7 Aug 2024 20:54:04 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.16.22]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 870AC1956089; Wed, 7 Aug 2024 20:54:03 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Wed, 7 Aug 2024 16:53:58 -0400 Message-ID: <20240807205359.1058331-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v3 1/2] ofproto-dpif-xlate: Add a recursion limit to tunnel address lookup. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" In deployments with multiple tunnels, it can be possible to enter an infinite loop where traffic generates an arp/nd lookup which is forwarded to a different tunnel, generating a new arp/nd packet that is send back to the first tunnel. Now the depth counter is incremented for new arp/nd packets, just as happens in xlate_table_action(). Signed-off-by: Mike Pattrick --- ofproto/ofproto-dpif-xlate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 850597b3a..887893417 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -679,6 +679,7 @@ static size_t count_skb_priorities(const struct xport *); static bool dscp_from_skb_priority(const struct xport *, uint32_t skb_priority, uint8_t *dscp); +static bool xlate_resubmit_resource_check(struct xlate_ctx *ctx); static void xlate_xbridge_init(struct xlate_cfg *, struct xbridge *); static void xlate_xbundle_init(struct xlate_cfg *, struct xbundle *); static void xlate_xport_init(struct xlate_cfg *, struct xport *); @@ -3723,6 +3724,10 @@ compose_table_xlate(struct xlate_ctx *ctx, const struct xport *out_dev, struct ofpact_output output; struct flow flow; + if (!xlate_resubmit_resource_check(ctx)) { + return 0; + } + ofpact_init(&output.ofpact, OFPACT_OUTPUT, sizeof output); flow_extract(packet, &flow); flow.in_port.ofp_port = out_dev->ofp_port; @@ -3731,7 +3736,8 @@ compose_table_xlate(struct xlate_ctx *ctx, const struct xport *out_dev, return ofproto_dpif_execute_actions__(xbridge->ofproto, version, &flow, NULL, &output.ofpact, sizeof output, - ctx->depth, ctx->resubmits, packet); + ctx->depth + 1, ctx->resubmits, + packet); } static void From patchwork Wed Aug 7 20:53:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1970261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ip/JkNGu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WfMqP28Ydz1ydk for ; Thu, 8 Aug 2024 06:54:25 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C25A3814B3; Wed, 7 Aug 2024 20:54:23 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id etddP_24aX-Q; Wed, 7 Aug 2024 20:54:21 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4FBEB8146B Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ip/JkNGu Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4FBEB8146B; Wed, 7 Aug 2024 20:54:20 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C4C19C002B; Wed, 7 Aug 2024 20:54:20 +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 1714AC002A for ; Wed, 7 Aug 2024 20:54:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9307B60805 for ; Wed, 7 Aug 2024 20:54:16 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id fQEaXEpZlcuG for ; Wed, 7 Aug 2024 20:54:11 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=mkp@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 96EBD606C0 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 96EBD606C0 Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ip/JkNGu 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 96EBD606C0 for ; Wed, 7 Aug 2024 20:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723064050; 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=IY1W95MX7YAQjUgjia1iq+zBt/ySzVObzgT1cKvgrR4=; b=ip/JkNGuh3nAHkow8Ok4BhBMHVqoQXCyyr1XQ6SJ0A/OqFsUd8zIltshFuQ8N8jtymg3+Q FD06Z3B947FzBi6obhXOIxwcX/hjfqNp1JTySlZQnyf7mX7zLMf6gmEIr1IC8R2ooDDPGY D3uwtIxO4yZ0fz86J62yotWQ5hNYZC8= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-mtz654utMCaZPOJt9zH8tw-1; Wed, 07 Aug 2024 16:54:06 -0400 X-MC-Unique: mtz654utMCaZPOJt9zH8tw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 664BA1955BC1 for ; Wed, 7 Aug 2024 20:54:05 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.16.22]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A3AB21956089; Wed, 7 Aug 2024 20:54:04 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Wed, 7 Aug 2024 16:53:59 -0400 Message-ID: <20240807205359.1058331-2-mkp@redhat.com> In-Reply-To: <20240807205359.1058331-1-mkp@redhat.com> References: <20240807205359.1058331-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v3 2/2] tunnel, tests: Add test for mirroring over tunnels. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Add a new test for mirroring packets over a tunnel, which isn't covered by other existing tests. Signed-off-by: Mike Pattrick --- v2: fixed test by pinning port v3: moved tests and added ipv6 test --- tests/tunnel-push-pop-ipv6.at | 83 +++++++++++++++++++++++++++++++++++ tests/tunnel-push-pop.at | 79 +++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) diff --git a/tests/tunnel-push-pop-ipv6.at b/tests/tunnel-push-pop-ipv6.at index 3edec5fbc..f4338a920 100644 --- a/tests/tunnel-push-pop-ipv6.at +++ b/tests/tunnel-push-pop-ipv6.at @@ -825,3 +825,86 @@ hash(l4(0)),recirc(0x2) OVS_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([tunnel_push_pop_ipv6 - Mirror over tunnels]) +OVS_VSWITCHD_START([dnl + add-br br-ext -- set bridge br-ext datapath_type=dummy \ + -- set bridge br-ext other-config:hwaddr=aa:55:aa:55:00:00 \ + -- add-port br0 t1 -- set Interface t1 type=geneve \ + options:remote_ip=2001:cafe::91 \ + -- add-port br0 t2 -- set Interface t2 type=erspan \ + options:remote_ip=2001:cafe::92 options:key=flow \ + options:erspan_ver=1 options:erspan_idx=flow \ + -- add-port br0 p0 -- set Interface p0 type=dummy \ + -- add-port br0 p1 -- set Interface p1 type=dummy \ + -- add-port br-ext p-ext -- set Interface p-ext type=dummy \ + options:pcap=ext.pcap]) + +dnl Configure mirroring over the UDP and ERSPAN tunnels. +AT_CHECK([dnl + ovs-vsctl \ + set Bridge br0 mirrors=@m1,@m2 -- \ + --id=@t1 get Port t1 -- \ + --id=@t2 get Port t2 -- \ + --id=@m1 create Mirror name=vxlan select_all=true output_port=@t1 -- \ + --id=@m2 create Mirror name=erspan select_all=true output_port=@t2], + [0], [stdout]) + +AT_CHECK([ovs-ofctl add-flow br-ext actions=normal]) +AT_CHECK([ovs-ofctl add-flow br0 actions=normal]) + +dnl Make sure ephemeral ports stay static across tests. +AT_CHECK([ovs-appctl tnl/egress_port_range 35190 35190], [0], [OK +]) + +dnl Setup an IP address. +AT_CHECK([ovs-appctl netdev-dummy/ip6addr br-ext 2001:cafe::90/64], [0], [OK +]) + +dnl Send two ND packets to set the tunnel's port and mac address. +AT_CHECK([ovs-appctl netdev-dummy/receive p-ext dnl + 'eth(src=f8:bc:12:44:34:b3,dst=aa:55:aa:55:00:00),eth_type(0x86dd),dnl + ipv6(src=2001:cafe::91,dst=2001:cafe::90,label=0,proto=58,tclass=0,hlimit=255,frag=no),dnl + icmpv6(type=136,code=0),dnl + nd(target=2001:cafe::91,sll=00:00:00:00:00:00,tll=f8:bc:12:44:34:b3)' +]) +AT_CHECK([ovs-appctl netdev-dummy/receive p-ext dnl + 'eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x86dd),dnl + ipv6(src=2001:cafe::92,dst=2001:cafe::90,label=0,proto=58,tclass=0,hlimit=255,frag=no),dnl + icmpv6(type=136,code=0),dnl + nd(target=2001:cafe::92,sll=00:00:00:00:00:00,tll=f8:bc:12:44:34:b6)' +]) + +m4_define([FLOW], [m4_join([,], + [in_port(p1)], + [eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800)], + [ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no)], + [icmp(type=8,code=0)])]) + +m4_define([ERSPAN_ACT], [m4_join([,], + [clone(tnl_push(tnl_port(erspan_sys)], + [header(size=70,type=108], + [eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x86dd)], + [ipv6(src=2001:cafe::90,dst=2001:cafe::92,label=0,proto=47,tclass=0x0,hlimit=64)], + [erspan(ver=1,sid=0x0,idx=0x0))], + [out_port(br-ext))], + [p-ext)])]) + +m4_define([GENEVE_ACT], [m4_join([,], + [clone(tnl_push(tnl_port(genev_sys_6081)], + [header(size=70,type=5], + [eth(dst=f8:bc:12:44:34:b3,src=aa:55:aa:55:00:00,dl_type=0x86dd)], + [ipv6(src=2001:cafe::90,dst=2001:cafe::91,label=0,proto=17,tclass=0x0,hlimit=64)], + [udp(src=0,dst=6081,csum=0xffff)], + [geneve(vni=0x0))], + [out_port(br-ext))], + [p-ext)])]) + +dnl Verify packet is mirrored to both tunnels. Tunnel actions may happen +dnl in any order. +AT_CHECK([ovs-appctl ofproto/trace --names ovs-dummy "FLOW"], [0], [stdout]) +AT_CHECK([grep -q "ERSPAN_ACT" stdout]) +AT_CHECK([grep -q "GENEVE_ACT" stdout]) + +OVS_VSWITCHD_STOP +AT_CLEANUP diff --git a/tests/tunnel-push-pop.at b/tests/tunnel-push-pop.at index 7ec4c31ab..1107b035b 100644 --- a/tests/tunnel-push-pop.at +++ b/tests/tunnel-push-pop.at @@ -1259,3 +1259,82 @@ hash(l4(0)),recirc(0x2) OVS_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([tunnel_push_pop - Mirror over tunnels]) +OVS_VSWITCHD_START([dnl + add-br br-ext -- set bridge br-ext datapath_type=dummy \ + -- set bridge br-ext other-config:hwaddr=aa:55:aa:55:00:00 \ + -- add-port br0 t1 -- set Interface t1 type=geneve \ + options:remote_ip=1.1.1.1 \ + -- add-port br0 t2 -- set Interface t2 type=erspan \ + options:remote_ip=1.1.1.2 options:key=flow options:erspan_ver=1 \ + options:erspan_idx=flow \ + -- add-port br0 p0 -- set Interface p0 type=dummy \ + -- add-port br0 p1 -- set Interface p1 type=dummy \ + -- add-port br-ext p-ext -- set Interface p-ext type=dummy \ + options:pcap=ext.pcap]) + +dnl Configure mirroring over the UDP and ERSPAN tunnels. +AT_CHECK([dnl + ovs-vsctl \ + set Bridge br0 mirrors=@m1,@m2 -- \ + --id=@t1 get Port t1 -- \ + --id=@t2 get Port t2 -- \ + --id=@m1 create Mirror name=vxlan select_all=true output_port=@t1 -- \ + --id=@m2 create Mirror name=erspan select_all=true output_port=@t2], + [0], [stdout]) + +AT_CHECK([ovs-ofctl add-flow br-ext actions=normal]) +AT_CHECK([ovs-ofctl add-flow br0 actions=normal]) + +dnl Make sure ephemeral ports stay static across tests. +AT_CHECK([ovs-appctl tnl/egress_port_range 35190 35190], [0], [OK +]) + +dnl Setup an IP address for the local side of the tunnel. +AT_CHECK([ovs-appctl netdev-dummy/ip4addr br-ext 1.1.1.3/24], [0], [OK +]) + +dnl Send two arp replies to populate arp table with tunnel remote endpoints. +AT_CHECK([ovs-appctl netdev-dummy/receive p-ext dnl + 'eth(src=f8:bc:12:44:34:b6,dst=ff:ff:ff:ff:ff:ff),eth_type(0x0806),dnl + arp(sip=1.1.1.1,tip=1.1.1.3,op=2,sha=f8:bc:12:44:34:b6,tha=00:00:00:00:00:00)' +]) +AT_CHECK([ovs-appctl netdev-dummy/receive p-ext dnl + 'eth(src=f8:bc:12:44:34:b3,dst=ff:ff:ff:ff:ff:ff),eth_type(0x0806),dnl + arp(sip=1.1.1.2,tip=1.1.1.3,op=2,sha=f8:bc:12:44:34:b3,tha=00:00:00:00:00:00)' +]) + +m4_define([FLOW], [m4_join([,], + [in_port(p1)], + [eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800)], + [ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no)], + [icmp(type=8,code=0)])]) + +m4_define([ERSPAN_ACT], [m4_join([,], + [clone(tnl_push(tnl_port(erspan_sys)], + [header(size=50,type=107], + [eth(dst=f8:bc:12:44:34:b3,src=aa:55:aa:55:00:00,dl_type=0x0800)], + [ipv4(src=1.1.1.3,dst=1.1.1.2,proto=47,tos=0,ttl=64,frag=0x4000)], + [erspan(ver=1,sid=0x0,idx=0x0))], + [out_port(br-ext))], + [p-ext)])]) + +m4_define([GENEVE_ACT], [m4_join([,], + [clone(tnl_push(tnl_port(genev_sys_6081)], + [header(size=50,type=5], + [eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x0800)], + [ipv4(src=1.1.1.3,dst=1.1.1.1,proto=17,tos=0,ttl=64,frag=0x4000)], + [udp(src=0,dst=6081,csum=0x0)], + [geneve(vni=0x0))], + [out_port(br-ext))], + [p-ext)])]) + +dnl Verify packet is mirrored to both tunnels. Tunnel actions may happen +dnl in any order. +AT_CHECK([ovs-appctl ofproto/trace --names ovs-dummy "FLOW"], [0], [stdout]) +AT_CHECK([grep -q "ERSPAN_ACT" stdout]) +AT_CHECK([grep -q "GENEVE_ACT" stdout]) + +OVS_VSWITCHD_STOP +AT_CLEANUP