Browse Source

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
tags/10.0.0b1
Dmitry Guryanov 3 years ago
parent
commit
c5d6963e04
1 changed files with 20 additions and 0 deletions
  1. 20
    0
      agent

+ 20
- 0
agent View File

@@ -434,6 +434,16 @@ class NodeAgent
434 434
             rescue
435 435
               int_meta[:current_speed] = nil
436 436
             end
437
+
438
+            unless int_meta[:driver]
439
+              # Rethtool::InterfaceSettings calls two ioctls: with
440
+              # ETHTOOL_CMD_GSET and ETHTOOL_CMD_GDRVINFO commands.
441
+              # But for virtio adapters the first is not implemented,
442
+              # but the second is. So try to get driver info at least
443
+              # in this fallback chain.
444
+              int_meta[:driver], int_meta[:bus_info] = _get_interface_driver_info(int)
445
+            end
446
+
437 447
           elsif (addrinfo[:family] rescue nil) =~ /^inet$/
438 448
             int_meta[:ip] = addr
439 449
             int_meta[:netmask] = addrinfo[:netmask] if addrinfo[:netmask]
@@ -561,6 +571,16 @@ class NodeAgent
561 571
     detailed_meta
562 572
   end
563 573
 
574
+  def _get_interface_driver_info(int)
575
+    cmd_driver = Rethtool::EthtoolCmdDriver.new
576
+    cmd_driver.cmd = Rethtool::ETHTOOL_CMD_GDRVINFO
577
+    data = Rethtool.ioctl(int, cmd_driver)
578
+    [data.driver.pack('c*').delete("\000"), data.bus_info.pack('c*').delete("\000")]
579
+  rescue => e
580
+    @logger.error("Error '#{e.message}' while obtaining #{int} driver info.")
581
+    [nil, nil]
582
+  end
583
+
564 584
   def multipath_devices
565 585
     dmsetup = `/sbin/dmsetup info -c --nameprefixes --noheadings -o blkdevname,subsystem,blkdevs_used,name,uuid`
566 586
     # Example output:

Loading…
Cancel
Save