diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-09-17 12:11:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 12:11:45 +0200 |
commit | f4b7b705297b0f6353dbe65c413109d6c136019d (patch) | |
tree | a3f202b438a8c87ed495ee76a66adc711d6c947c /python/vyos | |
parent | 43359c2b824d53b5f82dea937f817139cbf77f8f (diff) | |
parent | 2fc157115cb358afba89f92a761c6617159624fc (diff) | |
download | vyos-1x-f4b7b705297b0f6353dbe65c413109d6c136019d.tar.gz vyos-1x-f4b7b705297b0f6353dbe65c413109d6c136019d.zip |
Merge pull request #546 from DmitriyEshenko/cur-1x-rb
ethernet: T2891: Add ethernet ring-buffer CLI commands
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/ifconfig/ethernet.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py index 17c1bd64d..d4014a4dc 100644 --- a/python/vyos/ifconfig/ethernet.py +++ b/python/vyos/ifconfig/ethernet.py @@ -253,6 +253,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 +314,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 |