From patchwork Sat Oct 17 21:07:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 531879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 7A83E140DA8 for ; Sun, 18 Oct 2015 08:08:07 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 71FC610D30; Sat, 17 Oct 2015 14:08:01 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 230A110D25 for ; Sat, 17 Oct 2015 14:08:00 -0700 (PDT) Received: from bar2.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 9AF511E0074 for ; Sat, 17 Oct 2015 15:07:59 -0600 (MDT) X-ASG-Debug-ID: 1445116079-03dc53014e0eb50001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar2.cudamail.com with ESMTP id vDQ0EptheygyJGlr (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 17 Oct 2015 15:07:59 -0600 (MDT) X-Barracuda-Envelope-From: blp@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mail-pa0-f50.google.com) (209.85.220.50) by mx1-pf2.cudamail.com with ESMTPS (RC4-SHA encrypted); 17 Oct 2015 21:07:59 -0000 Received-SPF: unknown (mx1-pf2.cudamail.com: Multiple SPF records returned) X-Barracuda-Apparent-Source-IP: 209.85.220.50 X-Barracuda-RBL-IP: 209.85.220.50 Received: by pabws5 with SMTP id ws5so78443pab.2 for ; Sat, 17 Oct 2015 14:07:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EsaVvJpCPYDBkfLylXbkF3YUqUOpl0l89Zcyz4NqdEY=; b=IHQz8huHzlGLtJ8ngqU+NUZO3if9Tzu9uT5Z1SH/RMO2DB/PQspZs/a3zgE6JoGX4S LSPWG2HYfH+vEVuc9Oer99zkO0Osh4Qb8lyUPxiVqsrNoylg+wMG7JLxO2Z1Kq7h8Gj0 du84CcgH2uYD2YHjWFWD4clnalezZXw1nCMMLwoudjNSNGIgnmmEnR8u4JNZjNiZBIoF o6C+0iPJ2knh1+Apnj0gLWbZCQLboLhy6F8oY7Cw7ZXnh3ViX45hwMdSYAsdvkgA0P71 h+NlyxBRC9sgQGQv1vnbwhSWXu2ZxsuT2oTBBnjbWlakUb0etGXMS8j3AqqGZ2u47asW eR2A== X-Gm-Message-State: ALoCoQnPLXmaHkt2z4MAwVG1jlLL8BHU0ofs0bJSkDtoFN90dVmCkZVPynBGEWMmhrM6ctVKt/uC X-Received: by 10.68.57.129 with SMTP id i1mr24555836pbq.51.1445116078436; Sat, 17 Oct 2015 14:07:58 -0700 (PDT) Received: from sigabrt.gateway.sonic.net (173-228-112-197.dsl.dynamic.fusionbroadband.com. [173.228.112.197]) by smtp.gmail.com with ESMTPSA id pj10sm4755548pbc.59.2015.10.17.14.07.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Oct 2015 14:07:57 -0700 (PDT) X-CudaMail-Envelope-Sender: blp@nicira.com From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E2-1016029810 X-CudaMail-DTE: 101715 X-CudaMail-Originating-IP: 209.85.220.50 Date: Sat, 17 Oct 2015 14:07:43 -0700 X-ASG-Orig-Subj: [##CM-E2-1016029810##][PATCH v2 3/4] ovn: Add test for logical router ARP replies. Message-Id: <1445116064-20782-4-git-send-email-blp@nicira.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1445115992-16951-1-git-send-email-blp@nicira.com> References: <1445115992-16951-1-git-send-email-blp@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1445116079 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH v2 3/4] ovn: Add test for logical router ARP replies. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- tests/ovn.at | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 7 deletions(-) diff --git a/tests/ovn.at b/tests/ovn.at index c76b5dc..f72ca7a 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -886,6 +886,11 @@ vif_to_hv() { esac } +# Prints the first character of its argument, e.g. "vif_to_ls 12" yields 1. +vif_to_ls() { + echo $1 | sed 's/^\(.\).*/\1/' +} + net_add n1 for i in 1 2 3; do sim_add hv$i @@ -914,7 +919,7 @@ ovn_populate_arp # XXX This should be more systematic. sleep 1 -# test_packet INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... +# test_ip INPORT SRC_MAC DST_MAC SRC_IP DST_IP OUTPORT... # # This shell function causes a packet to be received on INPORT. The packet's # content has Ethernet destination DST and source SRC (each exactly 12 hex @@ -929,7 +934,7 @@ for i in 1 2 3; do : > $i$j.expected done done -test_packet() { +test_ip() { # This packet has bad checksums but logical L3 routing doesn't check. local inport=$1 src_mac=$2 dst_mac=$3 src_ip=$4 dst_ip=$5 local packet=$3$208004500001c0000000040110000$4$50035111100080000 @@ -938,8 +943,8 @@ test_packet() { as $hv ovs-appctl netdev-dummy/receive vif$inport $packet #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $packet for outport; do - ins=`echo $inport | sed 's/^\(.\).*/\1/'` - outs=`echo $outport | sed 's/^\(.\).*/\1/'` + ins=`vif_to_ls $inport` + outs=`vif_to_ls $outport` if test $ins = $outs; then # Ports on the same logical switch receive exactly the same packet. echo $packet @@ -951,10 +956,11 @@ test_packet() { done } +as hv1 ovs-vsctl --columns=name,ofport list interface as hv1 ovn-sbctl dump-flows as hv1 ovs-ofctl dump-flows br-int -# Send packets between all pairs of source and destination ports: +# Send IP packets between all pairs of source and destination ports: # # 1. Unicast IP packets are delivered to exactly one lport (except # that packets destined to their input ports are dropped). @@ -973,12 +979,69 @@ for is in 1 2 3; do if test $is = $id; then dmac=f000000000$d; else dmac=00000000ff0$is; fi if test $d != $s; then unicast=$d; else unicast=; fi - test_packet $s $smac $dmac $sip $dip $unicast #1 + test_ip $s $smac $dmac $sip $dip $unicast #1 if test $id = $is && test $jd != $js; then bcast="$bcast $d"; fi done done - test_packet $s $smac ffffffffffff $sip ffffffff $bcast #2 + test_ip $s $smac ffffffffffff $sip ffffffff $bcast #2 + done +done + +# test_arp INPORT SHA SPA TPA [REPLY_HA] +# +# Causes a packet to be received on INPORT. The packet is an ARP +# request with SHA, SPA, and TPA as specified. If REPLY_HA is provided, then +# it should be the hardware address of the target to expect to receive in an +# ARP reply; otherwise no reply is expected. +# +# INPORT is an lport number, e.g. 11 for vif11. +# SHA and REPLY_HA are each 12 hex digits. +# SPA and TPA are each 8 hex digits. +test_arp() { + local inport=$1 sha=$2 spa=$3 tpa=$4 reply_ha=$5 + local request=ffffffffffff${sha}08060001080006040001${sha}${spa}ffffffffffff${tpa} + hv=hv`vif_to_hv $inport` + as $hv ovs-appctl netdev-dummy/receive vif$inport $request + #as $hv ovs-appctl ofproto/trace br-int in_port=$inport $request + + # Expect to receive the broadcast ARP on the other logical switch ports. + # (OVN should probably suppress these.) + local i=`vif_to_ls $inport` + local j + for j in 1 2 3; do + if test $i$j != $inport; then + echo $request >> $i$j.expected + fi + done + + # Expect to receive the reply, if any. + if test X$reply_ha != X; then + local reply=${sha}00000000ff0${i}08060001080006040002${reply_ha}${tpa}${sha}${spa} + echo $reply >> $inport.expected + fi +} + +# Test router replies to ARP requests from all source ports: +# +# 3. Router replies to query for its MAC address from port's own IP address. +# +# 4. Router replies to query for its MAC address from any random IP address +# in its subnet. +# +# 5. Router replies to query for its MAC address from another subnet. +# +# 6. No reply to query for IP address other than router IP. +for i in 1 2 3; do + for j in 1 2 3; do + smac=f000000000$i$j # Source MAC + sip=c0a80${i}0${j} # Source IP + rip=c0a80${i}fe # Router IP + rmac=00000000ff0$i # Router MAC + test_arp $i$j $smac $sip $rip $rmac #3 + test_arp $i$j $smac c0a80${i}55 $rip $rmac #4 + test_arp $i$j $smac 0a123456 $rip $rmac #5 + test_arp $i$j $smac $sip c0a80${i}aa #6 done done