From patchwork Sat Oct 17 06:53:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 531649 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id D0402140F97 for ; Sat, 17 Oct 2015 17:53:49 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id A1CFE22C390; Fri, 16 Oct 2015 23:53:41 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v1.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 7839722C3AB for ; Fri, 16 Oct 2015 23:53:40 -0700 (PDT) Received: from bar4.cudamail.com (bar2 [192.168.15.2]) by mx3v1.cudamail.com (Postfix) with ESMTP id 04B2E6182D4 for ; Sat, 17 Oct 2015 00:53:40 -0600 (MDT) X-ASG-Debug-ID: 1445064819-03dc210f8d8b720001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar4.cudamail.com with ESMTP id WchSQnCXD7FgJ7cj (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 17 Oct 2015 00:53:39 -0600 (MDT) X-Barracuda-Envelope-From: blp@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mail-pa0-f41.google.com) (209.85.220.41) by mx3-pf3.cudamail.com with ESMTPS (RC4-SHA encrypted); 17 Oct 2015 06:53:39 -0000 Received-SPF: unknown (mx3-pf3.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.41 Received: by pabws5 with SMTP id ws5so10327350pab.1 for ; Fri, 16 Oct 2015 23:53:38 -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=oG6ezEYT53s9uF5x3uLrKhD9sKOKdeD+GjOGT4lWjyU=; b=coZwhZdfRXshOCLzKhvTwlvkcbXJ3QcUptNpw2njTGgJ7TgRWgx5vDUNxQj3YKlooa AFoaLAUHIeIcES7z9zx2OQHeeLuA3ONLIxgVc+EBrdDChQQO4wa1whAIOln9oMyIr31C IvEBMDQyB4ySyKz/hoAtL29x+8VsSqAtj4JyVov8Si1lj6B+jBcQHjHkU7bNnAI9/4Ap T14G5+ZMRMgnHFpH0GEL3JCcEofHYAUrUwlUtqIm4sMoWamW/LJwrrSaxHDHnOElRHvb DaFIQQZuiSgoeoHnzzjue6I4JYBHTKcPvGf0HXFqpVXiRf81erbp+i6mfXAb1jrYhYx+ dQLg== X-Gm-Message-State: ALoCoQmUixxK1FdzEYecfLmvmpbPLXx5A/zvyWED6f9LOmuIFnjvEG5/ZH4w7WyzLWoo3R2t3DXa X-Received: by 10.66.190.135 with SMTP id gq7mr21383218pac.65.1445064818845; Fri, 16 Oct 2015 23:53:38 -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 cs5sm24723520pbc.15.2015.10.16.23.53.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Oct 2015 23:53:37 -0700 (PDT) X-CudaMail-Envelope-Sender: blp@nicira.com X-Barracuda-Apparent-Source-IP: 173.228.112.197 From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V3-1016000527 X-CudaMail-DTE: 101715 X-CudaMail-Originating-IP: 209.85.220.41 Date: Fri, 16 Oct 2015 23:53:32 -0700 X-ASG-Orig-Subj: [##CM-V3-1016000527##][PATCH 3/3] ovn: Add test for logical router ARP replies. Message-Id: <1445064812-14120-3-git-send-email-blp@nicira.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1445064812-14120-1-git-send-email-blp@nicira.com> References: <1445064812-14120-1-git-send-email-blp@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1445064819 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 3/3] 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 --- tests/ovn.at | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 7 deletions(-) diff --git a/tests/ovn.at b/tests/ovn.at index c76b5dc..b149058 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