From 6c503ce60844890b901caea9b5e3e221aa0c1ec8 Mon Sep 17 00:00:00 2001 From: wrideout-arista Date: Wed, 17 Dec 2025 18:10:09 -0500 Subject: [PATCH] Support running acl tests without any IPv4 management configuration (#21155) * Support running acl tests without any IPv4 management configuration. Signed-off-by: Will Rideout --- tests/acl/test_acl.py | 9 +++-- tests/common/fixtures/ptfhost_utils.py | 8 ++--- .../tests_mark_conditions.yaml | 1 + .../tests_mark_conditions_acl.yaml | 30 ++++++++++++++-- tests/scripts/garp_service.py | 35 +++++++++++-------- 5 files changed, 60 insertions(+), 23 deletions(-) diff --git a/tests/acl/test_acl.py b/tests/acl/test_acl.py index 431eb4e1805..523d170ca61 100644 --- a/tests/acl/test_acl.py +++ b/tests/acl/test_acl.py @@ -535,8 +535,13 @@ def setup(duthosts, ptfhost, rand_selected_dut, rand_selected_front_end_dut, ran @pytest.fixture(scope="module", params=["ipv4", "ipv6"]) def ip_version(request, tbinfo, duthosts, rand_one_dut_hostname): - if tbinfo["topo"]["type"] in ["t0"] and request.param == "ipv6": - pytest.skip("IPV6 ACL test not currently supported on t0 testbeds") + v6topo = "isolated-v6" in tbinfo["topo"]["name"] + if request.param == "ipv4": + if v6topo: + pytest.skip("IPV4 ACL test not supported on isolated-v6 testbeds") + else: # ipv6 + if tbinfo["topo"]["type"] in ["t0"] and not v6topo: + pytest.skip("IPV6 ACL test not currently supported on t0 testbeds") return request.param diff --git a/tests/common/fixtures/ptfhost_utils.py b/tests/common/fixtures/ptfhost_utils.py index 43303c5eea5..caeb4aca396 100644 --- a/tests/common/fixtures/ptfhost_utils.py +++ b/tests/common/fixtures/ptfhost_utils.py @@ -477,8 +477,8 @@ def run_garp_service(duthost, ptfhost, tbinfo, change_mac_addresses, request): mux_cable_table = {} server_ipv4_base_addr, server_ipv6_base_addr = request.getfixturevalue('mock_server_base_ip_addr') for i, intf in enumerate(request.getfixturevalue('tor_mux_intfs')): - server_ipv4 = str(server_ipv4_base_addr + i) - server_ipv6 = str(server_ipv6_base_addr + i) + server_ipv4 = str(server_ipv4_base_addr + i) if server_ipv4_base_addr else '' + server_ipv6 = str(server_ipv6_base_addr + i) if server_ipv6_base_addr else '' mux_cable_table[intf] = {} mux_cable_table[intf]['server_ipv4'] = six.text_type(server_ipv4) # noqa: F821 mux_cable_table[intf]['server_ipv6'] = six.text_type(server_ipv6) # noqa: F821 @@ -490,8 +490,8 @@ def run_garp_service(duthost, ptfhost, tbinfo, change_mac_addresses, request): for vlan_intf, config in list(mux_cable_table.items()): ptf_port_index = ptf_indices[vlan_intf] - server_ip = ip_interface(config['server_ipv4']).ip - server_ipv6 = ip_interface(config['server_ipv6']).ip + server_ip = ip_interface(config['server_ipv4']).ip if config['server_ipv4'] else '' + server_ipv6 = ip_interface(config['server_ipv6']).ip if config['server_ipv6'] else '' garp_config[ptf_port_index] = { 'dut_mac': '{}'.format(dut_mac), diff --git a/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml b/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml index 288e8aef512..69d77b11fe2 100644 --- a/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml +++ b/tests/common/plugins/conditional_mark/tests_mark_conditions.yaml @@ -72,6 +72,7 @@ acl/test_acl.py: reason: "Skip acl for isolated-v6 topology" conditions: - "'isolated-v6' in topo_name and https://github.com/sonic-net/sonic-mgmt/issues/18077" + - "asic_type in ['broadcom']" xfail: reason: "Test case has issue on the t0-isolated-d256u256s2 topo." conditions: diff --git a/tests/common/plugins/conditional_mark/tests_mark_conditions_acl.yaml b/tests/common/plugins/conditional_mark/tests_mark_conditions_acl.yaml index 73a8eb99cbc..81e45f804dc 100644 --- a/tests/common/plugins/conditional_mark/tests_mark_conditions_acl.yaml +++ b/tests/common/plugins/conditional_mark/tests_mark_conditions_acl.yaml @@ -40,6 +40,13 @@ acl/test_acl.py::TestAclWithPortToggle::test_icmp_match_forwarded[ipv6-egress-up - "platform in ['armhf-nokia_ixs7215_52x-r0']" - https://github.com/sonic-net/sonic-mgmt/issues/8639 +acl/test_acl.py::TestAclWithPortToggle::test_icmp_match_forwarded[ipv6-ingress-uplink->downlink-default-Vlan1000]: + xfail: + reason: "Test issue on isolated-v6 topos" + conditions: + - "'isolated-v6' in topo_name" + - https://github.com/sonic-net/sonic-mgmt/issues/18077 + acl/test_acl.py::TestAclWithPortToggle::test_icmp_source_ip_match_dropped[ipv6-egress-uplink->downlink-default-Vlan1000]: xfail: reason: "Egress issue in Nokia" @@ -253,10 +260,8 @@ acl/test_acl.py::TestAclWithPortToggle::test_udp_source_ip_match_dropped[ipv6-eg acl/test_acl.py::TestAclWithReboot: skip: reason: "Skip in t1-lag KVM test due to test time too long and t0 would cover this testbeds, or for isolated-v6 topology" - conditions_logical_operator: or conditions: - "topo_type in ['t1'] and asic_type in ['vs']" - - "'isolated-v6' in topo_name and https://github.com/sonic-net/sonic-mgmt/issues/18077" acl/test_acl.py::TestAclWithReboot::test_dest_ip_match_dropped[ipv6-egress-uplink->downlink-default-Vlan1000]: xfail: @@ -324,6 +329,13 @@ acl/test_acl.py::TestAclWithReboot::test_icmp_match_forwarded[ipv6-egress-uplink conditions: - "topo_type in ['t1'] and asic_type in ['vs']" +acl/test_acl.py::TestAclWithReboot::test_icmp_match_forwarded[ipv6-ingress-uplink->downlink-default-Vlan1000]: + xfail: + reason: "Test issue on isolated-v6 topos" + conditions: + - "'isolated-v6' in topo_name" + - https://github.com/sonic-net/sonic-mgmt/issues/18077 + acl/test_acl.py::TestAclWithReboot::test_icmp_source_ip_match_dropped[ipv6-egress-uplink->downlink-default-Vlan1000]: xfail: reason: "Egress issue in Nokia" @@ -697,6 +709,13 @@ acl/test_acl.py::TestBasicAcl::test_icmp_match_forwarded[ipv6-egress-uplink->dow - "platform in ['armhf-nokia_ixs7215_52x-r0']" - https://github.com/sonic-net/sonic-mgmt/issues/8639 +acl/test_acl.py::TestBasicAcl::test_icmp_match_forwarded[ipv6-ingress-uplink->downlink-default-Vlan1000]: + xfail: + reason: "Test issue on isolated-v6 topos" + conditions: + - "'isolated-v6' in topo_name" + - https://github.com/sonic-net/sonic-mgmt/issues/18077 + acl/test_acl.py::TestBasicAcl::test_icmp_source_ip_match_dropped[ipv6-egress-uplink->downlink-default-Vlan1000]: xfail: reason: "Egress issue in Nokia" @@ -953,6 +972,13 @@ acl/test_acl.py::TestIncrementalAcl::test_icmp_match_forwarded[ipv6-egress-uplin - "platform in ['armhf-nokia_ixs7215_52x-r0']" - https://github.com/sonic-net/sonic-mgmt/issues/8639 +acl/test_acl.py::TestIncrementalAcl::test_icmp_match_forwarded[ipv6-ingress-uplink->downlink-default-Vlan1000]: + xfail: + reason: "Test issue on isolated-v6 topos" + conditions: + - "'isolated-v6' in topo_name" + - https://github.com/sonic-net/sonic-mgmt/issues/18077 + acl/test_acl.py::TestIncrementalAcl::test_icmp_source_ip_match_dropped[ipv6-egress-uplink->downlink-default-Vlan1000]: xfail: reason: "Egress issue in Nokia" diff --git a/tests/scripts/garp_service.py b/tests/scripts/garp_service.py index b2d1eaf77c8..8c80776c186 100644 --- a/tests/scripts/garp_service.py +++ b/tests/scripts/garp_service.py @@ -32,23 +32,27 @@ def gen_garp_packets(self): source_ipv6_str = config['target_ipv6'] dut_mac = config['dut_mac'] dst_ipv6 = config['dst_ipv6'] - source_ip = str(ip_interface(source_ip_str).ip) - source_ipv6 = str(ip_interface(source_ipv6_str).ip) + source_ip = str(ip_interface(source_ip_str).ip) if source_ip_str else None + source_ipv6 = str(ip_interface(source_ipv6_str).ip) if source_ipv6_str else None # PTF uses Scapy to create packets, so this is ok to create # packets through PTF even though we are using Scapy to send the packets - garp_pkt = testutils.simple_arp_packet( - eth_src=source_mac, - hw_snd=source_mac, - ip_snd=source_ip, - # Re-use server IP as target IP, since it is within the subnet of the VLAN IP - ip_tgt=source_ip, - arp_op=2) - - na_pkt = Ether(src=source_mac, dst=dut_mac) \ - / IPv6(dst=dst_ipv6, src=source_ipv6) \ - / ICMPv6ND_NA(tgt=source_ipv6, S=1, R=0, O=0) \ - / ICMPv6NDOptSrcLLAddr(type=2, lladdr=source_mac) + garp_pkt = None + na_pkt = None + if source_ip: + garp_pkt = testutils.simple_arp_packet( + eth_src=source_mac, + hw_snd=source_mac, + ip_snd=source_ip, + # Re-use server IP as target IP, since it is within the subnet of the VLAN IP + ip_tgt=source_ip, + arp_op=2) + + if source_ipv6: + na_pkt = Ether(src=source_mac, dst=dut_mac) \ + / IPv6(dst=dst_ipv6, src=source_ipv6) \ + / ICMPv6ND_NA(tgt=source_ipv6, S=1, R=0, O=0) \ + / ICMPv6NDOptSrcLLAddr(type=2, lladdr=source_mac) self.packets[intf_name] = [garp_pkt, na_pkt] @@ -69,7 +73,8 @@ def send_garp_packets(self): while True: for socket, packet_list in list(sockets.items()): for packet in packet_list: - socket.send(packet) + if packet: + socket.send(packet) if self.interval is None: break