Skip to content

Commit 297468d

Browse files
alawingmssonicbld
authored andcommitted
Added adding static route before startup interfaces (sonic-net#14699)
* added static routes before interface startup * fixed ipv6 from add to replace * address comments * fix pre-commit issue
1 parent f3eebc2 commit 297468d

1 file changed

Lines changed: 34 additions & 9 deletions

File tree

tests/ecmp/test_fgnhg.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
USE_INNER_HASHING = False
2828
NUM_FLOWS = 1000
2929
ptf_to_dut_port_map = {}
30+
ptf_to_dut_mac_map = {}
3031

3132
VXLAN_PORT = 13330
3233
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):
111112

112113

113114
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")
117115
vlan_name = "Vlan" + str(DEFAULT_VLAN_ID)
118116
neigh_entries = {}
119117
neigh_entries['NEIGH'] = {}
120118

121119
for ip, port in list(ip_to_port.items()):
122120

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
123123
if isinstance(ipaddress.ip_address(six.text_type(ip)), ipaddress.IPv4Address):
124124
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,
126126
"family": "IPv4"
127127
}
128128
else:
129129
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,
131131
"family": "IPv6"
132132
}
133133

@@ -267,6 +267,33 @@ def validate_packet_flow_without_neighbor_resolution(ptfhost, duthost, ip_to_por
267267
assert neigh_resolved
268268

269269

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+
270297
def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank_0_port, bank_1_port, prefix_list):
271298

272299
# Init base test params
@@ -330,8 +357,7 @@ def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank
330357
logger.info("Send the same flows again, but unshut " + dut_if_shutdown + " and check "
331358
"if flows reblanced as expected and are seen on now brought up link")
332359

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)
335361

336362
flows_per_nh = NUM_FLOWS/len(port_list)
337363
for port in port_list:
@@ -394,8 +420,7 @@ def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank
394420
logger.info("Send the same flows again, but startup " + dut_if_shutdown + " and check "
395421
"the flow hash redistribution")
396422

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)
399424

400425
exp_flow_count = {}
401426
flows_for_withdrawn_nh_bank = (NUM_FLOWS/2)/(len(bank_0_port) - 1)

0 commit comments

Comments
 (0)