From patchwork Wed Nov 25 13:31:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 548562 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 127631402E2 for ; Thu, 26 Nov 2015 00:33:02 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 0C4C910B74; Wed, 25 Nov 2015 05:31:56 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 7AB8B10B85 for ; Wed, 25 Nov 2015 05:31:55 -0800 (PST) Received: from bar2.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 06BA6420098 for ; Wed, 25 Nov 2015 06:31:55 -0700 (MST) X-ASG-Debug-ID: 1448458312-03dc5332c5151d50001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar2.cudamail.com with ESMTP id FfPkFgcLgGLjCXbh (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 25 Nov 2015 06:31:52 -0700 (MST) X-Barracuda-Envelope-From: cascardo@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 25 Nov 2015 13:31:52 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-Barracuda-RBL-IP: 209.132.183.28 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 9E4DD935F0 for ; Wed, 25 Nov 2015 13:31:51 +0000 (UTC) Received: from indiana.gru.redhat.com (ovpn-113-86.phx2.redhat.com [10.3.113.86]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAPDVREF029492 for ; Wed, 25 Nov 2015 08:31:50 -0500 X-CudaMail-Envelope-Sender: cascardo@redhat.com From: Thadeu Lima de Souza Cascardo To: dev@openvswitch.org X-CudaMail-MID: CM-E2-1124016396 X-CudaMail-DTE: 112515 X-CudaMail-Originating-IP: 209.132.183.28 Date: Wed, 25 Nov 2015 11:31:17 -0200 X-ASG-Orig-Subj: [##CM-E2-1124016396##][PATCH v2 14/14] tests: Add tunnel-push-pop-ipv6 tests Message-Id: <1448458277-28154-15-git-send-email-cascardo@redhat.com> In-Reply-To: <1448458277-28154-1-git-send-email-cascardo@redhat.com> References: <1448458277-28154-1-git-send-email-cascardo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-GBUdb-Analysis: 0, 209.132.183.28, Ugly c=0.279065 p=-0.2 Source Normal X-MessageSniffer-Rules: 0-0-0-27864-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1448458312 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 1.10 X-Barracuda-Spam-Status: No, SCORE=1.10 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_RULE_7582B, BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.24709 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE_7582B Custom Rule 7582B 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH v2 14/14] tests: Add tunnel-push-pop-ipv6 tests 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" Based on IPv4 tests, test tunnels over IPv6. In order to do that, add netdev-dummy/ip6addr command for dummy bridges, and get_in6 support for netdev-dummy as well. Signed-off-by: Thadeu Lima de Souza Cascardo --- lib/netdev-dummy.c | 58 +++++++++++++++- tests/automake.mk | 1 + tests/testsuite.at | 1 + tests/tunnel-push-pop-ipv6.at | 153 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 tests/tunnel-push-pop-ipv6.at diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c index 76815c2..7c63a99 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -116,6 +116,7 @@ struct netdev_dummy { FILE *tx_pcap, *rxq_pcap OVS_GUARDED; struct in_addr address, netmask; + struct in6_addr ipv6; struct ovs_list rxes OVS_GUARDED; /* List of child "netdev_rxq_dummy"s. */ }; @@ -730,6 +731,18 @@ netdev_dummy_get_in4(const struct netdev *netdev_, } static int +netdev_dummy_get_in6(const struct netdev *netdev_, struct in6_addr *in6) +{ + struct netdev_dummy *netdev = netdev_dummy_cast(netdev_); + + ovs_mutex_lock(&netdev->mutex); + *in6 = netdev->ipv6; + ovs_mutex_unlock(&netdev->mutex); + + return ipv6_addr_is_set(in6) ? 0 : EADDRNOTAVAIL; +} + +static int netdev_dummy_set_in4(struct netdev *netdev_, struct in_addr address, struct in_addr netmask) { @@ -744,6 +757,18 @@ netdev_dummy_set_in4(struct netdev *netdev_, struct in_addr address, } static int +netdev_dummy_set_in6(struct netdev *netdev_, struct in6_addr *in6) +{ + struct netdev_dummy *netdev = netdev_dummy_cast(netdev_); + + ovs_mutex_lock(&netdev->mutex); + netdev->ipv6 = *in6; + ovs_mutex_unlock(&netdev->mutex); + + return 0; +} + +static int netdev_dummy_set_config(struct netdev *netdev_, const struct smap *args) { struct netdev_dummy *netdev = netdev_dummy_cast(netdev_); @@ -1133,7 +1158,7 @@ static const struct netdev_class dummy_class = { netdev_dummy_get_in4, /* get_in4 */ NULL, /* set_in4 */ - NULL, /* get_in6 */ + netdev_dummy_get_in6, /* get_in6 */ NULL, /* add_router */ NULL, /* get_next_hop */ NULL, /* get_status */ @@ -1425,6 +1450,34 @@ netdev_dummy_ip4addr(struct unixctl_conn *conn, int argc OVS_UNUSED, } static void +netdev_dummy_ip6addr(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[], void *aux OVS_UNUSED) +{ + struct netdev *netdev = netdev_from_name(argv[1]); + + if (netdev && is_dummy_class(netdev->netdev_class)) { + char ip6_s[IPV6_SCAN_LEN + 1]; + struct in6_addr ip6; + + if (ovs_scan(argv[2], IPV6_SCAN_FMT, ip6_s) && + inet_pton(AF_INET6, ip6_s, &ip6) == 1) { + netdev_dummy_set_in6(netdev, &ip6); + unixctl_command_reply(conn, "OK"); + } else { + unixctl_command_reply(conn, "Invalid parameters"); + } + + netdev_close(netdev); + } else { + unixctl_command_reply_error(conn, "Unknown Dummy Interface"); + netdev_close(netdev); + return; + } + +} + + +static void netdev_dummy_override(const char *type) { if (!netdev_unregister_provider(type)) { @@ -1457,6 +1510,9 @@ netdev_dummy_register(enum dummy_level level) unixctl_command_register("netdev-dummy/ip4addr", "[netdev] ipaddr/mask-prefix-len", 2, 2, netdev_dummy_ip4addr, NULL); + unixctl_command_register("netdev-dummy/ip6addr", + "[netdev] ip6addr", 2, 2, + netdev_dummy_ip6addr, NULL); if (level == DUMMY_OVERRIDE_ALL) { struct sset types; diff --git a/tests/automake.mk b/tests/automake.mk index 5267be1..bd06a51 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -50,6 +50,7 @@ TESTSUITE_AT = \ tests/jsonrpc-py.at \ tests/tunnel.at \ tests/tunnel-push-pop.at \ + tests/tunnel-push-pop-ipv6.at \ tests/lockfile.at \ tests/reconnect.at \ tests/ovs-vswitchd.at \ diff --git a/tests/testsuite.at b/tests/testsuite.at index 8f915fa..7e3f193 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -48,6 +48,7 @@ m4_include([tests/jsonrpc.at]) m4_include([tests/jsonrpc-py.at]) m4_include([tests/tunnel.at]) m4_include([tests/tunnel-push-pop.at]) +m4_include([tests/tunnel-push-pop-ipv6.at]) m4_include([tests/lockfile.at]) m4_include([tests/reconnect.at]) m4_include([tests/ovs-vswitchd.at]) diff --git a/tests/tunnel-push-pop-ipv6.at b/tests/tunnel-push-pop-ipv6.at new file mode 100644 index 0000000..c9523e0 --- /dev/null +++ b/tests/tunnel-push-pop-ipv6.at @@ -0,0 +1,153 @@ +AT_BANNER([tunnel_push_pop_ipv6]) + +AT_SETUP([tunnel_push_pop_ipv6 - action]) + +OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy ofport_request=1 other-config:hwaddr=aa:55:aa:55:00:00]) +AT_CHECK([ovs-vsctl add-br int-br -- set bridge int-br datapath_type=dummy], [0]) +AT_CHECK([ovs-vsctl add-port int-br t2 -- set Interface t2 type=vxlan \ + options:remote_ip=2001:cafe::92 options:key=123 ofport_request=2\ + -- add-port int-br t1 -- set Interface t1 type=gre \ + options:remote_ip=2001:cafe::92 options:key=456 ofport_request=3\ + -- add-port int-br t3 -- set Interface t3 type=vxlan \ + options:remote_ip=2001:cafe::93 options:out_key=flow options:csum=true ofport_request=4\ + -- add-port int-br t4 -- set Interface t4 type=geneve \ + options:remote_ip=flow options:key=123 ofport_request=5\ + ], [0]) + +AT_CHECK([ovs-appctl dpif/show], [0], [dnl +dummy@ovs-dummy: hit:0 missed:0 + br0: + br0 65534/100: (dummy) + p0 1/1: (dummy) + int-br: + int-br 65534/2: (dummy) + t1 3/3: (gre: key=456, remote_ip=2001:cafe::92) + t2 2/4789: (vxlan: key=123, remote_ip=2001:cafe::92) + t3 4/4789: (vxlan: csum=true, out_key=flow, remote_ip=2001:cafe::93) + t4 5/6081: (geneve: key=123, remote_ip=flow) +]) + +dnl First setup dummy interface IP address, then add the route +dnl so that tnl-port table can get valid IP address for the device. +AT_CHECK([ovs-appctl netdev-dummy/ip6addr br0 2001:cafe::88/24], [0], [OK +]) +AT_CHECK([ovs-appctl ovs/route/add 2001:cafe::92/24 br0], [0], [OK +]) + +AT_CHECK([ovs-ofctl add-flow br0 action=normal]) + +dnl Check ARP Snoop +AT_CHECK([ovs-appctl tnl/arp/set br0 2001:cafe::92 f8:bc:12:44:34:b6], [0], [OK +]) +AT_CHECK([ovs-appctl tnl/arp/set br0 2001:cafe::93 f8:bc:12:44:34:b7], [0], [OK +]) + +AT_CHECK([ovs-appctl tnl/arp/show], [0], [dnl +IP MAC Bridge +========================================================================== +2001:cafe::92 f8:bc:12:44:34:b6 br0 +2001:cafe::93 f8:bc:12:44:34:b7 br0 +]) + +AT_CHECK([ovs-appctl tnl/ports/show |sort], [0], [dnl +Listening ports: +genev_sys_6081 (6081) +gre_sys (3) +vxlan_sys_4789 (4789) +]) + +dnl Check VXLAN tunnel pop +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:cafe::92,dst=2001:cafe::88,label=0,proto=17,tclass=0,hlimit=64),udp(src=51283,dst=4789)'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: tnl_pop(4789) +]) + +dnl Check GRE tunnel pop +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:cafe::92,dst=2001:cafe::88,label=0,proto=47,tclass=0,hlimit=64)'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: tnl_pop(3) +]) + +dnl Check Geneve tunnel pop +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(1),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:cafe::92,dst=2001:cafe::88,label=0,proto=17,tclass=0,hlimit=64),udp(src=51283,dst=6081)'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: tnl_pop(6081) +]) + +dnl Check VXLAN tunnel push +AT_CHECK([ovs-ofctl add-flow int-br action=2]) +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: tnl_push(tnl_port(4789),header(size=70,type=4,eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x86dd),ipv6(src=2001:cafe::88,dst=2001:cafe::92,label=0,proto=17,tclass=0,hlimit=64),udp(src=0,dst=4789,csum=0xffff),vxlan(flags=0x8000000,vni=0x7b)),out_port(100)) +]) + +dnl Check VXLAN tunnel push set tunnel id by flow and checksum +AT_CHECK([ovs-ofctl add-flow int-br "actions=set_tunnel:124,4"]) +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: tnl_push(tnl_port(4789),header(size=70,type=4,eth(dst=f8:bc:12:44:34:b7,src=aa:55:aa:55:00:00,dl_type=0x86dd),ipv6(src=2001:cafe::88,dst=2001:cafe::93,label=0,proto=17,tclass=0,hlimit=64),udp(src=0,dst=4789,csum=0xffff),vxlan(flags=0x8000000,vni=0x7c)),out_port(100)) +]) + +dnl Check GRE tunnel push +AT_CHECK([ovs-ofctl add-flow int-br action=3]) +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: tnl_push(tnl_port(3),header(size=62,type=3,eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x86dd),ipv6(src=2001:cafe::88,dst=2001:cafe::92,label=0,proto=47,tclass=0,hlimit=64),gre((flags=0x2000,proto=0x6558),key=0x1c8)),out_port(100)) +]) + +dnl Check Geneve tunnel push +AT_CHECK([ovs-ofctl add-flow int-br "actions=set_field:2001:cafe::92->tun_ipv6_dst,5"]) +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: tnl_push(tnl_port(6081),header(size=70,type=5,eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x86dd),ipv6(src=2001:cafe::88,dst=2001:cafe::92,label=0,proto=17,tclass=0,hlimit=64),udp(src=0,dst=6081,csum=0xffff),geneve(vni=0x7b)),out_port(100)) +]) + +dnl Check Geneve tunnel push with options +AT_CHECK([ovs-ofctl add-geneve-map int-br "{class=0xffff,type=0x80,len=4}->tun_metadata0"]) +AT_CHECK([ovs-ofctl add-flow int-br "actions=set_field:2001:cafe::92->tun_ipv6_dst,set_field:0xa->tun_metadata0,5"]) +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=47,tos=0,ttl=64,frag=no)'], [0], [stdout]) +AT_CHECK([tail -1 stdout], [0], + [Datapath actions: tnl_push(tnl_port(6081),header(size=78,type=5,eth(dst=f8:bc:12:44:34:b6,src=aa:55:aa:55:00:00,dl_type=0x86dd),ipv6(src=2001:cafe::88,dst=2001:cafe::92,label=0,proto=17,tclass=0,hlimit=64),udp(src=0,dst=6081,csum=0xffff),geneve(crit,vni=0x7b,options({class=0xffff,type=0x80,len=4,0xa}))),out_port(100)) +]) + +dnl Check decapsulation of GRE packet +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6486dd60000000006a2f402001cafe0000000000000000000000922001cafe00000000000000000000008820006558000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +ovs-appctl time/warp 1000 + +AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 3'], [0], [dnl + port 3: rx pkts=1, bytes=98, drop=0, errs=0, frame=0, over=0, crc=0 +]) + +dnl Check GRE only accepts encapsulated Ethernet frames +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6486dd60000000006a2f402001cafe0000000000000000000000922001cafe00000000000000000000008820000800000001c8fe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) +ovs-appctl time/warp 1000 + +AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 3'], [0], [dnl + port 3: rx pkts=1, bytes=98, drop=0, errs=0, frame=0, over=0, crc=0 +]) + +dnl Check decapsulation of Geneve packet with options +AT_CAPTURE_FILE([ofctl_monitor.log]) +AT_CHECK([ovs-ofctl monitor int-br 65534 --detach --no-chdir --pidfile 2> ofctl_monitor.log]) + +AT_CHECK([ovs-ofctl del-flows int-br]) +AT_CHECK([ovs-ofctl add-flow int-br "tun_metadata0=0xa/0xf,actions=5,controller"]) +AT_CHECK([ovs-appctl netdev-dummy/receive p0 'aa55aa550000001b213cab6486dd60000000008211402001cafe0000000000000000000000922001cafe000000000000000000000088308817c1008200000400655800007b00ffff80010000000affff00010000000bfe71d883724fbeb6f4e1494a080045000054ba200000400184861e0000011e00000200004227e75400030af3195500000000f265010000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637']) + +OVS_WAIT_UNTIL([test `wc -l < ofctl_monitor.log` -ge 2]) +OVS_APP_EXIT_AND_WAIT(ovs-ofctl) + +AT_CHECK([cat ofctl_monitor.log], [0], [dnl +NXT_PACKET_IN (xid=0x0): cookie=0x0 total_len=98 tun_id=0x7b,tun_ipv6_src=2001:cafe::92,tun_ipv6_dst=2001:cafe::88,tun_metadata0=0xa,in_port=5 (via action) data_len=98 (unbuffered) +icmp,vlan_tci=0x0000,dl_src=be:b6:f4:e1:49:4a,dl_dst=fe:71:d8:83:72:4f,nw_src=30.0.0.1,nw_dst=30.0.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=0,icmp_code=0 icmp_csum:4227 +]) + +AT_CHECK([ovs-ofctl dump-ports int-br | grep 'port 5'], [0], [dnl + port 5: rx pkts=1, bytes=98, drop=0, errs=0, frame=0, over=0, crc=0 +]) +AT_CHECK([ovs-appctl dpif/dump-flows int-br], [0], [dnl +tunnel(tun_id=0x7b,ipv6_src=2001:cafe::92,ipv6_dst=2001:cafe::88,ttl=64,geneve({class=0xffff,type=0x80,len=4,0xa/0xf}{class=0xffff,type=0,len=4}),flags(-df-csum+key)),skb_mark(0),recirc_id(0),in_port(6081),eth_type(0x0800),ipv4(frag=no), packets:0, bytes:0, used:never, actions:userspace(pid=0,slow_path(controller)) +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP