From patchwork Fri Jul 19 18:31:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1962603 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=RnA4jLsV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WQdYX6P8Gz1xrQ for ; Sat, 20 Jul 2024 04:31:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8C80A60894; Fri, 19 Jul 2024 18:31:42 +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 7y26IOqN5qjS; Fri, 19 Jul 2024 18:31:40 +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 smtp3.osuosl.org 599AD607E1 Authentication-Results: smtp3.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=RnA4jLsV Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 599AD607E1; Fri, 19 Jul 2024 18:31:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1ED8AC0A97; Fri, 19 Jul 2024 18:31:40 +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 DB7D2C0A96 for ; Fri, 19 Jul 2024 18:31:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id B638140CB7 for ; Fri, 19 Jul 2024 18:31:38 +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 r2Ng2Eclj6ZQ for ; Fri, 19 Jul 2024 18:31:37 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=mkp@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 5C59F40C77 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 5C59F40C77 Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RnA4jLsV 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 5C59F40C77 for ; Fri, 19 Jul 2024 18:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721413895; 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=J99uomxLWBea2ayhO3WSHHVOH2ZiO42YivU6xNZU6c4=; b=RnA4jLsV3ho09QYS8CSTAvbx/i8HqSglHqeJ1wfV/zFavyvlmlBCMCg5/8JE0ok/nnhr0e 9QAIA5cV/0B1Br0cNSmTskA6xMkG4UE88K/Let83iWV/PVWu6CsXPUH4UUy+4TPGtmsgPX 6RJjGJRL44KFPxpHe4v/4YWP+k/Q83c= Received: from mx-prod-mc-01.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-695-EhpF2OhIOYiwHvnK0sEDBg-1; Fri, 19 Jul 2024 14:31:33 -0400 X-MC-Unique: EhpF2OhIOYiwHvnK0sEDBg-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E43071955D44 for ; Fri, 19 Jul 2024 18:31:31 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.64.242]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D1AF11955D4A; Fri, 19 Jul 2024 18:31:30 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Fri, 19 Jul 2024 14:31:26 -0400 Message-Id: <20240719183126.187651-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2] 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 --- tests/tunnel.at | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/tunnel.at b/tests/tunnel.at index 31e935901..5a9d7663e 100644 --- a/tests/tunnel.at +++ b/tests/tunnel.at @@ -1362,3 +1362,69 @@ AT_CHECK_UNQUOTED([tail -1 stdout], [0], OVS_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([tunnel - Mirror over tunnels]) +OVS_VSWITCHD_START([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([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)' +]) + +flow="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)" + +dnl Verify packet is mirrored to both tunnels. Tunnel actions may happen in any order. +AT_CHECK([ovs-appctl ofproto/trace --names ovs-dummy "$flow"], [0], [stdout]) +AT_CHECK([grep -q '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),dnl +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)' stdout]) +AT_CHECK([grep -q '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),dnl +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)' stdout]) + +dnl Send a packet and then verify the contents. As with the previous test, tunneled packets can have any order. +AT_CHECK([ovs-appctl netdev-dummy/receive p1 'eth(src=aa:55:aa:55:00:00,dst=f8:bc:12:ff:ff:ff),eth_type(0x0800),ipv4(src=1.1.3.92,dst=1.1.3.88,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)']) +AT_CHECK([ovs-pcap ext.pcap > ext.pcap.txt 2>&1]) +AT_CHECK([cat ext.pcap.txt | tail -n 2 | sort], [0], [dnl +[f8bc124434b3aa55aa55000008004500008e00004000402f363b0101010301010102100088be000000001000000000000000f8bc12ffffffaa55aa55000008004500005c00000000]dnl +[400171ec0101035c0101035800001bfc00000000000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f30313233]dnl +[3435363738393a3b3c3d3e3f] +[f8bc124434b6aa55aa55000008004500008e000040004011365a0101010301010101897617c1007a00000000655800000000f8bc12ffffffaa55aa55000008004500005c00000000]dnl +[400171ec0101035c0101035800001bfc00000000000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f30313233]dnl +[3435363738393a3b3c3d3e3f] +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP