summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig/ethernet.py
diff options
context:
space:
mode:
authorMarcus Hoff <marcus.hoff@ring2.dk>2020-09-20 11:59:32 +0200
committerMarcus Hoff <marcus.hoff@ring2.dk>2020-09-20 11:59:32 +0200
commit45b30adfaaec7065f768d04085138a75a76ed376 (patch)
treea9cd47236468077141eee56068ba23027b0d4c7d /python/vyos/ifconfig/ethernet.py
parent46fb580fa0131f6815bbcfc95631654f6fe999a8 (diff)
parente0797331774a02ca23e8363fbcfe5a49fb3ca2bd (diff)
downloadvyos-1x-45b30adfaaec7065f768d04085138a75a76ed376.tar.gz
vyos-1x-45b30adfaaec7065f768d04085138a75a76ed376.zip
Merge remote-tracking branch 'upstream/current' into current
Diffstat (limited to 'python/vyos/ifconfig/ethernet.py')
-rw-r--r--python/vyos/ifconfig/ethernet.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py
index 17c1bd64d..1d48941f9 100644
--- a/python/vyos/ifconfig/ethernet.py
+++ b/python/vyos/ifconfig/ethernet.py
@@ -17,13 +17,11 @@ import os
import re
from vyos.ifconfig.interface import Interface
-from vyos.ifconfig.vlan import VLAN
from vyos.validate import assert_list
from vyos.util import run
from vyos.util import vyos_dict_search
@Interface.register
-@VLAN.enable
class EthernetIf(Interface):
"""
Abstraction of a Linux Ethernet Interface
@@ -253,6 +251,22 @@ class EthernetIf(Interface):
"""
return self.set_interface('ufo', state)
+ def set_ring_buffer(self, b_type, b_size):
+ """
+ Example:
+ >>> from vyos.ifconfig import EthernetIf
+ >>> i = EthernetIf('eth0')
+ >>> i.set_ring_buffer('rx', '4096')
+ """
+ cmd = '/sbin/ethtool -G {0} {1} {2}'.format(self.config['ifname'], b_type, b_size)
+ output, code = self._popen(cmd)
+ # ethtool error codes:
+ # 80 - value already setted
+ # 81 - does not possible to set value
+ if code and code != 80:
+ print('could not set {0} ring-buffer for {1}'.format(b_type, self.config['ifname']))
+ return output
+
def update(self, config):
""" General helper function which works on a dictionary retrived by
@@ -298,6 +312,11 @@ class EthernetIf(Interface):
duplex = config.get('duplex')
self.set_speed_duplex(speed, duplex)
+ # Set interface ring buffer
+ if 'ring_buffer' in config:
+ for b_type in config['ring_buffer']:
+ self.set_ring_buffer(b_type, config['ring_buffer'][b_type])
+
# Enable/Disable of an interface must always be done at the end of the
# derived class to make use of the ref-counting set_admin_state()
# function. We will only enable the interface if 'up' was called as