diff options
-rw-r--r-- | interface-definitions/interfaces-bonding.xml.in | 14 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_interfaces_bonding.py | 17 |
2 files changed, 28 insertions, 3 deletions
diff --git a/interface-definitions/interfaces-bonding.xml.in b/interface-definitions/interfaces-bonding.xml.in index cf9fb73eb..6c5e2abcc 100644 --- a/interface-definitions/interfaces-bonding.xml.in +++ b/interface-definitions/interfaces-bonding.xml.in @@ -60,7 +60,7 @@ <properties> <help>Bonding transmit hash policy</help> <completionHelp> - <list>layer2 layer2+3 layer3+4</list> + <list>layer2 layer2+3 layer3+4 encap2+3 encap3+4</list> </completionHelp> <valueHelp> <format>layer2</format> @@ -74,10 +74,18 @@ <format>layer3+4</format> <description>combine IP address and port to make hash</description> </valueHelp> + <valueHelp> + <format>encap2+3</format> + <description>combine encapsulated MAC address and IP address to make hash</description> + </valueHelp> + <valueHelp> + <format>encap3+4</format> + <description>combine encapsulated IP address and port to make hash</description> + </valueHelp> <constraint> - <regex>^(layer2\+3|layer3\+4|layer2)$</regex> + <regex>^(layer2\+3|layer3\+4|layer2|encap2\+3|encap3\+4)$</regex> </constraint> - <constraintErrorMessage>hash-policy must be layer2 layer2+3 or layer3+4</constraintErrorMessage> + <constraintErrorMessage>hash-policy must be layer2 layer2+3 layer3+4 encap2+3 or encap3+4</constraintErrorMessage> </properties> <defaultValue>layer2</defaultValue> </leafNode> diff --git a/smoketest/scripts/cli/test_interfaces_bonding.py b/smoketest/scripts/cli/test_interfaces_bonding.py index 4771eb6b6..880a822a7 100755 --- a/smoketest/scripts/cli/test_interfaces_bonding.py +++ b/smoketest/scripts/cli/test_interfaces_bonding.py @@ -130,5 +130,22 @@ class BondingInterfaceTest(BasicInterfaceTest.BaseTest): self.assertEqual(0, tmp['linkinfo']['info_data']['min_links']) self.assertEqual(lacp_rate, tmp['linkinfo']['info_data']['ad_lacp_rate']) + def test_bonding_hash_policy(self): + # Define available bonding hash policies + hash_policies = ['layer2', 'layer2+3', 'layer2+3', 'encap2+3', 'encap3+4'] + for hash_policy in hash_policies: + for interface in self._interfaces: + for option in self._options.get(interface, []): + self.session.set(self._base_path + [interface] + option.split()) + + self.session.set(self._base_path + [interface, 'hash-policy', hash_policy]) + + self.session.commit() + + # verify config + for interface in self._interfaces: + defined_policy = read_file(f'/sys/class/net/{interface}/bonding/xmit_hash_policy').split() + self.assertEqual(defined_policy[0], hash_policy) + if __name__ == '__main__': unittest.main(verbosity=2) |