Don't use Rethtool for retrieving driver information

Rethtool executes two ioctls SIOCETHTOOL, one with
command ETHTOOL_GLINKSETTINGS and then with ETHTOOL_GDRVINFO,
but some drivers (like virtio) don't implement
ETHTOOL_GLINKSETTINGS, so it fails.

I've send patch to the author of Rethtool, but he haven't
replied yet, and it also will take some time to have this
fix in out Rethtool package. So let's call ioctl
seaprately if Rethtool::InterfaceSettings failed.

Change-Id: Iea95e1b132a33621f7538c4b0ba43b134e2560ee
This commit is contained in:
Dmitry Guryanov 2016-05-20 17:43:45 +03:00
parent 5121bd658f
commit c5d6963e04
1 changed files with 20 additions and 0 deletions

20
agent
View File

@ -434,6 +434,16 @@ class NodeAgent
rescue
int_meta[:current_speed] = nil
end
unless int_meta[:driver]
# Rethtool::InterfaceSettings calls two ioctls: with
# ETHTOOL_CMD_GSET and ETHTOOL_CMD_GDRVINFO commands.
# But for virtio adapters the first is not implemented,
# but the second is. So try to get driver info at least
# in this fallback chain.
int_meta[:driver], int_meta[:bus_info] = _get_interface_driver_info(int)
end
elsif (addrinfo[:family] rescue nil) =~ /^inet$/
int_meta[:ip] = addr
int_meta[:netmask] = addrinfo[:netmask] if addrinfo[:netmask]
@ -561,6 +571,16 @@ class NodeAgent
detailed_meta
end
def _get_interface_driver_info(int)
cmd_driver = Rethtool::EthtoolCmdDriver.new
cmd_driver.cmd = Rethtool::ETHTOOL_CMD_GDRVINFO
data = Rethtool.ioctl(int, cmd_driver)
[data.driver.pack('c*').delete("\000"), data.bus_info.pack('c*').delete("\000")]
rescue => e
@logger.error("Error '#{e.message}' while obtaining #{int} driver info.")
[nil, nil]
end
def multipath_devices
dmsetup = `/sbin/dmsetup info -c --nameprefixes --noheadings -o blkdevname,subsystem,blkdevs_used,name,uuid`
# Example output: