From 4d409f8c5bfbef77e25a19810969dc9cbea5f528 Mon Sep 17 00:00:00 2001 From: Jan Gelety Date: Sat, 8 Aug 2020 12:36:02 +0200 Subject: [PATCH] VPP-DEV API COV: Add NAT44-ED tests Jira: CSIT-1755 Change-Id: I34baa22a49f44da3fa80d91fa2f4132c982fe610 Signed-off-by: Jan Gelety --- GPL/traffic_scripts/nat.py | 219 +++++++++++++++++++++ GPL/traffic_scripts/send_vxlan_check_vxlan.py | 1 + resources/api/vpp/supported_crcs.yaml | 40 ++-- resources/libraries/robot/ip/ip4.robot | 2 +- resources/libraries/robot/shared/traffic.robot | 53 +++++ .../device/ip4/eth2p-ethip4tcp-snat44ed-dev.robot | 117 +++++++++++ .../device/ip4/eth2p-ethip4udp-snat44ed-dev.robot | 117 +++++++++++ 7 files changed, 528 insertions(+), 21 deletions(-) create mode 100644 GPL/traffic_scripts/nat.py create mode 100644 tests/vpp/device/ip4/eth2p-ethip4tcp-snat44ed-dev.robot create mode 100644 tests/vpp/device/ip4/eth2p-ethip4udp-snat44ed-dev.robot diff --git a/GPL/traffic_scripts/nat.py b/GPL/traffic_scripts/nat.py new file mode 100644 index 0000000000..0ba9f4aefc --- /dev/null +++ b/GPL/traffic_scripts/nat.py @@ -0,0 +1,219 @@ +#!/usr/bin/env python3 + +# 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. + +"""Traffic script for NAT verification.""" + +import sys + +import ipaddress + +from scapy.layers.inet import IP, TCP, 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 valid_ipv4(ip): + try: + ipaddress.IPv4Address(ip) + return True + except (AttributeError, ipaddress.AddressValueError): + return False + + +def valid_ipv6(ip): + try: + ipaddress.IPv6Address(ip) + return True + except (AttributeError, ipaddress.AddressValueError): + return False + + +def main(): + """Send, receive and check IP/IPv6 packets with UDP/TCP layer passing + through NAT. + """ + args = TrafficScriptArg( + [ + u"tx_src_mac", u"rx_dst_mac", u"src_ip_in", u"src_ip_out", + u"dst_ip", u"tx_dst_mac", u"rx_src_mac", u"protocol", + u"src_port_in", u"src_port_out", u"dst_port" + ] + ) + + tx_src_mac = args.get_arg(u"tx_src_mac") + tx_dst_mac = args.get_arg(u"tx_dst_mac") + rx_dst_mac = args.get_arg(u"rx_dst_mac") + rx_src_mac = args.get_arg(u"rx_src_mac") + src_ip_in = args.get_arg(u"src_ip_in") + src_ip_out = args.get_arg(u"src_ip_out") + dst_ip = args.get_arg(u"dst_ip") + protocol = args.get_arg(u"protocol") + sport_in = int(args.get_arg(u"src_port_in")) + try: + sport_out = int(args.get_arg(u"src_port_out")) + except ValueError: + sport_out = None + dst_port = int(args.get_arg(u"dst_port")) + + 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")) + + sent_packets = list() + pkt_raw = Ether(src=tx_src_mac, dst=tx_dst_mac) + + if valid_ipv4(src_ip_in) and valid_ipv4(dst_ip): + ip_layer = IP + elif valid_ipv6(src_ip_in) and valid_ipv6(dst_ip): + ip_layer = IPv6 + else: + raise ValueError(u"IP not in correct format") + pkt_raw /= ip_layer(src=src_ip_in, dst=dst_ip) + + if protocol == u"UDP": + pkt_raw /= UDP(sport=sport_in, dport=dst_port) + proto_layer = UDP + elif protocol == u"TCP": + # flags=0x2 => SYN flag set + pkt_raw /= TCP(sport=sport_in, dport=dst_port, flags=0x2) + proto_layer = TCP + else: + raise ValueError(u"Incorrect protocol") + + pkt_raw /= Raw() + sent_packets.append(pkt_raw) + tx_txq.send(pkt_raw) + + while True: + ether = rx_rxq.recv(2) + + if ether is None: + raise RuntimeError(u"IP packet Rx timeout") + + if ether.haslayer(ICMPv6ND_NS): + # read another packet in the queue if the current one is ICMPv6ND_NS + continue + else: + # otherwise process the current packet + break + + if rx_dst_mac != ether[Ether].dst or rx_src_mac != ether[Ether].src: + raise RuntimeError(f"Matching packet unsuccessful: {ether!r}") + + ip_pkt = ether.payload + if not isinstance(ip_pkt, ip_layer): + raise RuntimeError(f"Not an {ip_layer!s} packet received: {ip_pkt!r}") + if ip_pkt.src != src_ip_out: + raise RuntimeError( + f"Matching Src IP address unsuccessful: " + f"{src_ip_out} != {ip_pkt.src}" + ) + if ip_pkt.dst != dst_ip: + raise RuntimeError( + f"Matching Dst IP address unsuccessful: {dst_ip} != {ip_pkt.dst}" + ) + + proto_pkt = ip_pkt.payload + if not isinstance(proto_pkt, proto_layer): + raise RuntimeError( + f"Not a {proto_layer!s} packet received: {proto_pkt!r}" + ) + if sport_out is not None: + if proto_pkt.sport != sport_out: + raise RuntimeError( + f"Matching Src {proto_layer!s} port unsuccessful: " + f"{sport_out} != {proto_pkt.sport}" + ) + else: + sport_out = proto_pkt.sport + if proto_pkt.dport != dst_port: + raise RuntimeError( + f"Matching Dst {proto_layer!s} port unsuccessful: " + f"{dst_port} != {proto_pkt.dport}" + ) + if proto_layer == TCP: + if proto_pkt.flags != 0x2: + raise RuntimeError( + f"Not a TCP SYN packet received: {proto_pkt!r}" + ) + + pkt_raw = Ether(src=rx_dst_mac, dst=rx_src_mac) + pkt_raw /= ip_layer(src=dst_ip, dst=src_ip_out) + pkt_raw /= proto_layer(sport=dst_port, dport=sport_out) + if proto_layer == TCP: + # flags=0x12 => SYN, ACK flags set + pkt_raw[TCP].flags = 0x12 + pkt_raw /= Raw() + rx_txq.send(pkt_raw) + + while True: + ether = tx_rxq.recv(2, ignore=sent_packets) + + if ether is None: + raise RuntimeError(u"IP packet Rx timeout") + + if ether.haslayer(ICMPv6ND_NS): + # read another packet in the queue if the current one is ICMPv6ND_NS + continue + else: + # otherwise process the current packet + break + + if ether[Ether].dst != tx_src_mac or ether[Ether].src != tx_dst_mac: + raise RuntimeError(f"Matching packet unsuccessful: {ether!r}") + + ip_pkt = ether.payload + if not isinstance(ip_pkt, ip_layer): + raise RuntimeError(f"Not an {ip_layer!s} packet received: {ip_pkt!r}") + if ip_pkt.src != dst_ip: + raise RuntimeError( + f"Matching Src IP address unsuccessful: {dst_ip} != {ip_pkt.src}" + ) + if ip_pkt.dst != src_ip_in: + raise RuntimeError( + f"Matching Dst IP address unsuccessful: {src_ip_in} != {ip_pkt.dst}" + ) + + proto_pkt = ip_pkt.payload + if not isinstance(proto_pkt, proto_layer): + raise RuntimeError( + f"Not a {proto_layer!s} packet received: {proto_pkt!r}" + ) + if proto_pkt.sport != dst_port: + raise RuntimeError( + f"Matching Src {proto_layer!s} port unsuccessful: " + f"{dst_port} != {proto_pkt.sport}" + ) + if proto_pkt.dport != sport_in: + raise RuntimeError( + f"Matching Dst {proto_layer!s} port unsuccessful: " + f"{sport_in} != {proto_pkt.dport}" + ) + if proto_layer == TCP: + if proto_pkt.flags != 0x12: + raise RuntimeError( + f"Not a TCP SYN-ACK packet received: {proto_pkt!r}" + ) + + sys.exit(0) + + +if __name__ == u"__main__": + main() diff --git a/GPL/traffic_scripts/send_vxlan_check_vxlan.py b/GPL/traffic_scripts/send_vxlan_check_vxlan.py index 0b1da81f18..8bc8f6e09e 100644 --- a/GPL/traffic_scripts/send_vxlan_check_vxlan.py +++ b/GPL/traffic_scripts/send_vxlan_check_vxlan.py @@ -115,5 +115,6 @@ def main(): sys.exit(0) + if __name__ == u"__main__": main() diff --git a/resources/api/vpp/supported_crcs.yaml b/resources/api/vpp/supported_crcs.yaml index e8eb379aa8..c4bc243aae 100644 --- a/resources/api/vpp/supported_crcs.yaml +++ b/resources/api/vpp/supported_crcs.yaml @@ -186,26 +186,26 @@ memif_dump: '0x51077d14' # dev memif_socket_filename_add_del: '0xa2ce1a10' # dev memif_socket_filename_add_del_reply: '0xe8d4e804' # dev - nat44_add_del_address_range: '0xd4c7568c' # perf - nat44_add_del_address_range_reply: '0xe8d4e804' # perf - nat44_address_details: '0x45410ac4' # perf teardown - nat44_address_dump: '0x51077d14' # perf teardown - nat44_interface_add_del_feature: '0xf3699b83' # perf - nat44_interface_add_del_feature_reply: '0xe8d4e804' # perf - nat44_interface_addr_details: '0x3e687514' # perf teardown - nat44_interface_addr_dump: '0x51077d14' # perf teardown - nat44_interface_details: '0x5d286289' # perf teardown - nat44_interface_dump: '0x51077d14' # perf teardown - nat44_static_mapping_details: '0x1a433ef7' # perf teardown - nat44_static_mapping_dump: '0x51077d14' # perf teardown - nat44_user_details: '0x355896c2' # perf teardown - nat44_user_dump: '0x51077d14' # perf teardown - nat44_user_session_details: '0x1965fd69' # perf teardown - nat44_user_session_dump: '0xe1899c98' # perf teardown - nat_show_config: '0x51077d14' # perf teardown - nat_show_config_reply: '0x7903ef06' # perf teardown - nat_worker_details: '0x84bf06fc' # perf teardown - nat_worker_dump: '0x51077d14' # perf teardown + nat44_add_del_address_range: '0xd4c7568c' # dev + nat44_add_del_address_range_reply: '0xe8d4e804' # dev + nat44_address_details: '0x45410ac4' # dev teardown + nat44_address_dump: '0x51077d14' # dev teardown + nat44_interface_add_del_feature: '0xf3699b83' # dev + nat44_interface_add_del_feature_reply: '0xe8d4e804' # dev + nat44_interface_addr_details: '0x3e687514' # dev teardown + nat44_interface_addr_dump: '0x51077d14' # dev teardown + nat44_interface_details: '0x5d286289' # dev teardown + nat44_interface_dump: '0x51077d14' # dev teardown + nat44_static_mapping_details: '0x1a433ef7' # dev teardown + nat44_static_mapping_dump: '0x51077d14' # dev teardown + nat44_user_details: '0x355896c2' # dev teardown + nat44_user_dump: '0x51077d14' # dev teardown + nat44_user_session_details: '0x1965fd69' # dev teardown + nat44_user_session_dump: '0xe1899c98' # dev teardown + nat_show_config: '0x51077d14' # dev teardown + nat_show_config_reply: '0x7903ef06' # dev teardown + nat_worker_details: '0x84bf06fc' # dev teardown + nat_worker_dump: '0x51077d14' # dev teardown # 6x^ tc01-64B-1c-ethip4udp-snat44det-h1-p1-s1-mrr # ^ nat44NOTscaleNOTsrc_user_1 nsim_configure: '0x16ed400f' # perf diff --git a/resources/libraries/robot/ip/ip4.robot b/resources/libraries/robot/ip/ip4.robot index 9855e129a4..f61466bf4e 100644 --- a/resources/libraries/robot/ip/ip4.robot +++ b/resources/libraries/robot/ip/ip4.robot @@ -599,7 +599,7 @@ | | ... | VPP Interface Set IP Address | ${dut2} | ${subif_index_2} | | ... | 2.2.2.2 | 30 | | VPP Interface Set IP Address -| | ... | ${dut} | ${dut_if2} | 3.3.3.2 | 30 +| | ... | ${dut} | ${dut_if2} | 3.3.3.2 | 30 | | Vpp Route Add | ${dut1} | ${tg_if1_net} | 30 | gateway=1.1.1.1 | | ... | interface=${DUT1_${int}1}[0] | | Run Keyword If | '${dut2_status}' == 'PASS' diff --git a/resources/libraries/robot/shared/traffic.robot b/resources/libraries/robot/shared/traffic.robot index 0b65c8d892..1f10787bc1 100644 --- a/resources/libraries/robot/shared/traffic.robot +++ b/resources/libraries/robot/shared/traffic.robot @@ -556,3 +556,56 @@ | | ... | --dir0_dstsid3 ${tg_dstsid3} | --dir1_dstsid3 ${dut_dstsid3} | | ... | --static_proxy ${static_proxy} | | Run Traffic Script On Node | srv6_encap.py | ${node} | ${args} + +| Send TCP or UDP packet and verify network address translations +| | [Documentation] | Send TCP or UDP packet from TG-if1 to TG-if2 and response\ +| | ... | in opposite direction via DUT with configured NAT. Check packet\ +| | ... | headers on both sides. +| | +| | ... | *Arguments:* +| | +| | ... | _NOTE:_ Arguments are based on topology: +| | ... | TG(if1)->(if1)DUT(if2)->TG(if2) +| | +| | ... | - tg_node - Node where to run traffic script. 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 +| | ... | - src_ip_in - Internal source IP address. Type: string +| | ... | - src_ip_out - External source IP address. Type: string +| | ... | - dst_ip - Destination IP address. Type: string +| | ... | - protocol - TCP or UDP protocol. Type: string +| | ... | - src_port_in - Internal source TCP/UDP port. Type: string or integer +| | ... | - src_port_out - External source TCP/UDP port; default value: unknown. +| | ... | Type: string or integer +| | ... | - dst_port - Destination TCP/UDP port. Type: string or integer +| | +| | ... | *Return:* +| | ... | - No value returned +| | +| | ... | *Example:* +| | +| | ... | \| Send TCP or UDP packet and verify network address translations \ +| | ... | \| ${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 \| +| | +| | [Arguments] | ${tg_node} | ${tx_interface} | ${rx_interface} | ${tx_dst_mac} +| | ... | ${rx_src_mac} | ${src_ip_in} | ${src_ip_out} | ${dst_ip} +| | ... | ${protocol} | ${src_port_in} | ${dst_port} | ${src_port_out}=unknown +| | +| | ${tx_src_mac}= | Get Interface Mac | ${tg_node} | ${tx_interface} +| | ${tx_if_name}= | Get Interface Name | ${tg_node} | ${tx_interface} +| | ${rx_dst_mac}= | Get Interface Mac | ${tg_node} | ${rx_interface} +| | ${rx_if_name}= | Get Interface Name | ${tg_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} +| | ... | --src_ip_in ${src_ip_in} | --src_ip_out ${src_ip_out} +| | ... | --dst_ip ${dst_ip} | --protocol ${protocol} +| | ... | --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} diff --git a/tests/vpp/device/ip4/eth2p-ethip4tcp-snat44ed-dev.robot b/tests/vpp/device/ip4/eth2p-ethip4tcp-snat44ed-dev.robot new file mode 100644 index 0000000000..5fe36c4341 --- /dev/null +++ b/tests/vpp/device/ip4/eth2p-ethip4tcp-snat44ed-dev.robot @@ -0,0 +1,117 @@ +# 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/nat.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 | FEATURE | NAT44 | NAT44_ENDPOINT_DEPENDENT +| ... | BASE | TCP | DRV_VFIO_PCI +| ... | RXQ_SIZE_0 | TXQ_SIZE_0 +| ... | ethip4tcp-snat44ed-dev +| +| Suite Setup | Setup suite topology interfaces | scapy +| Test Setup | Setup test +| Test Teardown | Tear down test | packet_trace | nat-ed +| +| Test Template | Local Template +| +| Documentation | *Connections per second NAT44 endpoint-dependent mode +| ... | performance test cases* +| +| ... | *[Top] Network Topologies:* TG-DUT1-TG 2-node circular topology +| ... | with single links between nodes. +| ... | *[Enc] Packet Encapsulations:* Eth-IPv4-TCP for IPv4 routing. +| ... | *[Cfg] DUT configuration:* DUT1 is configured with IPv4 routing and +| ... | one static IPv4 /18 route entries. +| ... | DUT1 is tested with ${nic_name}.\ +| ... | *[Ver] TG verification:* Eth-IPv4-TCP packet is sent from TG to DUT1 in\ +| ... | one direction. Packet is received and verified for correctness on TG.\ +| ... | Then Eth-IPv4-TCP packet is sent from TG in opposite direction. Packet\ +| ... | is received and verified for correctness on TG. +| ... | *[Ref] Applicable standard specifications:* RFC791, RFC793, RFC3022, +| ... | RFC4787. + +*** Variables *** +| @{plugins_to_enable}= | dpdk_plugin.so | nat_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 +| ${tg_if1_ip4}= | 10.0.0.2 +| ${tg_if1_mask}= | ${20} +| ${tg_if2_ip4}= | 12.0.0.2 +| ${tg_if2_mask}= | ${20} +| ${dut1_if1_ip4}= | 10.0.0.1 +| ${dut1_if1_mask}= | ${24} +| ${dut1_if2_ip4}= | 12.0.0.1 +| ${dut1_if2_mask}= | ${24} +| ${dest_net}= | 20.0.0.0 +| ${dest_mask}= | ${22} +# proto layer settings +| ${protocol}= | TCP +| ${src_port_in}= | 1024 +| ${dst_port}= | 8080 +# NAT settings +| ${nat_mode}= | endpoint-dependent +| ${max_translations_per_thread}= | 81920 +| ${in_net}= | 192.168.0.0 +| ${in_mask}= | ${22} +| ${out_net}= | 68.142.68.0 +| ${out_net_end}= | 68.142.68.0 +| ${out_mask}= | ${32} + +*** Keywords *** +| Local Template +| | +| | [Documentation] +| | ... | [Cfg] DUT runs NAT44 ${nat_mode} configuration. +| | ... | [Ver] Make TG send IPv4 packet routed over DUT1 interfaces.\ +| | ... | Make TG verify IPv4 packet is correct. +| | +| | ... | *Arguments:* +| | ... | - frame_size - Framesize in Bytes in integer. Type: integer +| | ... | - 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 Jumbo +| | And Add worker threads to all DUTs | ${phy_cores} | ${rxq} +| | And Pre-initialize layer driver | ${nic_driver} +| | And Add NAT to all DUTs | nat_mode=${nat_mode} +| | And Add NAT max translations per thread to all DUTs +| | ... | ${max_translations_per_thread} +| | And Apply startup configuration on all VPP DUTs | with_trace=${True} +| | When Initialize layer driver | ${nic_driver} +| | And Initialize layer interface +| | And Initialize IPv4 forwarding for NAT44 in circular topology +| | And Initialize NAT44 endpoint-dependent mode in circular topology +| | Then Send TCP or UDP packet and verify network address translations +| | ... | ${tg} | ${TG_pf1}[0] | ${TG_pf2}[0] | ${DUT1_vf1_mac}[0] +| | ... | ${DUT1_vf2_mac}[0] | ${in_net} | ${out_net} | ${dest_net} +| | ... | ${protocol} | ${src_port_in} | ${dst_port} + +*** Test Cases *** +| 64B-ethip4tcp-snat44ed-dev +| | [Tags] | 64B +| | frame_size=${64} | phy_cores=${0} diff --git a/tests/vpp/device/ip4/eth2p-ethip4udp-snat44ed-dev.robot b/tests/vpp/device/ip4/eth2p-ethip4udp-snat44ed-dev.robot new file mode 100644 index 0000000000..99cb761578 --- /dev/null +++ b/tests/vpp/device/ip4/eth2p-ethip4udp-snat44ed-dev.robot @@ -0,0 +1,117 @@ +# 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/nat.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 | FEATURE | NAT44 | NAT44_ENDPOINT_DEPENDENT +| ... | BASE | UDP | DRV_VFIO_PCI +| ... | RXQ_SIZE_0 | TXQ_SIZE_0 +| ... | ethip4udp-snat44ed-dev +| +| Suite Setup | Setup suite topology interfaces | scapy +| Test Setup | Setup test +| Test Teardown | Tear down test | packet_trace | nat-ed +| +| Test Template | Local Template +| +| Documentation | *RFC2544: Pkt throughput NAT44 endpoint-dependent mode +| ... | performance test cases* +| +| ... | *[Top] Network Topologies:* TG-DUT1-TG 2-node circular topology +| ... | with single links between nodes. +| ... | *[Enc] Packet Encapsulations:* Eth-IPv4-UDP for IPv4 routing. +| ... | *[Cfg] DUT configuration:* DUT1 is configured with IPv4 routing and +| ... | one static IPv4 /${dest_mask} route entries. +| ... | DUT1 is tested with ${nic_name}.\ +| ... | *[Ver] TG verification:* Eth-IPv4-UDP packet is sent from TG to DUT1 in\ +| ... | one direction. Packet is received and verified for correctness on TG.\ +| ... | Then Eth-IPv4-UDP packet is sent from TG in opposite direction. Packet\ +| ... | is received and verified for correctness on TG. +| ... | *[Ref] Applicable standard specifications:* RFC791, RFC768, RFC3022, +| ... | RFC4787. + +*** Variables *** +| @{plugins_to_enable}= | dpdk_plugin.so | nat_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 +| ${tg_if1_ip4}= | 10.0.0.2 +| ${tg_if1_mask}= | ${20} +| ${tg_if2_ip4}= | 12.0.0.2 +| ${tg_if2_mask}= | ${20} +| ${dut1_if1_ip4}= | 10.0.0.1 +| ${dut1_if1_mask}= | ${24} +| ${dut1_if2_ip4}= | 12.0.0.1 +| ${dut1_if2_mask}= | ${24} +| ${dest_net}= | 20.0.0.0 +| ${dest_mask}= | ${22} +# proto layer settings +| ${protocol}= | UDP +| ${src_port_in}= | 1024 +| ${dst_port}= | 8080 +# NAT settings +| ${nat_mode}= | endpoint-dependent +| ${max_translations_per_thread}= | 81920 +| ${in_net}= | 192.168.0.0 +| ${in_mask}= | ${22} +| ${out_net}= | 68.142.68.0 +| ${out_net_end}= | 68.142.68.0 +| ${out_mask}= | ${32} + +*** Keywords *** +| Local Template +| | +| | [Documentation] +| | ... | [Cfg] DUT runs NAT44 ${nat_mode} configuration. +| | ... | [Ver] Make TG send IPv4 packet routed over DUT1 interfaces.\ +| | ... | Make TG verify IPv4 packet is correct. +| | +| | ... | *Arguments:* +| | ... | - frame_size - Framesize in Bytes in integer. Type: integer +| | ... | - 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 Jumbo +| | And Add worker threads to all DUTs | ${phy_cores} | ${rxq} +| | And Pre-initialize layer driver | ${nic_driver} +| | And Add NAT to all DUTs | nat_mode=${nat_mode} +| | And Add NAT max translations per thread to all DUTs +| | ... | ${max_translations_per_thread} +| | And Apply startup configuration on all VPP DUTs | with_trace=${True} +| | When Initialize layer driver | ${nic_driver} +| | And Initialize layer interface +| | And Initialize IPv4 forwarding for NAT44 in circular topology +| | And Initialize NAT44 endpoint-dependent mode in circular topology +| | Then Send TCP or UDP packet and verify network address translations +| | ... | ${tg} | ${TG_pf1}[0] | ${TG_pf2}[0] | ${DUT1_vf1_mac}[0] +| | ... | ${DUT1_vf2_mac}[0] | ${in_net} | ${out_net} | ${dest_net} +| | ... | ${protocol} | ${src_port_in} | ${dst_port} + +*** Test Cases *** +| 64B-ethip4udp-snat44ed-dev +| | [Tags] | 64B +| | frame_size=${64} | phy_cores=${0} -- 2.16.6