99from scapy .all import Ether , IPv6 , ICMPv6ND_NS , ICMPv6NDOptSrcLLAddr , in6_getnsmac , \
1010 in6_getnsma , inet_pton , inet_ntop , socket
1111from ipaddress import ip_address , ip_network
12- from tests .common .utilities import wait_until , increment_ipv6_addr
12+ from tests .common .utilities import wait_until , increment_ipv6_addr , is_ipv6_only_topology
1313from tests .common .errors import RunAnsibleModuleFail
1414
1515
2222logger = logging .getLogger (__name__ )
2323
2424pytestmark = [
25- pytest .mark .topology ('t0' )
25+ pytest .mark .topology ('t0' ),
26+ pytest .mark .dualtor_active_standby_toggle_to_enum_tor
2627]
2728
2829LOOP_TIMES_LEVEL_MAP = {
3536
3637
3738@pytest .fixture (autouse = True )
38- def arp_cache_fdb_cleanup (duthost ):
39+ def arp_cache_fdb_cleanup (duthosts , rand_one_dut_hostname , tbinfo ):
40+ is_ipv6_only = is_ipv6_only_topology (tbinfo )
41+ duthost = duthosts [rand_one_dut_hostname ]
3942 try :
40- clear_dut_arp_cache (duthost )
43+ clear_dut_arp_cache (duthost , is_ipv6 = is_ipv6_only )
4144 fdb_cleanup (duthost )
4245 except RunAnsibleModuleFail as e :
4346 if 'Failed to send flush request: No such file or directory' in str (e ):
@@ -51,8 +54,10 @@ def arp_cache_fdb_cleanup(duthost):
5154
5255 # Ensure clean test environment even after failing
5356 try :
54- clear_dut_arp_cache (duthost )
55- fdb_cleanup (duthost )
57+ dut_list = duthosts if "dualtor-aa" in tbinfo ["topo" ]["name" ] else [duthost ]
58+ for dut in dut_list :
59+ clear_dut_arp_cache (dut , is_ipv6 = is_ipv6_only )
60+ fdb_cleanup (dut )
5661 except RunAnsibleModuleFail as e :
5762 if 'Failed to send flush request: No such file or directory' in str (e ):
5863 logger .warning ("Failed to clear arp cache or cleanup fdb table, file may not exist yet" )
@@ -90,13 +95,15 @@ def genrate_ipv4_ip():
9095 return list (ptf_intf_ipv4_hosts )
9196
9297
93- def test_ipv4_arp (duthost , garp_enabled , ip_and_intf_info , intfs_for_test ,
98+ def test_ipv4_arp (duthosts , enum_rand_one_per_hwsku_frontend_hostname ,
99+ garp_enabled , ip_and_intf_info , intfs_for_test ,
94100 ptfadapter , get_function_completeness_level ):
95101 """
96102 Send gratuitous ARP (GARP) packet sfrom the PTF to the DUT
97103
98104 The DUT should learn the (previously unseen) ARP info from the packet
99105 """
106+ duthost = duthosts [enum_rand_one_per_hwsku_frontend_hostname ]
100107 normalized_level = get_function_completeness_level
101108 if normalized_level is None :
102109 normalized_level = "debug"
@@ -106,6 +113,11 @@ def test_ipv4_arp(duthost, garp_enabled, ip_and_intf_info, intfs_for_test,
106113 pytest_assert (ipv4_available > 0 and fdb_available > 0 , "Entries have been filled" )
107114
108115 arp_available = min (min (ipv4_available , fdb_available ), ENTRIES_NUMBERS )
116+ # Limit ARP scale based on available NH entries
117+ asic_type = duthost .facts ["asic_type" ]
118+ if 'cisco-8000' in asic_type :
119+ ipv4_nh_available = get_crm_resources (duthost , "ipv4_nexthop" , "available" )
120+ arp_available = min (arp_available , ipv4_nh_available )
109121
110122 pytest_require (garp_enabled , 'Gratuitous ARP not enabled for this device' )
111123 ptf_intf_ipv4_hosts = genrate_ipv4_ip ()
@@ -181,8 +193,11 @@ def add_nd(ptfadapter, ip_and_intf_info, ptf_intf_index, nd_available):
181193 logger .info ("Sending {} ipv6 neighbor entries" .format (nd_available ))
182194
183195
184- def test_ipv6_nd (duthost , ptfhost , config_facts , tbinfo , ip_and_intf_info ,
196+ def test_ipv6_nd (duthosts , enum_rand_one_per_hwsku_frontend_hostname ,
197+ ptfhost , config_facts , tbinfo , ip_and_intf_info ,
185198 ptfadapter , get_function_completeness_level , proxy_arp_enabled ):
199+ duthost = duthosts [enum_rand_one_per_hwsku_frontend_hostname ]
200+ is_ipv6_only = is_ipv6_only_topology (tbinfo )
186201 _ , _ , ptf_intf_ipv6_addr , _ , ptf_intf_index = ip_and_intf_info
187202 ptf_intf_ipv6_addr = increment_ipv6_addr (ptf_intf_ipv6_addr )
188203 pytest_require (proxy_arp_enabled , 'Proxy ARP not enabled for all VLANs' )
@@ -198,7 +213,10 @@ def test_ipv6_nd(duthost, ptfhost, config_facts, tbinfo, ip_and_intf_info,
198213 pytest_assert (ipv6_available > 0 and fdb_available > 0 , "Entries have been filled" )
199214
200215 nd_available = min (min (ipv6_available , fdb_available ), ENTRIES_NUMBERS )
201-
216+ asic_type = duthost .facts ["asic_type" ]
217+ if 'cisco-8000' in asic_type :
218+ ipv6_nh_available = get_crm_resources (duthost , "ipv6_nexthop" , "available" )
219+ nd_available = min (nd_available , ipv6_nh_available )
202220 while loop_times > 0 :
203221 loop_times -= 1
204222 try :
@@ -213,7 +231,7 @@ def test_ipv6_nd(duthost, ptfhost, config_facts, tbinfo, ip_and_intf_info,
213231 "Neighbor Table Add failed" )
214232 finally :
215233 try :
216- clear_dut_arp_cache (duthost )
234+ clear_dut_arp_cache (duthost , is_ipv6 = is_ipv6_only )
217235 fdb_cleanup (duthost )
218236 except RunAnsibleModuleFail as e :
219237 if 'Failed to send flush request: No such file or directory' in str (e ):
@@ -246,6 +264,7 @@ def test_ipv6_nd_incomplete(duthost, ptfhost, config_facts, tbinfo, ip_and_intf_
246264 ptfadapter , get_function_completeness_level , proxy_arp_enabled ):
247265 _ , _ , ptf_intf_ipv6_addr , _ , ptf_intf_index = ip_and_intf_info
248266 ptf_intf_ipv6_addr = increment_ipv6_addr (ptf_intf_ipv6_addr )
267+ is_ipv6_only = is_ipv6_only_topology (tbinfo )
249268 pytest_require (proxy_arp_enabled , 'Proxy ARP not enabled for all VLANs' )
250269 pytest_require (ptf_intf_ipv6_addr is not None , 'No IPv6 VLAN address configured on device' )
251270
@@ -272,7 +291,7 @@ def test_ipv6_nd_incomplete(duthost, ptfhost, config_facts, tbinfo, ip_and_intf_
272291 logger .info ("original nf_conntrack_icmpv6_timeout: {}" .format (orig_conntrack_icmpv6_timeout ))
273292
274293 try :
275- clear_dut_arp_cache (duthost )
294+ clear_dut_arp_cache (duthost , is_ipv6 = is_ipv6_only )
276295
277296 duthost .command ("conntrack -F" )
278297
@@ -286,7 +305,7 @@ def test_ipv6_nd_incomplete(duthost, ptfhost, config_facts, tbinfo, ip_and_intf_
286305 conntrack_cnt_post = int (duthost .command ("cat /proc/sys/net/netfilter/nf_conntrack_count" )["stdout" ])
287306 logger .info ("nf_conntrack_count post test: {}" .format (conntrack_cnt_post ))
288307
289- pytest_assert ((conntrack_cnt_post - conntrack_cnt_pre ) < tgt_conntrack_cnt * 0.1 ,
308+ pytest_assert ((conntrack_cnt_post - conntrack_cnt_pre ) < tgt_conntrack_cnt ,
290309 "{} echo requests cause large increase in conntrack entries" .format (tgt_conntrack_cnt ))
291310
292311 pytest_assert ("[UNREPLIED]" not in duthost .command ("conntrack -f ipv6 -L dying" )["stdout" ],
@@ -302,4 +321,4 @@ def test_ipv6_nd_incomplete(duthost, ptfhost, config_facts, tbinfo, ip_and_intf_
302321
303322 duthost .command ("conntrack -F" )
304323
305- clear_dut_arp_cache (duthost )
324+ clear_dut_arp_cache (duthost , is_ipv6 = is_ipv6_only )
0 commit comments