diff options
-rw-r--r-- | GPL/traffic_scripts/PacketVerifier.py | 5 | ||||
-rw-r--r-- | GPL/traffic_scripts/geneve_tunnel.py | 348 | ||||
-rw-r--r-- | GPL/traffic_scripts/vxlan.py | 1 | ||||
-rw-r--r-- | docs/tag_documentation.rst | 12 | ||||
-rw-r--r-- | resources/api/vpp/supported_crcs.yaml | 8 | ||||
-rw-r--r-- | resources/libraries/python/GeneveUtil.py | 126 | ||||
-rw-r--r-- | resources/libraries/python/LispSetup.py | 4 | ||||
-rw-r--r-- | resources/libraries/python/VPPUtil.py | 23 | ||||
-rw-r--r-- | resources/libraries/python/topology.py | 2 | ||||
-rw-r--r-- | resources/libraries/robot/ip/geneve.robot | 74 | ||||
-rw-r--r-- | resources/libraries/robot/shared/test_teardown.robot | 136 | ||||
-rw-r--r-- | resources/libraries/robot/shared/traffic.robot | 91 | ||||
-rw-r--r-- | tests/vpp/device/ip4_tunnels/eth2p-ethip4--ethip4udpgeneve-1tun-ip4base-dev.robot | 107 |
13 files changed, 845 insertions, 92 deletions
diff --git a/GPL/traffic_scripts/PacketVerifier.py b/GPL/traffic_scripts/PacketVerifier.py index c915921625..bb91b9361c 100644 --- a/GPL/traffic_scripts/PacketVerifier.py +++ b/GPL/traffic_scripts/PacketVerifier.py @@ -331,9 +331,10 @@ def create_gratuitous_arp_request(src_mac, src_ip): def auto_pad(packet): """Pads zeroes at the end of the packet if the total packet length is less - then 64 bytes in case of IPv4 or 78 bytes in case of IPv6. + then 60 bytes in case of IPv4 or 78 bytes in case of IPv6. """ - min_len = 78 if packet.haslayer(IPv6) else 64 + # TODO: add document explaining deduction of FCS part + min_len = 78 if packet.haslayer(IPv6) else 60 pad_layer = Raw if packet.haslayer(Raw) \ else Padding if packet.haslayer(Padding) else None if pad_layer: diff --git a/GPL/traffic_scripts/geneve_tunnel.py b/GPL/traffic_scripts/geneve_tunnel.py new file mode 100644 index 0000000000..2fec3b0ac6 --- /dev/null +++ b/GPL/traffic_scripts/geneve_tunnel.py @@ -0,0 +1,348 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2020 Cisco and/or its affiliates. +# +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Licensed under the Apache License 2.0 or +# GNU General Public License v2.0 or later; you may not use this file +# except in compliance with one of these Licenses. You +# may obtain a copy of the Licenses at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html +# +# Note: If this file is linked with Scapy, which is GPLv2+, your use of it +# must be under GPLv2+. If at any point in the future it is no longer linked +# with Scapy (or other GPLv2+ licensed software), you are free to choose +# Apache 2. +# +# 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. + +"""Traffic script for GENEVE tunnel verification.""" + +import sys + +from ipaddress import ip_address +from scapy.contrib.geneve import GENEVE +from scapy.layers.inet import IP, UDP +from scapy.layers.inet6 import IPv6, ICMPv6ND_NS +from scapy.layers.l2 import Ether +from scapy.packet import Raw + +from .PacketVerifier import RxQueue, TxQueue +from .TrafficScriptArg import TrafficScriptArg + + +def check_geneve( + pkt_recv, ip_layer, outer_src_mac, outer_dst_mac, inner_src_mac, + inner_dst_mac, outer_src_ip, outer_dst_ip, inner_src_ip, inner_dst_ip, + udp_dport, gen_vni): + """Check received GENEVE packet. + + :param pkt_recv: Received packet to verify. + :param ip_layer: Scapy IP or IPv6 layer. + :param outer_src_mac: Outer source MAC address. + :param outer_dst_mac: Outer destination MAC address. + :param inner_src_mac: Inner source MAC address. + :param inner_dst_mac: Inner destination MAC address. + :param outer_src_ip: Outer source IP/IPv6 address. + :param outer_dst_ip: Outer destination IP/IPv6 address. + :param inner_src_ip: Inner source IP/IPv6 address. + :param inner_dst_ip: Inner destination IP/IPv6 address. + :param udp_dport: UDP destination port. + :param gen_vni: GENEVE VNI. + :type pkt_recv: scapy.Ether + :type ip_layer: scapy.layers.inet.IP or scapy.layers.inet6.IPv6 + :type outer_src_mac: str + :type outer_dst_mac: str + :type inner_src_mac: str + :type inner_dst_mac: str + :type outer_src_ip: str + :type outer_dst_ip: str + :type inner_src_ip: str + :type inner_dst_ip: str + :type udp_dport: int + :type gen_vni: int + :raises RuntimeError: If received packet is invalid. + """ + try: + if not isinstance(pkt_recv[0], Ether): + raise RuntimeError( + f"Received packet hasn't outer Ether layer: {pkt_recv!r}" + ) + elif not isinstance(pkt_recv[1], ip_layer): + raise RuntimeError( + f"Received packet hasn't outer {ip_layer.__name__} layer: " + f"{pkt_recv!r}" + ) + elif not isinstance(pkt_recv[2], UDP): + raise RuntimeError( + f"Received packet hasn't UDP layer: {pkt_recv!r}" + ) + elif not isinstance(pkt_recv[3], GENEVE): + raise RuntimeError( + f"Received packet hasn't GENEVE layer: {pkt_recv!r}" + ) + elif not isinstance(pkt_recv[4], Ether): + raise RuntimeError( + f"Received packet hasn't inner Ether layer: {pkt_recv!r}" + ) + elif not isinstance(pkt_recv[5], ip_layer): + raise RuntimeError( + f"Received packet hasn't inner {ip_layer.__name__} layer: " + f"{pkt_recv!r}" + ) + elif not isinstance(pkt_recv[6], Raw): + raise RuntimeError( + f"Received packet hasn't inner Raw layer: {pkt_recv!r}" + ) + except IndexError: + raise RuntimeError( + f"Received packet doesn't contain all layers: {pkt_recv!r}" + ) + + if pkt_recv[Ether].src != outer_src_mac: + raise RuntimeError( + f"Received frame has invalid outer source MAC address: " + f"{pkt_recv[Ether].src} should be: {outer_src_mac}" + ) + + if pkt_recv[Ether].dst != outer_dst_mac: + raise RuntimeError( + f"Received frame has invalid outer destination MAC address: " + f"{pkt_recv[Ether].dst} should be: {outer_dst_mac}" + ) + + if pkt_recv[ip_layer].src != outer_src_ip: + raise RuntimeError( + f"Received packet has invalid outer source address: " + f"{pkt_recv[ip_layer].src} should be: {outer_src_ip}" + ) + + if pkt_recv[ip_layer].dst != outer_dst_ip: + raise RuntimeError( + f"Received packet has invalid outer destination address: " + f"{pkt_recv[ip_layer].dst} should be: {outer_dst_ip}" + ) + + if pkt_recv[UDP].dport != udp_dport: + raise RuntimeError( + f"Received packet has invalid UDP dport: " + f"{pkt_recv[UDP].dport} should be: {udp_dport}" + ) + + if pkt_recv[GENEVE].vni != gen_vni: + raise RuntimeError( + f"Received packet has invalid GENEVE vni: " + f"{pkt_recv[GENEVE].vni} should be: {gen_vni}" + ) + + if pkt_recv[GENEVE].proto != 0x6558: + raise RuntimeError( + f"Received packet has invalid GENEVE protocol number: " + f"{pkt_recv[GENEVE].proto} should be: 0x6558" + ) + + if pkt_recv[Ether:2].src != inner_src_mac: + raise RuntimeError( + f"Received frame has invalid inner source MAC address: " + f"{pkt_recv[Ether:2].src} should be: {inner_src_mac}" + ) + + if pkt_recv[Ether:2].dst != inner_dst_mac: + raise RuntimeError( + f"Received frame has invalid inner destination MAC address: " + f"{pkt_recv[Ether:2].dst} should be: {inner_dst_mac}" + ) + + if pkt_recv[ip_layer:2].src != inner_src_ip: + raise RuntimeError( + f"Received packet has invalid inner source address: " + f"{pkt_recv[ip_layer:2].src} should be: {inner_src_ip}" + ) + + if pkt_recv[ip_layer:2].dst != inner_dst_ip: + raise RuntimeError( + f"Received packet has invalid inner destination address: " + f"{pkt_recv[ip_layer:2].dst} should be: {inner_dst_ip}" + ) + + +def check_ip(pkt_recv, ip_layer, src_mac, dst_mac, src_ip, dst_ip): + """Check received IP/IPv6 packet. + + :param pkt_recv: Received packet to verify. + :param ip_layer: Scapy IP layer. + :param src_mac: Source MAC address. + :param dst_mac: Destination MAC address. + :param src_ip: Source IP/IPv6 address. + :param dst_ip: Destination IP/IPv6 address. + :type pkt_recv: scapy.Ether + :type ip_layer: scapy.layers.inet.IP or scapy.layers.inet6.IPv6 + :type src_mac: str + :type dst_mac: str + :type src_ip: str + :type dst_ip: str + :raises RuntimeError: If received packet is invalid. + """ + if pkt_recv[Ether].src != src_mac: + raise RuntimeError( + f"Received frame has invalid source MAC address: " + f"{pkt_recv[Ether].src} should be: {src_mac}" + ) + + if pkt_recv[Ether].dst != dst_mac: + raise RuntimeError( + f"Received frame has invalid destination MAC address: " + f"{pkt_recv[Ether].dst} should be: {dst_mac}" + ) + + if not pkt_recv.haslayer(ip_layer): + raise RuntimeError( + f"Not an {ip_layer.__name__} packet received: {pkt_recv!r}" + ) + + if pkt_recv[ip_layer].dst != dst_ip: + raise RuntimeError( + f"Received packet has invalid destination {ip_layer.__name__} " + f"address: {pkt_recv[ip_layer.__name__].dst} should be: {dst_ip}" + ) + + if pkt_recv[ip_layer].src != src_ip: + raise RuntimeError( + f"Received packet has invalid destination {ip_layer.__name__} " + f"address: {pkt_recv[ip_layer.__name__].dst} should be: {src_ip}" + ) + + if ip_layer == IP and pkt_recv[ip_layer].proto != 61: + raise RuntimeError( + f"Received packet has invalid IP protocol: " + f"{pkt_recv[ip_layer].proto} should be: 61" + ) + + +def main(): + """Send and receive GENEVE packets.""" + + args = TrafficScriptArg( + [ + u"tx_src_mac", u"tx_dst_mac", u"rx_src_mac", u"rx_dst_mac", + u"tun_local_ip", u"tun_remote_ip", u"tun_vni", u"tun_src_ip", + u"tun_dst_ip" + ] + ) + + tx_txq = TxQueue(args.get_arg(u"tx_if")) + tx_rxq = RxQueue(args.get_arg(u"tx_if")) + rx_txq = TxQueue(args.get_arg(u"rx_if")) + rx_rxq = RxQueue(args.get_arg(u"rx_if")) + + rx_src_mac = args.get_arg(u"rx_src_mac") + rx_dst_mac = args.get_arg(u"rx_dst_mac") + tx_src_mac = args.get_arg(u"tx_src_mac") + tx_dst_mac = args.get_arg(u"tx_dst_mac") + + tun_local_ip = args.get_arg(u"tun_local_ip") + tun_remote_ip = args.get_arg(u"tun_remote_ip") + tun_vni = args.get_arg(u"tun_vni") + tun_src_ip = args.get_arg(u"tun_src_ip") + tun_dst_ip = args.get_arg(u"tun_dst_ip") + + geneve_tunnel_mac = u"d0:0b:ee:d0:00:00" + geneve_udp_dport = 6081 + + tx_sent_packets = list() + src_ip = ip_address(tun_src_ip) + dst_ip = ip_address(tun_dst_ip) + ip_layer = IP if src_ip.version == 4 else IPv6 + tx_ip_pkt = ip_layer(src=src_ip, dst=dst_ip, proto=61) \ + if ip_layer == IP else ip_layer(src=src_ip, dst=dst_ip) + tx_pkt_send = (Ether(src=tx_src_mac, dst=tx_dst_mac) / tx_ip_pkt) + tx_pkt_send /= Raw() + size_limit = 78 if ip_layer == IPv6 else 60 + if len(tx_pkt_send) < size_limit: + tx_pkt_send[Raw].load += b"\0" * (size_limit - len(tx_pkt_send)) + + tx_sent_packets.append(tx_pkt_send) + tx_txq.send(tx_pkt_send) + + while True: + rx_pkt_recv = rx_rxq.recv(2) + + if rx_pkt_recv is None: + raise RuntimeError(f"GENEVE packet Rx timeout") + + if rx_pkt_recv.haslayer(ICMPv6ND_NS): + # read another packet in the queue if the current one is ICMPv6ND_NS + continue + else: + # otherwise process the current packet + break + + check_geneve( + rx_pkt_recv, ip_layer, rx_src_mac, rx_dst_mac, geneve_tunnel_mac, + rx_src_mac, tun_local_ip, tun_remote_ip, str(src_ip), str(dst_ip), + geneve_udp_dport, int(tun_vni) + ) + + rx_inner_ip_pkt = IP( + src=rx_pkt_recv[Ether:2][IP].dst, + dst=rx_pkt_recv[Ether:2][IP].src, + proto=61 + ) if isinstance(rx_pkt_recv[Ether:2][1], IP) else IPv6( + src=rx_pkt_recv[Ether:2][IPv6].dst, + dst=rx_pkt_recv[Ether:2][IPv6].src + ) + rx_inner_ip_pkt /= Raw() + rx_inner_pkt = ( + Ether(src=rx_pkt_recv[4].dst, dst=rx_pkt_recv[4].src) / + rx_inner_ip_pkt + ) + size_limit = 78 if isinstance(rx_pkt_recv[Ether:2][1], IPv6) else 60 + if len(rx_inner_pkt) < size_limit: + rx_inner_pkt[Raw].load += b"\0" * (size_limit - len(rx_inner_pkt)) + + rx_outer_ip_pkt = IP( + src=rx_pkt_recv[Ether:1][IP].dst, + dst=rx_pkt_recv[Ether:1][IP].src + ) if isinstance(rx_pkt_recv[Ether:1][1], IP) else IPv6( + src=rx_pkt_recv[Ether:1][IPv6].dst, + dst=rx_pkt_recv[Ether:1][IPv6].src + ) + rx_pkt_send = ( + Ether(src=rx_pkt_recv[Ether:1].dst, dst=rx_pkt_recv[Ether:1].src) / + rx_outer_ip_pkt / + UDP(sport=6081, dport=6081) / + GENEVE(vni=rx_pkt_recv[GENEVE].vni) / + rx_inner_pkt + ) + rx_txq.send(rx_pkt_send) + + while True: + tx_pkt_recv = tx_rxq.recv(2, ignore=tx_sent_packets) + ip_layer = IP + + if tx_pkt_recv is None: + raise RuntimeError(f"{ip_layer.__name__} packet Rx timeout") + + if tx_pkt_recv.haslayer(ICMPv6ND_NS): + # read another packet in the queue if the current one is ICMPv6ND_NS + continue + else: + # otherwise process the current packet + break + + check_ip( + tx_pkt_recv, ip_layer, tx_dst_mac, tx_src_mac, str(dst_ip), str(src_ip) + ) + + sys.exit(0) + + +if __name__ == u"__main__": + main() diff --git a/GPL/traffic_scripts/vxlan.py b/GPL/traffic_scripts/vxlan.py index 985784d6f5..33e5c7adff 100644 --- a/GPL/traffic_scripts/vxlan.py +++ b/GPL/traffic_scripts/vxlan.py @@ -37,5 +37,6 @@ class VXLAN(Packet): def mysummary(self): return self.sprintf(f"VXLAN (vni={VXLAN.vni})") + bind_layers(UDP, VXLAN, dport=4789) bind_layers(VXLAN, Ether) diff --git a/docs/tag_documentation.rst b/docs/tag_documentation.rst index c37df8508b..a2d9f8466f 100644 --- a/docs/tag_documentation.rst +++ b/docs/tag_documentation.rst @@ -219,6 +219,10 @@ Scaling Tags usually with 63 flow differing in source port number. Could be UDP or TCP. If NAT is used, the clients are inside. Outside IP range can differ. +.. topic:: GENEVE4_1TUN + + Test with 1 GENEVE IPv4 tunnel. + Test Category Tags ------------------ @@ -587,6 +591,14 @@ Encapsulation Tags All SRv6 test cases with two SIDs and without decapsulation. +.. topic:: GENEVE + + All test cases with GENEVE. + +.. topic:: GENEVE_L3MODE + + All test cases with GENEVE tunnel in L3 mode. + Interface Tags -------------- diff --git a/resources/api/vpp/supported_crcs.yaml b/resources/api/vpp/supported_crcs.yaml index 2d25a42dfa..7b5a718c29 100644 --- a/resources/api/vpp/supported_crcs.yaml +++ b/resources/api/vpp/supported_crcs.yaml @@ -43,6 +43,8 @@ # 6x^ tc01-64B-1c-ethip4udp-ip4base-iacl1sf-10kflows-mrr # tc01-64B-1c-ethip4udp-ip4base-iacl1sl-10kflows-mrr # ^^ ip4fwdANDiaclANDacl10AND100_flows + add_node_next: '0x2457116d' # dev + add_node_next_reply: '0x2ed75f32' # dev avf_create: '0xdaab8ae2' # dev avf_create_reply: '0x5383d31f' # dev bond_create: '0x48883c7e' # perf @@ -90,6 +92,10 @@ det44_session_dump: '0xe45a3af7' # perf teardown # TODO: Which test to run to verify det44_* messages? # dhcp_proxy_dump / details # honeycomb + geneve_add_del_tunnel2: '0x8c2a9999' # dev + geneve_add_del_tunnel2_reply: '0x5383d31f' # dev + geneve_tunnel_details: '0xe27e2748' # dev + geneve_tunnel_dump: '0xf9e6675e' # dev gpe_enable_disable: '0xc264d7bf' # dev gpe_enable_disable_reply: '0xe8d4e804' # dev # gre_tunnel_add_del / reply # unused L1 keyword: create_gre_tunnel_interface @@ -249,6 +255,8 @@ # ^ dot1qANDl2bdmaclrnANDbaseANDmemif sw_interface_set_flags: '0x6a2b491a' # dev sw_interface_set_flags_reply: '0xe8d4e804' # dev + sw_interface_set_geneve_bypass: '0x65247409' # dev + sw_interface_set_geneve_bypass_reply: '0xe8d4e804' # dev sw_interface_set_l2_bridge: '0x2e483cd0' # dev sw_interface_set_l2_bridge_reply: '0xe8d4e804' # dev sw_interface_set_l2_xconnect: '0x1aaa2dbb' # dev diff --git a/resources/libraries/python/GeneveUtil.py b/resources/libraries/python/GeneveUtil.py new file mode 100644 index 0000000000..3c8ebeebb3 --- /dev/null +++ b/resources/libraries/python/GeneveUtil.py @@ -0,0 +1,126 @@ +# Copyright (c) 2020 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. + +"""VPP GENEVE Plugin utilities library.""" + +from ipaddress import ip_address + +from resources.libraries.python.Constants import Constants +from resources.libraries.python.InterfaceUtil import InterfaceUtil +from resources.libraries.python.IPAddress import IPAddress +from resources.libraries.python.PapiExecutor import PapiSocketExecutor +from resources.libraries.python.topology import Topology + + +class GeneveUtil: + """VPP GENEVE Plugin Keywords.""" + + @staticmethod + def add_geneve_tunnel( + node, local_address, remote_address, vni, multicast_if=None, + encap_vrf=0, l3_mode=False, next_index=None): + """Add GENEVE tunnel on the specified VPP node. + + :param node: Topology node. + :param local_address: Local IP address. + :param remote_address: Remote IP address. + :param vni: Virtual network ID. + :param multicast_if: Interface key of multicast interface; used only if + remote is multicast. (Default value = None) + :param encap_vrf: The FIB ID for sending unicast GENEVE encap packets or + receiving multicast packets. (Default value = 0) + :param l3_mode: Use geneve tunnel in L3 mode (ip routing) if Tue else in + L2 mode (L2 switching). (Default value = False) + :param next_index: The index of the next node. + :type node: dict + :type local_address: str + :type remote_address: str + :type vni: int + :type multicast_if: str + :type encap_vrf: int + :type l3_mode: bool + :type next_index: int + :returns: SW interface index of created geneve tunnel. + :rtype: int + """ + cmd = u"geneve_add_del_tunnel2" + args = dict( + is_add=True, + local_address=IPAddress.create_ip_address_object( + ip_address(local_address) + ), + remote_address=IPAddress.create_ip_address_object( + ip_address(remote_address) + ), + mcast_sw_if_index=Topology.get_interface_sw_index( + node, multicast_if + ) if multicast_if else Constants.BITWISE_NON_ZERO, + encap_vrf_id=int(encap_vrf), + decap_next_index=next_index if l3_mode + else Constants.BITWISE_NON_ZERO, + vni=int(vni), + l3_mode=l3_mode + ) + err_msg = f"Failed to configure GENEVE tunnel on host {node[u'host']}!" + with PapiSocketExecutor(node) as papi_exec: + sw_if_index = papi_exec.add(cmd, **args).get_sw_if_index(err_msg) + + if_key = Topology.add_new_port(node, u"geneve_tunnel") + Topology.update_interface_sw_if_index(node, if_key, sw_if_index) + + ifc_name = InterfaceUtil.vpp_get_interface_name(node, sw_if_index) + Topology.update_interface_name(node, if_key, ifc_name) + + ifc_mac = InterfaceUtil.vpp_get_interface_mac(node, sw_if_index) + Topology.update_interface_mac_address(node, if_key, ifc_mac) + + return sw_if_index + + @staticmethod + def enable_interface_geneve_bypass(node, interface, is_ipv6=False): + """Add ipv4/ipv6-geneve-bypass graph node for a given interface on + the specified VPP node. + + :param node: Topology node. + :param interface: Interface key from topology file of interface + to add geneve bypass node for. + :param is_ipv6: Enable ipv6-geneve-bypass graph node if True else enable + ipv4-geneve-bypass graph node. + :type node: dict + :type interface: str + :type is_ipv6: bool + """ + cmd = u"sw_interface_set_geneve_bypass" + args = dict( + is_ipv6=is_ipv6, + enable=True, + sw_if_index=Topology.get_interface_sw_index(node, interface) + ) + err_msg = ( + f"Failed to enable {u'ipv6' if is_ipv6 else u'ipv4'}-geneve-bypass " + f"on interface {interface} on host {node[u'host']}!" + ) + with PapiSocketExecutor(node) as papi_exec: + papi_exec.add(cmd, **args).get_reply(err_msg) + + @staticmethod + def show_geneve_tunnel_data(node): + """Show the GENEVE tunnels data. + + :param node: DUT node. + :type node: dict + """ + cmds = [ + u"geneve_tunnel_dump", + ] + PapiSocketExecutor.dump_and_log(node, cmds) diff --git a/resources/libraries/python/LispSetup.py b/resources/libraries/python/LispSetup.py index 59cb1a808d..6579764596 100644 --- a/resources/libraries/python/LispSetup.py +++ b/resources/libraries/python/LispSetup.py @@ -40,8 +40,8 @@ class LispEid: :type eid: str :type prefix_len: int """ - eid_addr = dict(prefix=IPUtil.create_prefix_object( - ip_address(eid), prefix_len) + eid_addr = dict( + prefix=IPUtil.create_prefix_object(ip_address(eid), prefix_len) ) if prefix_len else dict(mac=str(eid)) return dict( diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py index c735494282..a7ec44c974 100644 --- a/resources/libraries/python/VPPUtil.py +++ b/resources/libraries/python/VPPUtil.py @@ -361,3 +361,26 @@ class VPPUtil: logger.trace(f"show threads:\n{threads_data}") return threads_data + + @staticmethod + def vpp_add_graph_node_next(node, graph_node_name, graph_next_name): + """Set the next node for a given node. + + :param node: Node to run command on. + :param graph_node_name: Graph node to add the next node on. + :param graph_next_name: Graph node to add as the next node. + :type node: dict + :type graph_node_name: str + :type graph_next_name: str + :returns: The index of the next node. + :rtype: int + """ + cmd = u"add_node_next" + args = dict( + node_name=graph_node_name, + next_name=graph_next_name + ) + with PapiSocketExecutor(node) as papi_exec: + reply = papi_exec.add(cmd, **args).get_reply() + + return reply[u"next_index"] diff --git a/resources/libraries/python/topology.py b/resources/libraries/python/topology.py index 338ccb6b57..2b930c08dc 100644 --- a/resources/libraries/python/topology.py +++ b/resources/libraries/python/topology.py @@ -174,7 +174,7 @@ class Topology: port_types = ( u"subinterface", u"vlan_subif", u"memif", u"tap", u"vhost", u"loopback", u"gre_tunnel", u"vxlan_tunnel", u"eth_bond", - u"eth_avf", u"eth_rdma" + u"eth_avf", u"eth_rdma", u"geneve_tunnel" ) for node_data in nodes.values(): diff --git a/resources/libraries/robot/ip/geneve.robot b/resources/libraries/robot/ip/geneve.robot new file mode 100644 index 0000000000..c9de91d708 --- /dev/null +++ b/resources/libraries/robot/ip/geneve.robot @@ -0,0 +1,74 @@ +# Copyright (c) 2020 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 *** +| Library | resources.libraries.python.GeneveUtil +| +| Documentation | Keywords for GENEVE tunnels in VPP. + +*** Keywords *** +| Initialize GENEVE L3 mode in circular topology +| | [Documentation] | Initialization of GENEVE L3 mode on DUT1. +| | +| | [Arguments] | ${with_bypass}=${False} +| | +| | Set interfaces in path up +| | +| | VPP Interface Set IP Address +| | ... | ${dut1} | ${DUT1_${int}1}[0] | ${dut1_if1_ip4} | 24 +| | VPP Add IP Neighbor +| | ... | ${dut1} | ${DUT1_${int}1}[0] | ${tg_if1_ip4} | ${TG_pf1_mac}[0] +| | VPP Interface Set IP Address +| | ... | ${dut1} | ${DUT1_${int}2}[0] | ${dut1_if2_ip4} | 24 +| | VPP Add IP Neighbor +| | ... | ${dut1} | ${DUT1_${int}2}[0] | ${tg_if2_ip4} | ${TG_pf2_mac}[0] +| | ${next_index}= | VPP Add Graph Node Next +| | ... | ${dut1} | geneve4-input | ethernet-input +| | +| | ${src_ip_int} = | IP To Int | ${gen_tunnel.src_ip} +| | ${dst_ip_int} = | IP To Int | ${gen_tunnel.dst_ip} +| | ${if_ip_int} = | IP To Int | ${gen_tunnel.if_ip} +| | +| | FOR | ${nr} | IN RANGE | 0 | ${n_tunnels} +| | | ${src_ip} = | Int To IP | ${${src_ip_int} + ${nr} * 256} +| | | ${dst_ip} = | Int To IP | ${${dst_ip_int} + ${nr} * 256} +| | | ${if_ip} = | Int To IP | ${${if_ip_int} + ${nr} * 256} +| | | Vpp Route Add +| | | ... | ${dut1} | ${src_ip} | ${gen_tunnel.ip_mask} +| | | ... | gateway=${tg_if1_ip4} | interface=${DUT1_${int}1}[0] +| | | ${tunnel_sw_index}= | Add Geneve Tunnel +| | | ... | ${dut1} | ${gen_tunnel.local} | ${gen_tunnel.remote} +| | | ... | ${${gen_tunnel.vni} + ${nr}} | l3_mode=${True} +| | | ... | next_index=${next_index} +| | | ${tunnel_if_key}= | Get Interface By SW Index +| | | ... | ${dut1} | ${tunnel_sw_index} +| | | ${tunnel_if_mac}= | Get Interface MAC +| | | ... | ${dut1} | ${tunnel_if_key} +| | | VPP Interface Set IP Address +| | | ... | ${dut1} | ${tunnel_if_key} | ${if_ip} | 24 +| | | VPP Add IP Neighbor +| | | ... | ${dut1} | ${tunnel_if_key} | ${dut1_if2_ip4} | ${DUT1_vf2_mac}[0] +| | | Vpp Route Add +| | | ... | ${dut1} | ${dst_ip} | ${gen_tunnel.ip_mask} +| | | ... | gateway=${dut1_if2_ip4} | interface=${tunnel_if_key} +| | | Vpp Route Add +| | | ... | ${dut1} | ${gen_tunnel.remote} | 32 +| | | ... | gateway=${tg_if2_ip4} | interface=${DUT1_${int}2}[0] +| | | VPP Add IP Neighbor +| | | ... | ${dut1} | ${tunnel_if_key} | ${gen_tunnel.local} | ${tunnel_if_mac} +| | | Vpp Route Add +| | | ... | ${dut1} | ${gen_tunnel.local} | 32 | gateway=${if_ip} +| | | Set Interface State +| | | ... | ${dut1} | ${tunnel_if_key} | up +| | END +| | All VPP Interfaces Ready Wait | ${nodes} | retries=${60} diff --git a/resources/libraries/robot/shared/test_teardown.robot b/resources/libraries/robot/shared/test_teardown.robot index c3d1e8a5ca..d6df417db1 100644 --- a/resources/libraries/robot/shared/test_teardown.robot +++ b/resources/libraries/robot/shared/test_teardown.robot @@ -61,30 +61,22 @@ | | END | | Clean Sockets On All Nodes | ${nodes} -| Additional Test Tear Down Action For performance +# Additional Test Tear Down Actions in alphabetical order +| Additional Test Tear Down Action For acl | | [Documentation] -| | ... | Additional teardown for tests which uses performance measurement. -| | ... | Optionally, call \${resetter} (if defined) to reset DUT state. -| | -| | ... | TODO: Document what test variables are required or optional. +| | ... | Additional teardown for tests which uses ACL feature. | | -| | Run Keyword If Test Passed | Return From Keyword -| | ${use_latency} = | Get Use Latency -| | ${rate_for_teardown} = | Get Rate For Teardown -| | Call Resetter -| | Set Test Variable | \${extended_debug} | ${True} -| | Send traffic at specified rate -| | ... | trial_duration=${1.0} -| | ... | rate=${rate_for_teardown} -| | ... | trial_multiplicity=${1} -| | ... | use_latency=${use_latency} -| | ... | duration_limit=${1.0} +| | Run Keyword If Test Failed +| | ... | Vpp Log Plugin Acl Settings | ${dut1} +| | Run Keyword If Test Failed +| | ... | Vpp Log Plugin Acl Interface Assignment | ${dut1} -| Additional Test Tear Down Action For packet_trace +| Additional Test Tear Down Action For classify | | [Documentation] -| | ... | Additional teardown for tests which uses packet trace. +| | ... | Additional teardown for tests which uses classify tables. | | -| | Show Packet Trace on All DUTs | ${nodes} +| | Run Keyword If Test Failed +| | ... | Show Classify Tables Verbose on all DUTs | ${nodes} | Additional Test Tear Down Action For container | | [Documentation] @@ -94,23 +86,6 @@ | | | Destroy all '${container_group}' containers | | END -| Additional Test Tear Down Action For vhost -| | [Documentation] -| | ... | Additional teardown for tests which uses vhost(s) and VM(s). -| | -| | Show VPP vhost on all DUTs | ${nodes} -| | ${vnf_status} | ${value}= | Run Keyword And Ignore Error -| | ... | Keyword Should Exist | vnf_manager.Kill All VMs -| | Run Keyword If | '${vnf_status}' == 'PASS' | vnf_manager.Kill All VMs - -| Additional Test Tear Down Action For vhost-pt -| | [Documentation] -| | ... | Additional teardown for tests which uses pci-passtrough and VM(s). -| | -| | ${vnf_status} | ${value}= | Run Keyword And Ignore Error -| | ... | Keyword Should Exist | vnf_manager.Kill All VMs -| | Run Keyword If | '${vnf_status}' == 'PASS' | vnf_manager.Kill All VMs - | Additional Test Tear Down Action For det44 | | [Documentation] | | ... | Additional teardown for tests which uses DET44 feature. @@ -120,23 +95,13 @@ | | | ... | Show DET44 verbose | ${nodes['${dut}']} | | END -| Additional Test Tear Down Action For nat-ed +| Additional Test Tear Down Action For geneve4 | | [Documentation] -| | ... | Additional teardown for tests which uses NAT feature. +| | ... | Additional teardown for tests which uses GENEVE IPv4 tunnel. | | | | FOR | ${dut} | IN | @{duts} -| | | Show NAT44 Config | ${nodes['${dut}']} -| | | Show NAT44 Summary | ${nodes['${dut}']} -| | | Show NAT Base Data | ${nodes['${dut}']} -| | | Vpp Get Ip Table Summary | ${nodes['${dut}']} -| | END - -| Additional Test Tear Down Action For namespace -| | [Documentation] -| | ... | Additional teardown for tests which uses namespace. -| | -| | FOR | ${dut} | IN | @{duts} -| | | Clean Up Namespaces | ${nodes['${dut}']} +| | | Run Keyword If Test Failed +| | | ... | Show Geneve Tunnel Data | ${nodes['${dut}']} | | END | Additional Test Tear Down Action For linux_bridge @@ -147,15 +112,6 @@ | | | Linux Del Bridge | ${nodes['${dut}']} | ${bid_TAP} | | END -| Additional Test Tear Down Action For acl -| | [Documentation] -| | ... | Additional teardown for tests which uses ACL feature. -| | -| | Run Keyword If Test Failed -| | ... | Vpp Log Plugin Acl Settings | ${dut1} -| | Run Keyword If Test Failed -| | ... | Vpp Log Plugin Acl Interface Assignment | ${dut1} - | Additional Test Tear Down Action For macipacl | | [Documentation] | | ... | Additional teardown for tests which uses MACIP ACL feature. @@ -165,12 +121,49 @@ | | Run Keyword If Test Failed | | ... | Vpp Log Macip Acl Interface Assignment | ${dut1} -| Additional Test Tear Down Action For classify +| Additional Test Tear Down Action For namespace | | [Documentation] -| | ... | Additional teardown for tests which uses classify tables. +| | ... | Additional teardown for tests which uses namespace. | | -| | Run Keyword If Test Failed -| | ... | Show Classify Tables Verbose on all DUTs | ${nodes} +| | FOR | ${dut} | IN | @{duts} +| | | Clean Up Namespaces | ${nodes['${dut}']} +| | END + +| Additional Test Tear Down Action For nat-ed +| | [Documentation] +| | ... | Additional teardown for tests which uses NAT feature. +| | +| | FOR | ${dut} | IN | @{duts} +| | | Show NAT44 Config | ${nodes['${dut}']} +| | | Show NAT44 Summary | ${nodes['${dut}']} +| | | Show NAT Base Data | ${nodes['${dut}']} +| | | Vpp Get Ip Table Summary | ${nodes['${dut}']} +| | END + +| Additional Test Tear Down Action For packet_trace +| | [Documentation] +| | ... | Additional teardown for tests which uses packet trace. +| | +| | Show Packet Trace on All DUTs | ${nodes} + +| Additional Test Tear Down Action For performance +| | [Documentation] +| | ... | Additional teardown for tests which uses performance measurement. +| | ... | Optionally, call \${resetter} (if defined) to reset DUT state. +| | +| | ... | TODO: Document what test variables are required or optional. +| | +| | Run Keyword If Test Passed | Return From Keyword +| | ${use_latency} = | Get Use Latency +| | ${rate_for_teardown} = | Get Rate For Teardown +| | Call Resetter +| | Set Test Variable | \${extended_debug} | ${True} +| | Send traffic at specified rate +| | ... | trial_duration=${1.0} +| | ... | rate=${rate_for_teardown} +| | ... | trial_multiplicity=${1} +| | ... | use_latency=${use_latency} +| | ... | duration_limit=${1.0} | Additional Test Tear Down Action For srv6 | | [Documentation] @@ -182,3 +175,20 @@ | | ... | Show SR Steering Policies on all DUTs | ${nodes} | | Run Keyword If Test Failed | | ... | Show SR LocalSIDs on all DUTs | ${nodes} + +| Additional Test Tear Down Action For vhost +| | [Documentation] +| | ... | Additional teardown for tests which uses vhost(s) and VM(s). +| | +| | Show VPP vhost on all DUTs | ${nodes} +| | ${vnf_status} | ${value}= | Run Keyword And Ignore Error +| | ... | Keyword Should Exist | vnf_manager.Kill All VMs +| | Run Keyword If | '${vnf_status}' == 'PASS' | vnf_manager.Kill All VMs + +| Additional Test Tear Down Action For vhost-pt +| | [Documentation] +| | ... | Additional teardown for tests which uses pci-passtrough and VM(s). +| | +| | ${vnf_status} | ${value}= | Run Keyword And Ignore Error +| | ... | Keyword Should Exist | vnf_manager.Kill All VMs +| | Run Keyword If | '${vnf_status}' == 'PASS' | vnf_manager.Kill All VMs diff --git a/resources/libraries/robot/shared/traffic.robot b/resources/libraries/robot/shared/traffic.robot index 1f10787bc1..08f579c9df 100644 --- a/resources/libraries/robot/shared/traffic.robot +++ b/resources/libraries/robot/shared/traffic.robot @@ -61,7 +61,7 @@ | | | | ... | *Example:* | | -| | ... | \| Send packet and verify headers \| ${nodes['TG']} \| 10.0.0.1 \ +| | ... | \| Send packet and verify headers \| \${nodes['TG']} \| 10.0.0.1 \ | | ... | \| 32.0.0.1 \| eth2 \| 08:00:27:ee:fd:b3 \| 08:00:27:a2:52:5b \ | | ... | \| eth3 \| 08:00:27:4d:ca:7a \| 08:00:27:7d:fd:10 \| | | @@ -120,7 +120,7 @@ | | ... | *Example:* | | | | ... | \| Packet transmission from port to port should fail \ -| | ... | \| ${nodes['TG']} \| 10.0.0.1 \ \| 32.0.0.1 \| eth2 \ +| | ... | \| \${nodes['TG']} \| 10.0.0.1 \ \| 32.0.0.1 \| eth2 \ | | ... | \| 08:00:27:a2:52:5b \| eth3 \| 08:00:27:4d:ca:7a \ | | ... | \| 08:00:27:ee:fd:b3 \| 08:00:27:7d:fd:10 \| | | [Arguments] | ${tg_node} | ${src_ip} | ${dst_ip} | ${tx_src_port} @@ -150,7 +150,7 @@ | | ... | - dst_ip - Packet destination IP address. Type: string | | | | ... | *Example:* -| | ... | \| Send packet and verify marking \| ${nodes['TG']} \| eth1 \| eth2 \ +| | ... | \| Send packet and verify marking \| \${nodes['TG']} \| eth1 \| eth2 \ | | ... | \| 08:00:27:87:4d:f7 \| 52:54:00:d4:d8:22 \| 192.168.122.2 \ | | ... | \| 192.168.122.1 \| | | @@ -190,9 +190,9 @@ | | ... | *Example:* | | | | ... | \| Send VXLAN encapsulated packet and verify received packet \ -| | ... | \| ${tg_node} \| port4 \| port4 \ +| | ... | \| \${tg_node} \| port4 \| port4 \ | | ... | \| fa:16:3e:6d:f9:c5 \| fa:16:3e:e6:6d:9a \| 192.168.0.1 \ -| | ... | \| 192.168.0.2 \| ${101} \| 192.168.0.2 \| 192.168.0.1 \| ${102} \| +| | ... | \| 192.168.0.2 \| ${101} \| 192.168.0.2 \| 192.168.0.1 \| \${102} \| | | | | [Arguments] | ${tg_node} | ${tx_if} | ${rx_if} | | ... | ${tx_src_mac} | ${tx_dst_mac} @@ -231,7 +231,7 @@ | | ... | *Example:* | | | | ... | \| Send ICMP echo request and verify answer \ -| | ... | \| ${nodes['TG']} \| eth2 \ +| | ... | \| \${nodes['TG']} \| eth2 \ | | ... | \| 08:00:27:46:2b:4c \| 08:00:27:66:b8:57 \ | | ... | \| 192.168.23.10 \| 192.168.23.1 \| 10 \| | | @@ -270,14 +270,14 @@ | | ... | - r_tunnel - Remote tunnel IP address (optional). Type: string | | | | ... | *Example:* -| | ... | \| ${encr_alg}= \| Crypto Alg AES CBC 128 \| -| | ... | \| ${auth_alg}= \| Integ Alg SHA1 96 \| +| | ... | \| \${encr_alg}= \| Crypto Alg AES CBC 128 \| +| | ... | \| \${auth_alg}= \| Integ Alg SHA1 96 \| | | ... | \| Send IPsec Packet and verify ESP encapsulation in received packet\ -| | ... | \| ${nodes['TG']} \| eth1 \| eth2 \ -| | ... | \| 52:54:00:d4:d8:22 \| 52:54:00:d4:d8:3e \| ${encr_alg} \ +| | ... | \| \${nodes['TG']} \| eth1 \| eth2 \ +| | ... | \| 52:54:00:d4:d8:22 \| 52:54:00:d4:d8:3e \| \${encr_alg} \ | | ... | \| sixteenbytes_key \| ${auth_alg} \| twentybytessecretkey \ -| | ... | \| ${1001} \| ${1000} \| 192.168.3.3 \| 192.168.4.4 \| 192.168.100.2 \ -| | ... | \| 192.168.100.3 \| +| | ... | \| \${1001} \| \00} \| 192.168.3.3 \| 192.168.4.4 \ +| | ... | \| 192.168.100.2 \| 192.168.100.3 \| | | | | [Arguments] | ${node} | ${tx_interface} | ${rx_interface} | ${tx_dst_mac} | | ... | ${rx_src_mac} | ${crypto_alg} | ${crypto_key} | ${integ_alg} @@ -329,7 +329,7 @@ | | | | ... | *Example:* | | -| | ... | \| Send packet and verify LISP encap \| ${nodes['TG']} \| 10.0.0.1 \ +| | ... | \| Send packet and verify LISP encap \| \${nodes['TG']} \| 10.0.0.1 \ | | ... | \| 32.0.0.1 \| eth2 \| 08:00:27:ee:fd:b3 \| 08:00:27:a2:52:5b \ | | ... | \| eth3 \| 08:00:27:4d:ca:7a \| 08:00:27:7d:fd:10 \| 10.0.1.1 \ | | ... | \| 10.0.1.2 \| @@ -373,14 +373,14 @@ | | ... | - dst_tun - Destination tunnel IP address. Type: string | | | | ... | *Example:* -| | ... | \| ${encr_alg}= \| Crypto Alg AES CBC 128 \| -| | ... | \| ${auth_alg}= \| Integ Alg SHA1 96 \| +| | ... | \| \${encr_alg}= \| Crypto Alg AES CBC 128 \| +| | ... | \| \${auth_alg}= \| Integ Alg SHA1 96 \| | | ... | \| Send IPsec Packet and verify ESP encapsulation in received packet\ -| | ... | \| ${nodes['TG']} \| eth1 \| eth2 \ -| | ... | \| 52:54:00:d4:d8:22 \| 52:54:00:d4:d8:3e \| ${encr_alg} \ -| | ... | \| sixteenbytes_key \| ${auth_alg} \| twentybytessecretkey \ -| | ... | \| ${1001} \| ${1000} \| 192.168.3.3 \| 192.168.4.4 \| 192.168.100.2 \ -| | ... | \| 192.168.100.3 \| +| | ... | \| \${nodes['TG']} \| eth1 \| eth2 \ +| | ... | \| 52:54:00:d4:d8:22 \| 52:54:00:d4:d8:3e \| \${encr_alg} \ +| | ... | \| sixteenbytes_key \| \${auth_alg} \| twentybytessecretkey \ +| | ... | \| \${1001} \| \${1000} \| 192.168.3.3 \| 192.168.4.4 \ +| | ... | \| 192.168.100.2 \| 192.168.100.3 \| | | | | [Arguments] | ${node} | ${tx_interface} | ${rx_interface} | ${tx_dst_mac} | | ... | ${rx_src_mac} | ${crypto_alg} | ${crypto_key} | ${integ_alg} @@ -429,7 +429,7 @@ | | | | ... | *Example:* | | -| | ... | \| Send packet and verify LISP GPE encap \| ${nodes['TG']} \ +| | ... | \| Send packet and verify LISP GPE encap \| \${nodes['TG']} \ | | ... | \| 10.0.0.1 \| 32.0.0.1 \ | | ... | \| eth2 \| 08:00:27:ee:fd:b3 \| 08:00:27:a2:52:5b \ | | ... | \| eth3 \| 08:00:27:4d:ca:7a \| 08:00:27:7d:fd:10 \ @@ -476,7 +476,7 @@ | | | | ... | *Example:* | | -| | ... | \| Send packet and verify LISP encap \| ${nodes['TG']} \| 10.0.0.1 \ +| | ... | \| Send packet and verify LISP encap \| \${nodes['TG']} \| 10.0.0.1 \ | | ... | \| 32.0.0.1 \| eth2 \| 08:00:27:ee:fd:b3 \| 08:00:27:a2:52:5b \ | | ... | \| eth3 \| 08:00:27:4d:ca:7a \| 08:00:27:7d:fd:10 \| 10.0.1.1 \ | | ... | \| 10.0.1.2 \| @@ -529,7 +529,7 @@ | | | | ... | *Example:* | | ... | \| Send IPv6 Packet and verify SRv6 encapsulation in received packet\ -| | ... | \| ${nodes['TG']} \| eth1 \| eth2 \ +| | ... | \| \${nodes['TG']} \| eth1 \| eth2 \ | | ... | \| 52:54:00:d4:d8:22 \| 52:54:00:d4:d8:3e \| 2002:1:: \ | | ... | \| 2003:2:: \| 2003:1:: \| 2002:2:: \| decap=${False} \ | | ... | \| tg_dstsid3=2002:4:: \| dut_dstsid3=2003:4:: \ @@ -589,7 +589,7 @@ | | ... | *Example:* | | | | ... | \| Send TCP or UDP packet and verify network address translations \ -| | ... | \| ${nodes['TG']} \| port1 \| port2 \| 08:00:27:cc:4f:54 \ +| | ... | \| \${nodes['TG']} \| port1 \| port2 \| 08:00:27:cc:4f:54 \ | | ... | \| 08:00:27:c9:6a:d5 \| 192.168.0.0 \| 68.142.68.0 \| 20.0.0.0 \ | | ... | \| TCP \| 1024 \| 8080 \| | | @@ -609,3 +609,46 @@ | | ... | --src_port_in ${src_port_in} | --src_port_out ${src_port_out} | | ... | --dst_port ${dst_port} | | Run Traffic Script On Node | nat.py | ${tg_node} | ${args} + +| Send IP packet and verify GENEVE encapsulation in received packets +| | [Documentation] | Send IP packet from TG to DUT. Receive GENEVE packet\ +| | ... | from DUT on TG and verify GENEVE encapsulation. Send GENEVE packet in\ +| | ... | opposite direction and verify received IP packet. +| | +| | ... | *Arguments:* +| | ... | - node - TG node. Type: dictionary +| | ... | - tx_interface - TG Interface 1. Type: string +| | ... | - rx_interface - TG Interface 2. Type: string +| | ... | - tx_dst_mac - Destination MAC for TX interface / DUT interface 1 MAC. +| | ... | Type: string +| | ... | - rx_src_mac - Source MAC for RX interface / DUT interface 2 MAC. +| | ... | Type: string +| | ... | - tun_local_ip - GENEVE tunnel source IP address. Type: string +| | ... | - tun_remote_ip - GENEVE tunnel destination IP address. Type: string +| | ... | - tun_vni - GENEVE tunnel VNI. Type: integer +| | ... | - tun_src_ip - Source IP address of original IP packet / inner source +| | ... | IP address of GENEVE packet. Type: string +| | ... | - tun_dst_ip - Destination IP address of original IP packet / inner +| | ... | destination IP address of GENEVE packet. Type: string +| | +| | ... | *Example:* +| | ... | \| Send IP packet and verify GENEVE encapsulation in received packets\ +| | ... | \| \${nodes['TG']} \| eth1 \| eth2 \ +| | ... | \| 52:54:00:d4:d8:22 \| 52:54:00:d4:d8:3e \| 1.1.1.2 \| 1.1.1.1 \ +| | ... | \| 1 \| 10.128.1.0 \| 10.0.1.0 \| 24 \|11.0.1.2\| +| | +| | [Arguments] | ${node} | ${tx_interface} | ${rx_interface} +| | ... | ${tx_dst_mac} | ${rx_src_mac} | ${tun_local_ip} | ${tun_remote_ip} +| | ... | ${tun_vni} | ${tun_src_ip} | ${tun_dst_ip} +| | +| | ${tx_src_mac}= | Get Interface Mac | ${node} | ${tx_interface} +| | ${tx_if_name}= | Get Interface Name | ${node} | ${tx_interface} +| | ${rx_dst_mac}= | Get Interface Mac | ${node} | ${rx_interface} +| | ${rx_if_name}= | Get Interface Name | ${node} | ${rx_interface} +| | ${args}= | Catenate | --rx_if ${rx_if_name} | --tx_if ${tx_if_name} +| | ... | --tx_src_mac ${tx_src_mac} | --tx_dst_mac ${tx_dst_mac} +| | ... | --rx_src_mac ${rx_src_mac} | --rx_dst_mac ${rx_dst_mac} +| | ... | --tun_local_ip ${tun_local_ip} | --tun_remote_ip ${tun_remote_ip} +| | ... | --tun_vni ${tun_vni} | --tun_src_ip ${tun_src_ip} +| | ... | --tun_dst_ip ${tun_dst_ip} +| | Run Traffic Script On Node | geneve_tunnel.py | ${node} | ${args} diff --git a/tests/vpp/device/ip4_tunnels/eth2p-ethip4--ethip4udpgeneve-1tun-ip4base-dev.robot b/tests/vpp/device/ip4_tunnels/eth2p-ethip4--ethip4udpgeneve-1tun-ip4base-dev.robot new file mode 100644 index 0000000000..fe20d6dd6d --- /dev/null +++ b/tests/vpp/device/ip4_tunnels/eth2p-ethip4--ethip4udpgeneve-1tun-ip4base-dev.robot @@ -0,0 +1,107 @@ +# Copyright (c) 2020 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/shared/default.robot +| Resource | resources/libraries/robot/ip/geneve.robot +| Resource | resources/libraries/robot/shared/traffic.robot +| +| Force Tags | 2_NODE_SINGLE_LINK_TOPO | DEVICETEST | HW_ENV | DCR_ENV | SCAPY +| ... | NIC_Virtual | ETH | IP4FWD | IP4BASE | UDP | ENCAP | GENEVE +| ... | GENEVE_L3MODE | GENEVE4_1TUN | DRV_VFIO_PCI +| ... | RXQ_SIZE_0 | TXQ_SIZE_0 +| ... | ethip4--ethip4udpgeneve-1tun-ip4base +| +| Suite Setup | Setup suite topology interfaces | scapy +| Test Setup | Setup test +| Test Teardown | Tear down test | packet_trace | geneve4 +| +| Test Template | Local Template +| +| Documentation | *L2BD with GENEVE L3 mode test cases* +| +| ... | *[Top] Network Topologies:* TG-DUT1-TG 2-node circular topology\ +| ... | with single links between nodes. +| ... | *[Enc] Packet Encapsulations:* Eth-IPv4 between TG-if1 and DUT1-if1 and\ +| ... | Eth-IPv4-UDP-GENEVE-Eth-IPv4 between DUT1-if2 and TG-if2 for IPv4\ +| ... | routing over GENEVE tunnel. +| ... | *[Cfg] DUT configuration:* DUT1 is configured with IPv4 routing over\ +| ... | GENEVE tunnel and 4 static IPv4 /24 route entries.\ +| ... | DUT1 is tested with ${nic_name}. +| ... | *[Ver] TG verification:* Test Eth-IPv4 packet is sent by TG-if1 on link\ +| ... | to DUT1-if1; on receive by TG-if2 the encapsulated packet is verified\ +| ... | for correctness and its outer and inner IPv4 and MAC addresses, UDP\ +| ... | ports and GENEVE vni and protocol number. Then test\ +| ... | Eth-IPv4-UDP-GENEVE-Eth-IPv4 packet is sent by TG-if2 on link to\ +| ... | DUT1-if2; on receive by TG-if1 decapsulated packet is verified for\ +| ... | correctness and its IPv4 and MAC addresses +| ... | *[Ref] Applicable standard specifications:* RFC791, RFC768, RFC8926. + +*** Variables *** +| @{plugins_to_enable}= | dpdk_plugin.so | geneve_plugin.so +| ${crypto_type}= | ${None} +| ${nic_name}= | virtual +| ${nic_driver}= | vfio-pci +| ${nic_rxq_size}= | 0 +| ${nic_txq_size}= | 0 +| ${nic_pfs}= | 2 +| ${nic_vfs}= | 0 +| ${overhead}= | ${0} +# IP settings +| ${dut1_if1_ip4}= | 20.0.0.1 +| ${dut1_if2_ip4}= | 30.0.0.1 +| ${tg_if1_ip4}= | 20.0.0.2 +| ${tg_if2_ip4}= | 30.0.0.2 +# GENEVE settings +| ${gen_mode}= | L3 +| ${n_tunnels}= | ${1} +| &{gen_tunnel}= +| ... | local=1.1.1.2 | remote=1.1.1.1 | vni=${1} +| ... | src_ip=10.128.1.0 | dst_ip=10.0.1.0 | ip_mask=${24} | if_ip=11.0.1.2 + +*** Keywords *** +| Local Template +| | +| | [Documentation] +| | ... | [Cfg] DUT runs GENEVE ${gen_mode} mode configuration. +| | ... | Each DUT uses ${phy_cores} physical core(s) for worker threads. +| | ... | [Ver] Measure NDR and PDR values using MLRsearch algorithm.\ +| | +| | ... | *Arguments:* +| | ... | - frame_size - Framesize in Bytes in integer or string (IMIX_v4_1). +| | ... | Type: integer, string +| | ... | - phy_cores - Number of physical cores. Type: integer +| | ... | - rxq - Number of RX queues, default value: ${None}. Type: integer +| | +| | [Arguments] | ${frame_size} | ${phy_cores} | ${rxq}=${None} +| | +| | Set Test Variable | \${frame_size} +| | +| | Given Set Max Rate And Jumbo +| | And Add worker threads to all DUTs | ${phy_cores} | ${rxq} +| | And Pre-initialize layer driver | ${nic_driver} +| | And Apply startup configuration on all VPP DUTs | with_trace=${True} +| | When Initialize layer driver | ${nic_driver} +| | And Initialize layer interface +| | And Initialize GENEVE L3 mode in circular topology +| | Then Send IP packet and verify GENEVE encapsulation in received packets +| | ... | ${tg} | ${TG_pf1}[0] | ${TG_pf2}[0] +| | ... | ${DUT1_vf1_mac}[0] | ${DUT1_vf2_mac}[0] +| | ... | ${gen_tunnel}[local] | ${gen_tunnel}[remote] | ${gen_tunnel}[vni] +| | ... | ${gen_tunnel}[src_ip] | ${gen_tunnel}[dst_ip] +| | And Show Geneve Tunnel Data | ${nodes['DUT1']} + +*** Test Cases *** +| 64B-ethip4--ethip4udpgeneve-1tun-ip4base-dev +| | [Tags] | 64B +| | frame_size=${64} | phy_cores=${0} |