summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-09-01 19:48:09 +0200
committerChristian Poessinger <christian@poessinger.com>2019-09-01 19:48:09 +0200
commit736b3eca504bf9f57f12166bef7f3bfb347cf522 (patch)
tree12ada917a87cba647af8fcf37f54748b0c38e9d8 /python
parente7711bf0693e8463731cdbc955b18311738f42a5 (diff)
downloadvyos-1x-736b3eca504bf9f57f12166bef7f3bfb347cf522.tar.gz
vyos-1x-736b3eca504bf9f57f12166bef7f3bfb347cf522.zip
Python/ifconfig: T1557: bonding: add xmit_hash_policy
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 71d608511..b03550626 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -954,3 +954,47 @@ class BridgeIf(Interface):
"""
return self._write_sysfs('/sys/class/net/{}/brif/{}/priority'
.format(self._ifname, interface), priority)
+
+
+class BondIf(Interface):
+ def __init__(self, ifname):
+ super().__init__(ifname, type='bond')
+
+ @property
+ def xmit_hash_policy(self):
+ """
+ Selects the transmit hash policy to use for slave selection in
+ balance-xor, 802.3ad, and tlb modes. Possible values are: layer2,
+ layer2+3, layer3+4, encap2+3, encap3+4.
+
+ The default value is layer2
+
+ Example:
+ >>> from vyos.ifconfig import BondIf
+ >>> BondIf('bond0').xmit_hash_policy
+ 'layer3+4'
+ """
+ # Linux Kernel appends has policy value to string, e.g. 'layer3+4 1',
+ # so remove the later part and only return the mode as string.
+ return self._read_sysfs('/sys/class/net/{}/bonding/xmit_hash_policy'
+ .format(self._ifname)).split(' ')[0]
+
+ @xmit_hash_policy.setter
+ def xmit_hash_policy(self, mode):
+ """
+ Selects the transmit hash policy to use for slave selection in
+ balance-xor, 802.3ad, and tlb modes. Possible values are: layer2,
+ layer2+3, layer3+4, encap2+3, encap3+4.
+
+ The default value is layer2
+
+ Example:
+ >>> from vyos.ifconfig import Interface
+ >>> BondIf('bond0').xmit_hash_policy = 'layer2+3'
+ >>> BondIf('bond0').proxy_arp
+ '1'
+ """
+ if not mode in ['layer2', 'layer2+3', 'layer3+4', 'encap2+3', 'encap3+4']:
+ raise ValueError()
+ return self._write_sysfs('/sys/class/net/{}/bonding/xmit_hash_policy'
+ .format(self._ifname), mode)