From d26c0608f0fd218f6a9ea6ab836e52a73c24c3a8 Mon Sep 17 00:00:00 2001 From: Anish Narsian <44376847+anish-n@users.noreply.github.com> Date: Mon, 6 Dec 2021 16:55:44 -0800 Subject: [PATCH] Fix rebase issue and make the vxlan port used for inner hashing configured from the top level (#4780) --- .../roles/test/files/ptftests/fg_ecmp_test.py | 16 +++++++++---- tests/ecmp/test_fgnhg.py | 24 ++++++++++++++++++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/ansible/roles/test/files/ptftests/fg_ecmp_test.py b/ansible/roles/test/files/ptftests/fg_ecmp_test.py index b2bb95aec7..5de842177a 100644 --- a/ansible/roles/test/files/ptftests/fg_ecmp_test.py +++ b/ansible/roles/test/files/ptftests/fg_ecmp_test.py @@ -164,6 +164,8 @@ def setUp(self): self.inner_hashing = graph['inner_hashing'] self.src_ipv4_interval = lpm.LpmDict.IpInterval(ipaddress.ip_address(unicode(IPV4_SRC_IP_RANGE[0])), ipaddress.ip_address(unicode(IPV4_SRC_IP_RANGE[1]))) self.src_ipv6_interval = lpm.LpmDict.IpInterval(ipaddress.ip_address(unicode(IPV6_SRC_IP_RANGE[0])), ipaddress.ip_address(unicode(IPV6_SRC_IP_RANGE[1]))) + self.vxlan_port = graph['vxlan_port'] + self.log(self.net_ports) self.log(self.serv_ports) self.log(self.exp_port_set_one) @@ -174,6 +176,7 @@ def setUp(self): self.log(self.num_flows) self.log(self.inner_hashing) self.log(self.exp_flow_count) + self.log(self.vxlan_port) if self.test_case != 'hash_check_warm_boot': # We send bi-directional traffic during warm boot due to @@ -227,10 +230,11 @@ def fg_ecmp(self): # and generate a flow to port map self.log("Creating flow to port map ...") for i in range(0, self.num_flows): - if ipv4: + if ipv4 or self.inner_hashing: src_ip = self.src_ipv4_interval.get_random_ip() else: src_ip = self.src_ipv6_interval.get_random_ip() + if self.inner_hashing: in_port = random.choice(self.net_ports) else: @@ -274,7 +278,11 @@ def fg_ecmp(self): self.log("Ensure that all packets were received ...") total_num_pkts_lost = 0 for i in range(0, self.num_flows): - src_ip = str(base_ip + i) + if ipv4 or self.inner_hashing: + src_ip = self.src_ipv4_interval.get_random_ip() + else: + src_ip = self.src_ipv6_interval.get_random_ip() + if self.inner_hashing: in_port = random.choice(self.net_ports) else: @@ -485,7 +493,7 @@ def send_rcv_ipv4_pkt(self, in_port, sport, dport, ip_dst=self.dst_ip, ip_ttl=64, udp_sport=rand_int, - udp_dport=4789, + udp_dport=self.vxlan_port, vxlan_vni=20000+rand_int, with_udp_chksum=False, inner_frame=pkt) @@ -521,7 +529,7 @@ def send_rcv_ipv6_pkt(self, in_port, sport, dport, ipv6_src='2:2:2::' + str(rand_int), ipv6_dst=self.dst_ip, udp_sport=rand_int, - udp_dport=4789, + udp_dport=self.vxlan_port, vxlan_vni=20000+rand_int, with_udp_chksum=False, inner_frame=pkt) diff --git a/tests/ecmp/test_fgnhg.py b/tests/ecmp/test_fgnhg.py index 4defb84ae4..20fc4acb1f 100644 --- a/tests/ecmp/test_fgnhg.py +++ b/tests/ecmp/test_fgnhg.py @@ -26,6 +26,9 @@ NUM_FLOWS = 1000 ptf_to_dut_port_map = {} +VXLAN_PORT = 13330 +DUT_VXLAN_PORT_JSON_FILE = '/tmp/vxlan.switch.json' + pytestmark = [ pytest.mark.topology('t0'), pytest.mark.asic('mellanox'), @@ -166,7 +169,8 @@ def create_fg_ptf_config(ptfhost, ip_to_port, port_list, bank_0_port, bank_1_por "dut_mac": router_mac, "net_ports": net_ports, "inner_hashing": USE_INNER_HASHING, - "num_flows": NUM_FLOWS + "num_flows": NUM_FLOWS, + "vxlan_port": VXLAN_PORT } logger.info("fg_ecmp config sent to PTF: " + str(fg_ecmp)) @@ -182,6 +186,21 @@ def setup_test_config(duthost, ptfhost, cfg_facts, router_mac, net_ports, vlan_i return port_list, ip_to_port, bank_0_port, bank_1_port +def configure_switch_vxlan_cfg(duthost): + vxlan_switch_config = [{ + "SWITCH_TABLE:switch": { + "vxlan_port": VXLAN_PORT + }, + "OP": "SET" + }] + + logger.info("Copying vxlan.switch.json with data: " + str(vxlan_switch_config)) + + duthost.copy(content=json.dumps(vxlan_switch_config, indent=4), dest=DUT_VXLAN_PORT_JSON_FILE) + duthost.shell("docker cp {} swss:/vxlan.switch.json".format(DUT_VXLAN_PORT_JSON_FILE)) + duthost.shell("docker exec swss sh -c \"swssconfig /vxlan.switch.json\"") + + def configure_dut(duthost, cmd): logger.info("Configuring dut with " + cmd) duthost.shell(cmd, executable="/bin/bash") @@ -575,6 +594,9 @@ def common_setup_teardown(tbinfo, duthosts, rand_one_dut_hostname, ptfhost): for name, val in mg_facts['minigraph_portchannels'].items(): members = [mg_facts['minigraph_ptf_indices'][member] for member in val['members']] net_ports.extend(members) + if USE_INNER_HASHING is True: + configure_switch_vxlan_cfg(duthost) + yield duthost, cfg_facts, router_mac, net_ports finally: