Skip to content

Commit

Permalink
Remove default hash-offset for chassis-packet (sonic-net#19745)
Browse files Browse the repository at this point in the history
Why I did it
Fixes sonic-net#19746

switch.json in swss docker sets the default hash offset to 0 for chassis-packet. The change was recently introduced via sonic-net#18912 which was supposed to be only for T0/T1. On chassis-packet, each asics needs to set an unique hash offset to set an unique offset for load balancing algorithm. The new change overwrites platform setting and resets the hash-offset to 0 on all asics. This breaks the ecmp load balancing algorithm on chassis-packet.

How I did it
Remove the default hash-offset setting for chassis-packet. This setting is provided by platform based on platform specific rules.

How to verify it
Run sonic-mgmt fib/test_fib.py

Signed-off-by: anamehra <anamehra@cisco.com>
  • Loading branch information
anamehra authored Sep 4, 2024
1 parent eee217d commit f0979dd
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dockers/docker-orchagent/switch.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
"ecmp_hash_seed": "{{ hash_seed_value }}",
"lag_hash_seed": "{{ hash_seed_value }}",
"fdb_aging_time": "600",
{% if not DEVICE_METADATA.localhost.switch_type or DEVICE_METADATA.localhost.switch_type != "chassis-packet" %}
"ecmp_hash_offset": "{{ ecmp_hash_offset_value }}",
"lag_hash_offset": "{{ lag_hash_offset_value }}",
{% endif %}
{% if DEVICE_METADATA.localhost.type and "LeafRouter" in DEVICE_METADATA.localhost.type %}
"ordered_ecmp": "true"
{% else %}
Expand Down
11 changes: 11 additions & 0 deletions src/sonic-config-engine/tests/sample_output/t2-switch-masic1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"SWITCH_TABLE:switch": {
"ecmp_hash_seed": "26",
"lag_hash_seed": "26",
"fdb_aging_time": "600",
"ordered_ecmp": "false"
},
"OP": "SET"
}
]
11 changes: 11 additions & 0 deletions src/sonic-config-engine/tests/sample_output/t2-switch-masic3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"SWITCH_TABLE:switch": {
"ecmp_hash_seed": "28",
"lag_hash_seed": "28",
"fdb_aging_time": "600",
"ordered_ecmp": "false"
},
"OP": "SET"
}
]
31 changes: 31 additions & 0 deletions src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def setUp(self):
self.no_ip_helper_minigraph = os.path.join(self.test_dir, 't0-sample-no-ip-helper-graph.xml')
self.nokia_ixr7250e_36x100g_t2_minigraph = os.path.join(self.test_dir, 'sample-nokia-ixr7250e-36x100g-t2-minigraph.xml')
self.nokia_ixr7250e_36x400g_t2_minigraph = os.path.join(self.test_dir, 'sample-nokia-ixr7250e-36x400g-t2-minigraph.xml')
self.t2_sample_graph_chassis_packet = os.path.join(self.test_dir, 'sample-chassis-packet-lc-graph.xml')
self.output_file = os.path.join(self.test_dir, 'output')
os.environ["CFGGEN_UNIT_TESTING"] = "2"

Expand Down Expand Up @@ -753,6 +754,36 @@ def test_swss_switch_render_template_multi_asic(self):
assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
os.environ["NAMESPACE_ID"] = ""

def test_swss_switch_render_template_t2(self):
# verify the ECMP hash seed changes per namespace
switch_template = os.path.join(
self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent',
'switch.json.j2'
)
constants_yml = os.path.join(
self.test_dir, '..', '..', '..', 'files', 'image_config',
'constants', 'constants.yml'
)
test_list = {
"0": {
"namespace_id": "1",
"output": "t2-switch-masic1.json"
},
"1": {
"namespace_id": "3",
"output": "t2-switch-masic3.json"
},
}
for _, v in test_list.items():
os.environ["NAMESPACE_ID"] = v["namespace_id"]
argument = ["-m", self.t2_sample_graph_chassis_packet, "-y", constants_yml, "-t", switch_template]
sample_output_file = os.path.join(
self.test_dir, 'sample_output', v["output"]
)
self.run_script(argument, output_file=self.output_file)
assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)
os.environ["NAMESPACE_ID"] = ""

def test_ndppd_conf(self):
conf_template = os.path.join(self.test_dir, "ndppd.conf.j2")
vlan_interfaces_json = os.path.join(self.test_dir, "data", "ndppd", "vlan_interfaces.json")
Expand Down

0 comments on commit f0979dd

Please sign in to comment.