Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions tests/ecmp/test_fgnhg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
USE_INNER_HASHING = False
NUM_FLOWS = 1000
ptf_to_dut_port_map = {}
ptf_to_dut_mac_map = {}

VXLAN_PORT = 13330
DUT_VXLAN_PORT_JSON_FILE = '/tmp/vxlan.switch.json'
Expand Down Expand Up @@ -111,23 +112,22 @@ def generate_fgnhg_config(duthost, ip_to_port, bank_0_port, bank_1_port):


def setup_neighbors(duthost, ptfhost, ip_to_port):
duthost.shell("sonic-clear fdb all")
duthost.shell("sonic-clear arp")
duthost.shell("sonic-clear ndp")
vlan_name = "Vlan" + str(DEFAULT_VLAN_ID)
neigh_entries = {}
neigh_entries['NEIGH'] = {}

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

neigh_mac = ptfhost.shell("cat /sys/class/net/eth" + str(port) + "/address")["stdout_lines"][0]
ptf_to_dut_mac_map[port] = neigh_mac
if isinstance(ipaddress.ip_address(six.text_type(ip)), ipaddress.IPv4Address):
neigh_entries['NEIGH'][vlan_name + "|" + ip] = {
"neigh": ptfhost.shell("cat /sys/class/net/eth" + str(port) + "/address")["stdout_lines"][0],
"neigh": neigh_mac,
"family": "IPv4"
}
else:
neigh_entries['NEIGH'][vlan_name + "|" + ip] = {
"neigh": ptfhost.shell("cat /sys/class/net/eth" + str(port) + "/address")["stdout_lines"][0],
"neigh": neigh_mac,
"family": "IPv6"
}

Expand Down Expand Up @@ -267,6 +267,17 @@ def validate_packet_flow_without_neighbor_resolution(ptfhost, duthost, ip_to_por
assert neigh_resolved


def static_neighbor_entry(duthost, ip, mac, prefix_list):
"""
Performs addition of static entries of ipv4 and v6 neighbors in DUT
"""
if isinstance(ipaddress.ip_network(prefix_list[0]), ipaddress.IPv4Network):
logger.info("adding ipv4 static arp entry for ip %s on DUT" % (ip))
duthost.shell("sudo arp -s {0} {1}".format(ip, mac))
else:
logger.info("adding ipv6 static arp entry for ip %s on DUT" % (ip))
duthost.shell("sudo ip -6 neigh replace {0} lladdr {1} dev Vlan{2}".format(ip, mac, DEFAULT_VLAN_ID))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the static neighbor removed?

Copy link
Contributor Author

@alawing alawing Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From 202205 and newer version. When testing shut down an interface, the neighbor/Arp tables will lose the static neighbor

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern is the statically added neighbor will be there permanently, which may impact other tests running after test_fgnhg. Suggest adding a cleanup to remove the statically programmed neigh

Copy link
Contributor Author

@alawing alawing Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neighbor entries will be flushed when reloading config after tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought we fixed it by sonic-net/sonic-swss#2469

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought we fixed it by sonic-net/sonic-swss#2469

That PR is not fixing the issue we have on this test.


def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank_0_port, bank_1_port, prefix_list):

# Init base test params
Expand Down Expand Up @@ -330,6 +341,11 @@ def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank
logger.info("Send the same flows again, but unshut " + dut_if_shutdown + " and check "
"if flows reblanced as expected and are seen on now brought up link")

#add static neighbor
for nexthop, port in list(ip_to_port.items()):
if port == shutdown_link:
static_neighbor_entry(duthost, nexthop, ptf_to_dut_mac_map[port], prefix_list)

configure_dut(duthost, "config interface startup " + dut_if_shutdown)
time.sleep(30)

Expand Down Expand Up @@ -394,6 +410,11 @@ def fg_ecmp(ptfhost, duthost, router_mac, net_ports, port_list, ip_to_port, bank
logger.info("Send the same flows again, but startup " + dut_if_shutdown + " and check "
"the flow hash redistribution")

#add static neighbor
for nexthop, port in list(ip_to_port.items()):
if port == shutdown_link:
static_neighbor_entry(duthost, nexthop, ptf_to_dut_mac_map[port], prefix_list)

configure_dut(duthost, "config interface startup " + dut_if_shutdown)
time.sleep(30)

Expand Down