Change in vdsm[ovirt-3.4]: netconfig: set ETHTOOL_OPTS when a NIC goes up
danken at redhat.com
danken at redhat.com
Mon Jan 27 15:16:57 UTC 2014
Dan Kenigsberg has uploaded a new change for review.
Change subject: netconfig: set ETHTOOL_OPTS when a NIC goes up
......................................................................
netconfig: set ETHTOOL_OPTS when a NIC goes up
There's broken hardware out there where lro needs to to be turned off
explicitly.
This patch lets an admin of a local node set
ethtool_opts.eth0 = lro off
to disable LRO on the interface named eth0.
Change-Id: Ic8a5a933e1c93f80185d61f3cd43eee53c3a7c1a
Signed-off-by: Dan Kenigsberg <danken at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/23366
Reviewed-by: Douglas Schilling Landgraf <dougsland at redhat.com>
Reviewed-by: Antoni Segura Puimedon <asegurap at redhat.com>
(cherry picked from commit e963d155904a814db48ac1cfbf18ae82b1b33c36)
---
M lib/vdsm/config.py.in
M vdsm/netconf/__init__.py
M vdsm/netconf/ifcfg.py
M vdsm/netconf/iproute2.py
4 files changed, 34 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/23761/1
diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index e279c87..0f84f16 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -54,6 +54,12 @@
'NetworkManager is disabled and device name persistence does '
'not depend on HWADDR.'),
+ ('ethtool_opts', '',
+ 'Which special ethtool options should be applied to NICs after '
+ 'they are taken up, e.g. "lro off" on buggy devices. '
+ 'To apply options to a single interface, '
+ 'set ethtool_opts.iface_name.'),
+
('nic_model', 'rtl8139,pv',
'NIC model is rtl8139, ne2k_pci pv or any other valid device '
'recognized by kvm/qemu if a coma separated list given then a '
diff --git a/vdsm/netconf/__init__.py b/vdsm/netconf/__init__.py
index 7ab63da..6d8cbd8 100644
--- a/vdsm/netconf/__init__.py
+++ b/vdsm/netconf/__init__.py
@@ -17,6 +17,7 @@
# Refer to the README and COPYING files for full details of the license
#
+import ConfigParser
import logging
import libvirtCfg
@@ -24,6 +25,7 @@
from sourceRoute import DynamicSourceRoute
from sourceRoute import StaticSourceRoute
from vdsm import netinfo
+from vdsm.config import config
from vdsm.netconfpersistence import RunningConfig
@@ -145,3 +147,10 @@
self.configApplier.setBondingMtu(iface.name, maxMtu)
else:
self.configApplier.setIfaceMtu(iface.name, maxMtu)
+
+ def getEthtoolOpts(self, name):
+ try:
+ opts = config.get('vars', 'ethtool_opts.' + name)
+ except ConfigParser.NoOptionError:
+ opts = config.get('vars', 'ethtool_opts')
+ return opts
diff --git a/vdsm/netconf/ifcfg.py b/vdsm/netconf/ifcfg.py
index c5e6074..1364d82 100644
--- a/vdsm/netconf/ifcfg.py
+++ b/vdsm/netconf/ifcfg.py
@@ -626,6 +626,10 @@
if nic.bond:
conf += 'MASTER=%s\nSLAVE=yes\n' % pipes.quote(nic.bond.name)
+ ethtool_opts = self.getEthtoolOpts(nic.name)
+ if ethtool_opts:
+ conf += 'ETHTOOL_OPTS=%s\n' % pipes.quote(ethtool_opts)
+
ipconfig, mtu = self._getIfaceConfValues(nic, _netinfo)
self._createConfFile(conf, nic.name, ipconfig, mtu, **opts)
diff --git a/vdsm/netconf/iproute2.py b/vdsm/netconf/iproute2.py
index 86727d3..e9ce7cc 100644
--- a/vdsm/netconf/iproute2.py
+++ b/vdsm/netconf/iproute2.py
@@ -32,7 +32,15 @@
from vdsm.ipwrapper import ruleAdd
from vdsm.ipwrapper import ruleDel
from vdsm.netconfpersistence import RunningConfig
+from vdsm.utils import CommandPath
from vdsm.utils import execCmd
+
+_ETHTOOL_BINARY = CommandPath(
+ 'ethtool',
+ '/usr/sbin/ethtool', # F19+
+ '/sbin/ethtool', # EL6, ubuntu and Debian
+ '/usr/bin/ethtool', # Arch
+)
class Iproute2(Configurator):
@@ -113,6 +121,13 @@
def configureNic(self, nic, **opts):
self.configApplier.setIfaceConfigAndUp(nic)
+ ethtool_opts = self.getEthtoolOpts(nic.name)
+ if ethtool_opts:
+ # We ignore ethtool's return code to maintain initscripts'
+ # behaviour.
+ execCmd(
+ [_ETHTOOL_BINARY.cmd, '-K', nic.name] + ethtool_opts.split())
+
def removeBridge(self, bridge):
self.configApplier.ifdown(bridge)
self.configApplier.removeBridge(bridge)
--
To view, visit http://gerrit.ovirt.org/23761
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8a5a933e1c93f80185d61f3cd43eee53c3a7c1a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.4
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>
More information about the vdsm-patches
mailing list