From 517ee7fd3eb28ecf030c5d50be09fcdabe508922 Mon Sep 17 00:00:00 2001 From: Matej Klotton Date: Mon, 25 Jul 2016 17:52:22 +0200 Subject: [PATCH] CSIT-197: Add basic mapping rule tests for MAP-E - IPv4 prefix length + ea bits length < 32 - IPv4 prefix length + ea bits length == 32 - IPv4 prefix length + ea bits length > 32 - End user IPv6 prefix is 64 - IPv4 preffix is 0 Change-Id: Ib8d76abfebfb206fbbaa3c1422b2d321a3ed8712 Signed-off-by: Matej Klotton --- resources/libraries/python/IPUtil.py | 23 +- resources/libraries/python/Map.py | 180 ++++++++++++ resources/libraries/python/Trace.py | 8 + resources/templates/vat/clear_trace.vat | 1 + resources/templates/vat/map_del_domain.vat | 1 + .../traffic_scripts/send_ipv4_udp_check_lw_4o6.py | 5 +- tests/func/softwire/map_e.robot | 318 +++++++++++++++++++++ 7 files changed, 532 insertions(+), 4 deletions(-) create mode 100644 resources/templates/vat/clear_trace.vat create mode 100644 resources/templates/vat/map_del_domain.vat create mode 100644 tests/func/softwire/map_e.robot diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py index 323c75bda4..5011708c39 100644 --- a/resources/libraries/python/IPUtil.py +++ b/resources/libraries/python/IPUtil.py @@ -12,13 +12,15 @@ # limitations under the License. """Common IP utilities library.""" -from ipaddress import IPv4Network + +from ipaddress import IPv4Network, ip_address from resources.libraries.python.ssh import SSH from resources.libraries.python.constants import Constants from resources.libraries.python.topology import Topology + class IPUtil(object): """Common IP utilities""" @@ -45,7 +47,7 @@ class IPUtil(object): elif if_type == "name": iface_name = interface else: - raise ValueError("if_type unknown: {}".format(if_type)) + raise ValueError("if_type unknown: {0}".format(if_type)) cmd = "{c}".format(c=Constants.VAT_BIN_NAME) cmd_input = 'exec ip probe {dev} {ip}'.format(dev=iface_name, ip=addr) @@ -54,6 +56,23 @@ class IPUtil(object): raise Exception('VPP ip probe {dev} {ip} failed on {h}'.format( dev=iface_name, ip=addr, h=node['host'])) + @staticmethod + def ip_addresses_should_be_equal(ip1, ip2): + """Fails if the given IP addresses are unequal. + + :param ip1: IPv4 or IPv6 address. + :param ip2: IPv4 or IPv6 address. + :type ip1: str + :type ip2: str + """ + + addr1 = ip_address(unicode(ip1)) + addr2 = ip_address(unicode(ip2)) + + if addr1 != addr2: + raise AssertionError('IP addresses are not equal: {0} != {1}'. + format(ip1, ip2)) + def convert_ipv4_netmask_prefix(network): """Convert network mask to equivalent network prefix length or vice versa. diff --git a/resources/libraries/python/Map.py b/resources/libraries/python/Map.py index 7d48c20d2e..b98d488e73 100644 --- a/resources/libraries/python/Map.py +++ b/resources/libraries/python/Map.py @@ -14,6 +14,8 @@ """Map utilities library.""" +import ipaddress + from resources.libraries.python.VatExecutor import VatExecutor @@ -81,3 +83,181 @@ class Map(object): if output[0]["retval"] != 0: raise RuntimeError('Unable to add map rule on node {}' .format(vpp_node['host'])) + + @staticmethod + def map_del_domain(vpp_node, index): + """Delete map domain on node. + + :param vpp_node: VPP node to delete map domain on. + :param index: Index of the map domain. + :type vpp_node: dict + :type index: int + :raises RuntimeError: If unable to delete map domain. + """ + output = VatExecutor.cmd_from_template(vpp_node, "map_del_domain.vat", + index=index) + if output[0]["retval"] != 0: + raise RuntimeError('Unable to delete map domain {} on node {}' + .format(index, vpp_node['host'])) + + @staticmethod + def get_psid_from_port(port, psid_len, psid_offset): + """Return PSID from port. + 0 1 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 + +-----------+-----------+-------+ + Ports in | A | PSID | j | + the CE port set | > 0 | | | + +-----------+-----------+-------+ + | a bits | k bits |m bits | + + + :param port: Port to compute PSID from. + :param psid_len: PSID length. + :param psid_offset: PSID offset. + :type port: int + :type psid_len: int + :type psid_offset: int + + :return: PSID. + :rtype: int + """ + ones = 2**16-1 + mask = ones >> (16 - psid_len) + psid = port >> (16 - psid_len - psid_offset) + psid &= mask + return psid + + @staticmethod + def _make_ea_bits(ipv4_net, ipv4_host, ea_bit_len, psid_len, psid): + """ + _note_: host(or prefix) part of destination ip in rule prefix, + psid + + :param ipv4_net: IPv4 domain prefix. + :param ipv4_host: Destination IPv4 address. + :param ea_bit_len: EA bit length. + :param psid_len: PSID length. + :param psid: PSID. + :type ipv4_net: ipaddress.IPv4Network + :type ipv4_host: ipaddress.IPv4Address + :type ea_bit_len: int + :type psid_len: int + :type psid: int + :return: Number representing EA bit field of destination IPv6 address. + :rtype: int + """ + v4_suffix_len = ipv4_net._max_prefixlen - ipv4_net.prefixlen + v4_suffix = ipv4_net.network_address._ip ^ ipv4_host._ip + + if ipv4_net.prefixlen + ea_bit_len <= 32: + ea_bits = v4_suffix >> (v4_suffix_len - ea_bit_len) + return ea_bits + else: + q_len = ea_bit_len - v4_suffix_len + # p_bits = v4_suffix << q_len # option 1: psid right padded + p_bits = v4_suffix << psid_len # option 2: psid left padded + if q_len < psid_len: + raise Exception("invalid configuration: q_len < psid_len") + ea_bits = p_bits | psid + ea_bits <<= q_len - psid_len # option 2: psid left padded + return ea_bits + + @staticmethod + def _make_interface_id(rule_net, dst_ip, ea_bit_len, psid): + """ + _note_: if prefix or complete ip (<= 32), psid is 0 + + :param rule_net: IPv4 domain prefix. + :param dst_ip: Destination IPv4 address. + :param ea_bit_len: EA bit length. + :param psid: PSID. + :type rule_net: ipaddress.IPv4Network + :type dst_ip: ipaddress.IPv4Address + :type ea_bit_len: int + :type psid: int + :return: Number representing interface id field of destination IPv6 + address. + :rtype: int + """ + if rule_net.prefixlen + ea_bit_len < 32: + v4_suffix_len = rule_net._max_prefixlen - rule_net.prefixlen + v4_suffix = rule_net.network_address._ip ^ dst_ip._ip + ea_bits = v4_suffix >> (v4_suffix_len - ea_bit_len) + address = rule_net.network_address._ip >> v4_suffix_len + address <<= ea_bit_len + address |= ea_bits + address <<= 32 - rule_net.prefixlen - ea_bit_len + address <<= 16 + # psid_field = 0 + # address = address | psid_field + elif rule_net.prefixlen + ea_bit_len == 32: + address = dst_ip._ip << 16 + # psid_field = 0 + # address = address | psid_field + else: + address = dst_ip._ip << 16 + address |= psid + return address + + return address + + @staticmethod + def compute_ipv6_map_destination_address(ipv4_pfx, ipv6_pfx, ea_bit_len, + psid_offset, psid_len, ipv4_dst, + dst_port): + """Compute IPv6 destination address from IPv4 address for MAP algorithm. + (RFC 7597) + + | n bits | o bits | s bits | 128-n-o-s bits | + +--------------------+-----------+---------+-----------------------+ + | Rule IPv6 prefix | EA bits |subnet ID| interface ID | + +--------------------+-----------+---------+-----------------------+ + |<--- End-user IPv6 prefix --->| + + + :param ipv4_pfx: Domain IPv4 preffix. + :param ipv6_pfx: Domain IPv6 preffix. + :param ea_bit_len: Domain EA bits length. + :param psid_offset: Domain PSID offset. + :param psid_len: Domain PSID length. + :param ipv4_dst: Destination IPv4 address. + :param dst_port: Destination port number or ICMP ID. + :type ipv4_pfx: str + :type ipv6_pfx: str + :type ea_bit_len: int + :type psid_offset: int + :type psid_len: int + :type ipv4_dst: str + :type dst_port: int + :return: Computed IPv6 address. + :rtype: str + """ + ipv6_net = ipaddress.ip_network(unicode(ipv6_pfx)) + ipv4_net = ipaddress.ip_network(unicode(ipv4_pfx)) + ipv4_host = ipaddress.ip_address(unicode(ipv4_dst)) + + ipv6_host_len = ipv6_net._max_prefixlen - ipv6_net.prefixlen + ipv4_host_len = ipv4_net._max_prefixlen - ipv4_net.prefixlen + end_user_v6_pfx_len = ipv6_net.prefixlen + ea_bit_len + psid = Map.get_psid_from_port(dst_port, psid_len, psid_offset) + + rule_v6_pfx = ipv6_net.network_address._ip >> ipv6_host_len + ea_bits = Map._make_ea_bits(ipv4_net, ipv4_host, ea_bit_len, psid_len, + psid) + subnet_id = 0 + interface_id = Map._make_interface_id(ipv4_net, ipv4_host, ea_bit_len, + psid) + + address = rule_v6_pfx << ea_bit_len + address |= ea_bits # add EA bits + + if end_user_v6_pfx_len > 64: + # If the End-user IPv6 prefix length is larger than 64, + # the most significant parts of the interface identifier are + # overwritten by the prefix. + mask = (2**128-1) >> end_user_v6_pfx_len + interface_id &= mask + address <<= (128 - end_user_v6_pfx_len) + address |= interface_id # add Interface ID bits + + return str(ipaddress.ip_address(address)) diff --git a/resources/libraries/python/Trace.py b/resources/libraries/python/Trace.py index 1a251a61b6..49b39cbdfb 100644 --- a/resources/libraries/python/Trace.py +++ b/resources/libraries/python/Trace.py @@ -23,3 +23,11 @@ class Trace(object): if node['type'] == NodeType.DUT: vat = VatExecutor() vat.execute_script("show_trace.vat", node, json_out=False) + + @staticmethod + def clear_packet_trace_on_all_duts(nodes): + for node in nodes.values(): + if node['type'] == NodeType.DUT: + vat = VatExecutor() + vat.execute_script("clear_trace.vat", node, json_out=False) + diff --git a/resources/templates/vat/clear_trace.vat b/resources/templates/vat/clear_trace.vat new file mode 100644 index 0000000000..66f2dfb165 --- /dev/null +++ b/resources/templates/vat/clear_trace.vat @@ -0,0 +1 @@ +exec clear trace diff --git a/resources/templates/vat/map_del_domain.vat b/resources/templates/vat/map_del_domain.vat new file mode 100644 index 0000000000..eeafd8f93a --- /dev/null +++ b/resources/templates/vat/map_del_domain.vat @@ -0,0 +1 @@ +map_del_domain index {index} \ No newline at end of file diff --git a/resources/traffic_scripts/send_ipv4_udp_check_lw_4o6.py b/resources/traffic_scripts/send_ipv4_udp_check_lw_4o6.py index 881abc83a2..116edb206b 100755 --- a/resources/traffic_scripts/send_ipv4_udp_check_lw_4o6.py +++ b/resources/traffic_scripts/send_ipv4_udp_check_lw_4o6.py @@ -19,6 +19,7 @@ import sys from scapy.layers.l2 import Ether from scapy.layers.inet import IP, UDP +from ipaddress import ip_address from resources.libraries.python.PacketVerifier import RxQueue, TxQueue from resources.libraries.python.TrafficScriptArg import TrafficScriptArg @@ -88,12 +89,12 @@ def main(): # pylint: disable=too-many-statements, too-many-locals ipv6 = ether.payload # check ipv6 - if ipv6.dst != rx_dst_ipv6: + if ip_address(unicode(ipv6.dst)) != ip_address(unicode(rx_dst_ipv6)): raise RuntimeError("Destination IP error {} != {}.". format(ipv6.dst, rx_dst_ipv6)) print "Destination IPv6: OK." - if ipv6.src != rx_src_ipv6: + if ip_address(unicode(ipv6.src)) != ip_address(unicode(rx_src_ipv6)): raise RuntimeError("Source IP error {} != {}.". format(ipv6.src, rx_src_ipv6)) print "Source IPv6: OK." diff --git a/tests/func/softwire/map_e.robot b/tests/func/softwire/map_e.robot new file mode 100644 index 0000000000..e0b09e56bb --- /dev/null +++ b/tests/func/softwire/map_e.robot @@ -0,0 +1,318 @@ +# Copyright (c) 2016 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +*** Settings *** +| Resource | resources/libraries/robot/default.robot +| Resource | resources/libraries/robot/testing_path.robot +| Resource | resources/libraries/robot/ipv4.robot +| Resource | resources/libraries/robot/ipv6.robot +| Resource | resources/libraries/robot/map.robot +| Library | resources.libraries.python.IPUtil +| Library | resources.libraries.python.Trace +| Force Tags | HW_ENV | VM_ENV | 3_NODE_DOUBLE_LINK_TOPO +| Suite Setup | Run Keywords +| ... | Setup all DUTs before test | AND +| ... | Setup all TGs before traffic script +| Test Setup | Run Keywords +| ... | Setup all DUTs before test | AND +| ... | Setup all TGs before traffic script +| Test Teardown | Run Keywords +| ... | Show packet trace on all DUTs | ${nodes} | AND +| ... | Show vpp trace dump on all DUTs +| Documentation | *Test for Basic mapping rule for MAP-E*\ +| ... | *[Top] Network Topologies:* TG - DUT1 - TG with two links between the +| ... | nodes. +| ... | *[Enc] Packet Encapsulations:* Eth-IPv4-UDP on TG-to-DUT-if1. +| ... | Eth-IPv6-IPv4-UDP on TG-to-DUT-if2. +| ... | *[Cfg] DUT configuration:* DUT is configured with IPv4 on one DUT-to-TG +| ... | interface and IPv6 address on second DUT-to-TG interface. MAP-E domain +| ... | is configured in test template based on test parameters. +| ... | *[Ver] TG verification:* UDP packets in IPv4 are sent by TG to +| ... | destination in MAP domain. IPv6 packets with encapsulated IPv4 are +| ... | received on TG interface. +| ... | *[Ref] Applicable standard specifications:* RFC7597. + + +*** Variables *** +| ${dut_ip4}= | 10.0.0.1 +| ${dut_ip6}= | 2001:0::1 +| ${dut_ip4_gw}= | 10.0.0.2 +| ${dut_ip6_gw}= | 2001:0::2 +| ${ipv4_prefix_len}= | 24 +| ${ipv6_prefix_len}= | 64 +| ${ipv6_br_src}= | 2001:db8:ffff::1 +| ${ipv4_outside}= | 100.0.0.1 + + +*** Test Cases *** +| TC01: BMR, then an IPv4 prefix is assigned +| | [Tags] | EXPECTED_FAILING +| | [Documentation] | +| | ... | Basic Mapping Rule https://tools.ietf.org/html/rfc7597#section-5.2\ +| | ... | IPv4 prefix length + ea bits length < 32 (o + r < 32) +| | ... | psid_length = 0, ip6_prefix < 64, ip4_prefix <= 32 +| | ... +# TODO: replace setup when VPP-312 fixed +#| | [Setup] | Set interfaces IP addresses and routes +| | [Setup] | Run Keywords +| | ... | Setup all DUTs before test | AND +| | ... | Setup all TGs before traffic script | AND +| | ... | Set interfaces IP addresses and routes +| | [Template] | Check MAP configuration with traffic script +# |=================|===============|================|============|=============|==========|================|==========|==================================| +# | ipv4_pfx | ipv6_pfx | ipv6_src | ea_bit_len | psid_offset | psid_len | ipv4_dst | dst_port | expected_ipv6_dst | +# |=================|===============|================|============|=============|==========|================|==========|==================================| +| | 20.0.0.0/8 | 2001:db8::/32 | ${ipv6_br_src} | ${4} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:a000::14a0:0:0 | +| | 20.0.0.0/8 | 2001:db8::/32 | ${ipv6_br_src} | ${8} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:a900::14a9:0:0 | +| | 20.0.0.0/8 | 2001:db8::/32 | ${ipv6_br_src} | ${10} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:a9c0::14a9:c000:0 | +| | 20.0.0.0/8 | 2001:db8::/32 | ${ipv6_br_src} | ${16} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:a9c9::14a9:c900:0 | +| | 20.0.0.0/8 | 2001:db8::/32 | ${ipv6_br_src} | ${20} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:a9c9:d000:0:14a9:c9d0:0 | +| | 20.0.0.0/8 | 2001:db8::/32 | ${ipv6_br_src} | ${23} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:a9c9:da00:0:14a9:c9da:0 | +| | 20.169.201.0/24 | 2001:db8::/32 | ${ipv6_br_src} | ${4} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:d000::14a9:c9d0:0 | +| | 20.169.201.0/24 | 2001:db8::/32 | ${ipv6_br_src} | ${7} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:da00::14a9:c9da:0 | + + +| TC02: BMR, full IPv4 address is to be assigned +| | [Documentation] | +| | ... | Basic Mapping Rule https://tools.ietf.org/html/rfc7597#section-5.2\ +| | ... | IPv4 prefix length + ea bits length == 32 (o + r == 32) +| | ... | psid_length = 0, ip6_prefix < 64, ip4_prefix <= 32 +| | ... +# TODO: replace setup when VPP-312 fixed +#| | [Setup] | Set interfaces IP addresses and routes +| | [Setup] | Run Keywords +| | ... | Setup all DUTs before test | AND +| | ... | Setup all TGs before traffic script | AND +| | ... | Set interfaces IP addresses and routes +| | [Template] | Check MAP configuration with traffic script +# |===================|===============|================|============|=============|==========|================|==========|==================================| +# | ipv4_pfx | ipv6_pfx | ipv6_src | ea_bit_len | psid_offset | psid_len | ipv4_dst | dst_port | expected_ipv6_dst | +# |===================|===============|================|============|=============|==========|================|==========|==================================| +| | 20.0.0.0/8 | 2001:db8::/32 | ${ipv6_br_src} | ${24} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:a9c9:db00:0:14a9:c9db:0 | +| | 20.160.0.0/12 | 2001:db8::/32 | ${ipv6_br_src} | ${20} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:9c9d:b000:0:14a9:c9db:0 | +| | 20.169.0.0/16 | 2001:db8::/32 | ${ipv6_br_src} | ${16} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:c9db::14a9:c9db:0 | +| | 20.169.200.0/22 | 2001:db8::/32 | ${ipv6_br_src} | ${10} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:76c0::14a9:c9db:0 | +| | 20.169.201.0/24 | 2001:db8::/32 | ${ipv6_br_src} | ${8} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:db00::14a9:c9db:0 | +| | 20.169.201.208/28 | 2001:db8::/32 | ${ipv6_br_src} | ${4} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:b000::14a9:c9db:0 | +| | 20.169.201.219/32 | 2001:db8::/32 | ${ipv6_br_src} | ${0} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8::14a9:c9db:0 | +| | 20.0.0.0/8 | 2001:db8::/40 | ${ipv6_br_src} | ${24} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:a9:c9db:0:14a9:c9db:0 | +| | 20.160.0.0/12 | 2001:db8::/44 | ${ipv6_br_src} | ${20} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:9:c9db:0:14a9:c9db:0 | +| | 20.169.0.0/16 | 2001:db8::/48 | ${ipv6_br_src} | ${16} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:0:c9db:0:14a9:c9db:0 | +| | 20.169.200.0/22 | 2001:db8::/54 | ${ipv6_br_src} | ${10} | ${0} | ${0} | 20.169.201.219 | ${1232} | 2001:db8:0:1db:0:14a9:c9db:0 | + + +| TC03: BMR, shared IPv4 address is to be assigned +| | [Documentation] | +| | ... | Basic Mapping Rule https://tools.ietf.org/html/rfc7597#section-5.2\ +| | ... | IPv4 prefix length + ea bits length > 32 (o + r > 32) +| | ... | ip6_prefix < 64, ip4_prefix <= 32 +| | ... +# TODO: replace setup when VPP-312 fixed +#| | [Setup] | Set interfaces IP addresses and routes +| | [Setup] | Run Keywords +| | ... | Setup all DUTs before test | AND +| | ... | Setup all TGs before traffic script | AND +| | ... | Set interfaces IP addresses and routes +| | [Template] | Check MAP configuration with traffic script +# |===================|===============|================|============|=============|==========|================|==========|===================================| +# | ipv4_pfx | ipv6_pfx | ipv6_src | ea_bit_len | psid_offset | psid_len | ipv4_dst | dst_port | expected_ipv6_dst | +# |===================|===============|================|============|=============|==========|================|==========|===================================| +| | 20.0.0.0/8 | 2001::/16 | ${ipv6_br_src} | ${48} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:a9c9:db34::14a9:c9db:34 | +| | 20.169.0.0/16 | 2001::/16 | ${ipv6_br_src} | ${48} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:c9db:3400::14a9:c9db:34 | +| | 20.169.201.0/24 | 2001::/16 | ${ipv6_br_src} | ${48} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db34::14a9:c9db:34 | +| | 20.169.201.219/32 | 2001::/16 | ${ipv6_br_src} | ${48} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:3400::14a9:c9db:34 | + +| | 20.0.0.0/8 | 2001::/24 | ${ipv6_br_src} | ${40} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:a9:c9db:3400:0:14a9:c9db:34 | +| | 20.169.0.0/16 | 2001::/24 | ${ipv6_br_src} | ${40} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:c9:db34::14a9:c9db:34 | +| | 20.169.201.0/24 | 2001::/24 | ${ipv6_br_src} | ${40} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db:3400::14a9:c9db:34 | +| | 20.169.201.219/32 | 2001::/24 | ${ipv6_br_src} | ${40} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:34::14a9:c9db:34 | +| | 20.169.0.0/16 | 2001::/16 | ${ipv6_br_src} | ${40} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:c9db:3400::14a9:c9db:34 | +| | 20.169.201.219/32 | 2001::/16 | ${ipv6_br_src} | ${40} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:3400::14a9:c9db:34 | + +| | 20.0.0.0/8 | 2001:db8::/32 | ${ipv6_br_src} | ${32} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db8:a9c9:db34:0:14a9:c9db:34 | +| | 20.169.0.0/16 | 2001:db8::/32 | ${ipv6_br_src} | ${32} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db8:c9db:3400:0:14a9:c9db:34 | +| | 20.169.201.0/24 | 2001:db8::/32 | ${ipv6_br_src} | ${32} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db8:db34::14a9:c9db:34 | +| | 20.169.201.219/32 | 2001:db8::/32 | ${ipv6_br_src} | ${32} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db8:3400::14a9:c9db:34 | +| | 20.169.0.0/16 | 2001::/24 | ${ipv6_br_src} | ${32} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:c9:db34::14a9:c9db:34 | +| | 20.169.201.0/24 | 2001::/24 | ${ipv6_br_src} | ${32} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db:3400::14a9:c9db:34 | +| | 20.169.0.0/16 | 2001::/16 | ${ipv6_br_src} | ${32} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:c9db:3400::14a9:c9db:34 | +| | 20.169.201.0/24 | 2001::/16 | ${ipv6_br_src} | ${32} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db34::14a9:c9db:34 | + +| | 20.160.0.0/12 | 2001:db8::/32 | ${ipv6_br_src} | ${25} | ${6} | ${5} | 20.169.201.219 | ${1232} | 2001:db8:9c9d:b300:0:14a9:c9db:6 | +| | 20.169.0.0/16 | 2001:db8::/32 | ${ipv6_br_src} | ${25} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db8:c9db:3400:0:14a9:c9db:34 | +| | 20.169.201.0/24 | 2001:db8::/32 | ${ipv6_br_src} | ${25} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db8:db34::14a9:c9db:34 | +| | 20.169.201.219/32 | 2001:db8::/32 | ${ipv6_br_src} | ${25} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db8:3400::14a9:c9db:34 | + +| | 20.169.192.0/20 | 2001:db8::/32 | ${ipv6_br_src} | ${17} | ${6} | ${5} | 20.169.201.219 | ${1232} | 2001:db8:9db3::14a9:c9db:6 | +| | 20.169.201.0/24 | 2001:db8::/32 | ${ipv6_br_src} | ${17} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db8:db34::14a9:c9db:34 | +| | 20.169.201.219/32 | 2001:db8::/32 | ${ipv6_br_src} | ${17} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db8:3400::14a9:c9db:34 | + +| | 20.169.201.0/24 | 2001:db8::/32 | ${ipv6_br_src} | ${12} | ${6} | ${4} | 20.169.201.219 | ${1232} | 2001:db8:db30::14a9:c9db:3 | +| | 20.169.201.219/32 | 2001:db8::/32 | ${ipv6_br_src} | ${12} | ${6} | ${8} | 20.169.201.219 | ${1232} | 2001:db8:3400::14a9:c9db:34 | + + +| TC04: End user IPv6 prefix is 64 +| | [Tags] | EXPECTED_FAILING +| | [Documentation] | +| | ... | Supported End-User IPv6 prefix length is 64 bit. +| | ... +# TODO: replace setup when VPP-312 fixed +#| | [Setup] | Set interfaces IP addresses and routes +| | [Setup] | Run Keywords +| | ... | Setup all DUTs before test | AND +| | ... | Setup all TGs before traffic script | AND +| | ... | Set interfaces IP addresses and routes +| | [Template] | Check MAP configuration with traffic script +# |===================|=========================|================|============|=============|==========|================|==========| +# | ipv4_pfx | ipv6_pfx | ipv6_src | ea_bit_len | psid_offset | psid_len | ipv4_dst | dst_port | +# |===================|=========================|================|============|=============|==========|================|==========| +| | 20.0.0.0/8 | 2001:db8:0012:3400::/56 | ${ipv6_br_src} | ${8} | ${0} | ${0} | 20.169.201.219 | ${1232} | +| | 20.169.201.208/28 | 2001:db8:0012:3400::/56 | ${ipv6_br_src} | ${8} | ${5} | ${4} | 20.169.201.219 | ${3280} | +| | 20.0.0.0/8 | 2001:db8:0012:3400::/64 | ${ipv6_br_src} | ${0} | ${0} | ${0} | 20.169.201.219 | ${1232} | +| | 20.169.201.219/32 | 2001:db8:0012:3400::/64 | ${ipv6_br_src} | ${0} | ${0} | ${0} | 20.169.201.219 | ${1232} | + + +| TC05: IPv4 prefix is 0 +| | [Tags] | EXPECTED_FAILING +# TODO: replace setup when VPP-312 fixed +#| | [Setup] | Set interfaces IP addresses and routes +| | [Setup] | Run Keywords +| | ... | Setup all DUTs before test | AND +| | ... | Setup all TGs before traffic script | AND +| | ... | Set interfaces IP addresses and routes +| | [Template] | Check MAP configuration with traffic script +# |===================|=========================|================|============|=============|==========|================|==========| +# | ipv4_pfx | ipv6_pfx | ipv6_src | ea_bit_len | psid_offset | psid_len | ipv4_dst | dst_port | +# |===================|=========================|================|============|=============|==========|================|==========| +| | 0.0.0.0/0 | 2001:db8:0000::/40 | ${ipv6_br_src} | ${8} | ${0} | ${0} | 20.169.201.219 | ${1232} | +| | 0.0.0.0/0 | 2001:db8:0000::/40 | ${ipv6_br_src} | ${16} | ${0} | ${0} | 20.169.201.219 | ${1232} | +| | 0.0.0.0/0 | 2001:db8::/32 | ${ipv6_br_src} | ${32} | ${0} | ${0} | 20.169.201.219 | ${1232} | +| | 0.0.0.0/0 | 2001::/16 | ${ipv6_br_src} | ${48} | ${0} | ${0} | 20.169.201.219 | ${1232} | +| | 0.0.0.0/0 | 2001::/16 | ${ipv6_br_src} | ${48} | ${6} | ${8} | 20.169.201.219 | ${1232} | + + +| Bug: VPP-318 +| | [Tags] | EXPECTED_FAILING +| | [Documentation] | qlen < psid length +| | Given Path for 2-node testing is set +| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']} +| | And Interfaces in 2-node path are up +| | And IP addresses are set on interfaces +| | ... | ${dut_node} | ${dut_to_tg_if1} | ${dut_ip4} | ${ipv4_prefix_len} +| | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut_ip6} | ${ipv6_prefix_len} +| | Then Run Keyword And Expect Error | Unable to add map domain * +| | ... | Map Add Domain | ${dut_node} | 20.169.0.0/16 | 2001:db8::/32 +| | ... | ${ipv6_br_src} | ${20} | ${6} | ${8} + + +| Bug: VPP-312 +| | [Tags] | EXPECTED_FAILING +| | [Documentation] | +| | ... | add route; add map; traffic pass; add route; add map; traffic fail +| | Given Path for 2-node testing is set +| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']} +| | And Interfaces in 2-node path are up + +| | When IP addresses are set on interfaces +| | ... | ${dut_node} | ${dut_to_tg_if1} | ${dut_ip4} | ${ipv4_prefix_len} +| | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut_ip6} | ${ipv6_prefix_len} +| | And Vpp Route Add | ${dut_node} | 2001:: | 16 | ${dut_ip6_gw} +| | ... | ${dut_to_tg_if2} | resolve_attempts=${NONE} | count=${NONE} +| | And Add IP neighbor | ${dut_node} | ${dut_to_tg_if2} | ${dut_ip6_gw} +| | ... | ${tg_to_dut_if2_mac} + +| | Then Check MAP configuration with traffic script +| | ... | 20.0.0.0/8 | 2001::/16 | ${ipv6_br_src} | ${48} | ${6} | ${8} +| | ... | 20.169.201.219 | ${1232} | 2001:a9c9:db34::14a9:c9db:34 + +| | When IP addresses are set on interfaces +| | ... | ${dut_node} | ${dut_to_tg_if1} | ${dut_ip4} | ${ipv4_prefix_len} +| | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut_ip6} | ${ipv6_prefix_len} +| | And Vpp Route Add | ${dut_node} | 2001:: | 16 | ${dut_ip6_gw} +| | ... | ${dut_to_tg_if2} | resolve_attempts=${NONE} | count=${NONE} +| | And Add IP neighbor | ${dut_node} | ${dut_to_tg_if2} | ${dut_ip6_gw} +| | ... | ${tg_to_dut_if2_mac} + +| | Then Check MAP configuration with traffic script +| | ... | 20.0.0.0/8 | 2001::/16 | ${ipv6_br_src} | ${48} | ${6} | ${8} +| | ... | 20.169.201.219 | ${1232} | 2001:a9c9:db34::14a9:c9db:34 + + +*** Keywords *** +| Set interfaces IP addresses and routes +| | Path for 2-node testing is set +| | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']} +| | Interfaces in 2-node path are up +| | IP addresses are set on interfaces +| | ... | ${dut_node} | ${dut_to_tg_if1} | ${dut_ip4} | ${ipv4_prefix_len} +| | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut_ip6} | ${ipv6_prefix_len} +| | Vpp Route Add | ${dut_node} | :: | 0 | ${dut_ip6_gw} | ${dut_to_tg_if2} +| | ... | resolve_attempts=${NONE} | count=${NONE} +| | Add IP neighbor | ${dut_node} | ${dut_to_tg_if2} | ${dut_ip6_gw} +| | ... | ${tg_to_dut_if2_mac} +| | Vpp Route Add | ${dut_node} | 0.0.0.0 | 0 | ${dut_ip4_gw} | ${dut_to_tg_if1} +| | ... | resolve_attempts=${NONE} | count=${NONE} +| | Add IP neighbor | ${dut_node} | ${dut_to_tg_if1} | ${dut_ip4_gw} +| | ... | ${tg_to_dut_if1_mac} + +| Check MAP configuration with traffic script +| | [Documentation] | +| | ... | Used as a test case template.\ +| | ... | Configure MAP-E domain with given parameters, with traffic script send +| | ... | UDP in IPv4 packet to given UDP destination port and IP destination +| | ... | address and check if correctly received IPv6 packet. Vice versa send +| | ... | IPv6 packet and check if received IPv4 packet with correct source +| | ... | address. +| | ... | The MAP domain is deleted in teardown. +| | ... | The expected IPv6 address is compared with computed IPv6 address. +| | [Arguments] | ${ipv4_pfx} | ${ipv6_pfx} | ${ipv6_br_src} | ${ea_bit_len} +| | ... | ${psid_offset} | ${psid_len} | ${ipv4_dst} | ${dst_port} +| | ... | ${expected_ipv6_dst}=${EMPTY} +| | ${domain_index}= | Map Add Domain | ${dut_node} | ${ipv4_pfx} | ${ipv6_pfx} +| | ... | ${ipv6_br_src} | ${ea_bit_len} | ${psid_offset} | ${psid_len} +| | ${computed_ipv6_dst}= | Compute IPv6 map destination address +| | ... | ${ipv4_pfx} | ${ipv6_pfx} | ${ea_bit_len} | ${psid_offset} +| | ... | ${psid_len} | ${ipv4_dst} | ${dst_port} +| | ${ipv6_dst}= | Run Keyword If | "${expected_ipv6_dst}" == "${EMPTY}" +| | ... | Set Variable | ${computed_ipv6_dst} +| | ... | ELSE | Set Variable | ${expected_ipv6_dst} +| | Run Keyword If | "${expected_ipv6_dst}" != "${EMPTY}" +| | ... | IP Addresses Should be Equal +| | ... | ${computed_ipv6_dst} | ${expected_ipv6_dst} +| | ${ipv6_dst}= | Set Variable | ${computed_ipv6_dst} +| | Check encapsulation with traffic script +| | ... | ${ipv4_dst} | ${dst_port} | ${ipv6_dst} +| | Check decapsulation with traffic script +| | ... | ${ipv6_dst} | ${ipv4_dst} | ${dst_port} +| | [Teardown] | Run Keywords +| | ... | Map Del Domain | ${dut_node} | ${domain_index} | AND +| | ... | Show packet trace on all DUTs | ${nodes} | AND +| | ... | Clear packet trace on all DUTs | ${nodes} + +| Check encapsulation with traffic script +| | [Arguments] | ${ipv4_dst} | ${dst_port} | ${ipv6_dst} +| | Send IPv4 UDP and check headers for lightweight 4over6 +| | ... | ${tg_node} | ${tg_to_dut_if1} | ${tg_to_dut_if2} +| | ... | ${dut_to_tg_if1_mac} | ${ipv4_dst} | ${ipv4_outside} +| | ... | ${dst_port} | ${tg_to_dut_if2_mac} | ${dut_to_tg_if2_mac} +| | ... | ${ipv6_dst} | ${ipv6_br_src} + +| Check decapsulation with traffic script +| | [Arguments] | ${ipv6_ce_addr} | ${ipv4_inside} | ${port} +| | Send IPv4 UDP in IPv6 and check headers for lightweight 4over6 +| | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if1} +| | ... | ${dut_to_tg_if2_mac} | ${tg_to_dut_if2_mac} +| | ... | ${ipv6_br_src} | ${ipv6_ce_addr} +| | ... | ${ipv4_outside} | ${ipv4_inside} | ${port} +| | ... | ${tg_to_dut_if1_mac} | ${dut_to_tg_if1_mac} -- 2.16.6