|
27 | 27 | USE_INNER_HASHING = False |
28 | 28 | NUM_FLOWS = 1000 |
29 | 29 | ptf_to_dut_port_map = {} |
| 30 | +ptf_to_dut_mac_map = {} |
30 | 31 |
|
31 | 32 | VXLAN_PORT = 13330 |
32 | 33 | DUT_VXLAN_PORT_JSON_FILE = '/tmp/vxlan.switch.json' |
@@ -111,23 +112,22 @@ def generate_fgnhg_config(duthost, ip_to_port, bank_0_port, bank_1_port): |
111 | 112 |
|
112 | 113 |
|
113 | 114 | def setup_neighbors(duthost, ptfhost, ip_to_port): |
114 | | - duthost.shell("sonic-clear fdb all") |
115 | | - duthost.shell("sonic-clear arp") |
116 | | - duthost.shell("sonic-clear ndp") |
117 | 115 | vlan_name = "Vlan" + str(DEFAULT_VLAN_ID) |
118 | 116 | neigh_entries = {} |
119 | 117 | neigh_entries['NEIGH'] = {} |
120 | 118 |
|
121 | 119 | for ip, port in list(ip_to_port.items()): |
122 | 120 |
|
| 121 | + neigh_mac = ptfhost.shell("cat /sys/class/net/eth" + str(port) + "/address")["stdout_lines"][0] |
| 122 | + ptf_to_dut_mac_map[port] = neigh_mac |
123 | 123 | if isinstance(ipaddress.ip_address(six.text_type(ip)), ipaddress.IPv4Address): |
124 | 124 | neigh_entries['NEIGH'][vlan_name + "|" + ip] = { |
125 | | - "neigh": ptfhost.shell("cat /sys/class/net/eth" + str(port) + "/address")["stdout_lines"][0], |
| 125 | + "neigh": neigh_mac, |
126 | 126 | "family": "IPv4" |
127 | 127 | } |
128 | 128 | else: |
129 | 129 | neigh_entries['NEIGH'][vlan_name + "|" + ip] = { |
130 | | - "neigh": ptfhost.shell("cat /sys/class/net/eth" + str(port) + "/address")["stdout_lines"][0], |
| 130 | + "neigh": neigh_mac, |
131 | 131 | "family": "IPv6" |
132 | 132 | } |
133 | 133 |
|
@@ -267,6 +267,33 @@ def validate_packet_flow_without_neighbor_resolution(ptfhost, duthost, ip_to_por |
267 | 267 | assert neigh_resolved |
268 | 268 |
|
269 | 269 |
|
| 270 | +def setup_static_neighbor_entry(duthost, ip, mac, prefix_list): |
| 271 | + """ |
| 272 | + Performs addition of static entries of ipv4 and v6 neighbors in DUT |
| 273 | + """ |
| 274 | + if isinstance(ipaddress.ip_network(prefix_list[0]), ipaddress.IPv4Network): |
| 275 | + logger.info("adding ipv4 static arp entry for ip %s on DUT" % (ip)) |
| 276 | + duthost.shell("sudo arp -s {0} {1}".format(ip, mac)) |
| 277 | + else: |
| 278 | + logger.info("adding ipv6 static arp entry for ip %s on DUT" % (ip)) |
| 279 | + duthost.shell("sudo ip -6 neigh replace {0} lladdr {1} dev Vlan{2}".format(ip, mac, DEFAULT_VLAN_ID)) |
| 280 | + |
| 281 | + |
| 282 | +def link_startup(duthost, ip_to_port, prefix_list, shutdown_link): |
| 283 | + """ |
| 284 | + Performs link startup on DUT |
| 285 | + """ |
| 286 | + dut_if_shutdown = ptf_to_dut_port_map[shutdown_link] |
| 287 | + configure_dut(duthost, "config interface startup " + dut_if_shutdown) |
| 288 | + |
| 289 | + # add static neighbor |
| 290 | + for nexthop, port in list(ip_to_port.items()): |
| 291 | + if port == shutdown_link: |
| 292 | + setup_static_neighbor_entry(duthost, nexthop, ptf_to_dut_mac_map[port], prefix_list) |
| 293 | + |
| 294 | + time.sleep(30) |
| 295 | + |
| 296 | + |
270 | 297 | def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank_0_port, bank_1_port, prefix_list): |
271 | 298 |
|
272 | 299 | # Init base test params |
@@ -330,8 +357,7 @@ def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank |
330 | 357 | logger.info("Send the same flows again, but unshut " + dut_if_shutdown + " and check " |
331 | 358 | "if flows reblanced as expected and are seen on now brought up link") |
332 | 359 |
|
333 | | - configure_dut(duthost, "config interface startup " + dut_if_shutdown) |
334 | | - time.sleep(30) |
| 360 | + link_startup(duthost, ip_to_port, prefix_list, shutdown_link) |
335 | 361 |
|
336 | 362 | flows_per_nh = NUM_FLOWS/len(port_list) |
337 | 363 | for port in port_list: |
@@ -394,8 +420,7 @@ def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank |
394 | 420 | logger.info("Send the same flows again, but startup " + dut_if_shutdown + " and check " |
395 | 421 | "the flow hash redistribution") |
396 | 422 |
|
397 | | - configure_dut(duthost, "config interface startup " + dut_if_shutdown) |
398 | | - time.sleep(30) |
| 423 | + link_startup(duthost, ip_to_port, prefix_list, shutdown_link) |
399 | 424 |
|
400 | 425 | exp_flow_count = {} |
401 | 426 | flows_for_withdrawn_nh_bank = (NUM_FLOWS/2)/(len(bank_0_port) - 1) |
|
0 commit comments