bond: add support to vlan+srcmac tx hashing option

The new vlan+srcmac tx hashing option is now available at kernel
upstream. Nmstate is now supporting it.

Ref: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=7b8fc0103bb51d1d3e1fb5fd67958612e709f883

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
This commit is contained in:
Fernando Fernandez Mancera 2021-01-25 15:52:32 +01:00 committed by Gris Ge
parent 9e43f68bb7
commit ebf5777afb
2 changed files with 32 additions and 1 deletions

View File

@ -260,6 +260,7 @@ _BOND_OPTIONS_NUMERIC_TO_NAMED_MAP = {
"layer2+3",
"encap2+3",
"encap3+4",
"vlan+srcmac",
),
}

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2018-2020 Red Hat, Inc.
# Copyright (c) 2018-2021 Red Hat, Inc.
#
# This file is part of nmstate
#
@ -17,6 +17,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
import os
import time
import pytest
@ -986,3 +987,32 @@ def test_ignore_verification_error_on_invalid_bond_option(eth1_up, eth2_up):
Bond.OPTIONS_SUBTREE
]
)
def _nmcli_get_bond_options(ifname):
rc, output, _ = cmdlib.exec_cmd(
f"nmcli -g bond.options c show {ifname}".split(), check=True
)
return output
@pytest.mark.skipif(
os.environ.get("CI") == "true",
reason="xmit hash policy vlan+srcmac is only supported in upstream kernel",
)
def test_set_xmit_hash_policy_to_vlan_srcmac(eth1_up, eth2_up):
port = [
eth1_up[Interface.KEY][0][Interface.NAME],
eth2_up[Interface.KEY][0][Interface.NAME],
]
extra_iface_state = {
Bond.CONFIG_SUBTREE: {
Bond.MODE: BondMode.XOR,
Bond.OPTIONS_SUBTREE: {
"xmit_hash_policy": "vlan+srcmac",
},
}
}
with bond_interface(BOND99, port, extra_iface_state=extra_iface_state):
options = _nmcli_get_bond_options(BOND99)
assert "vlan+srcmac" in options