lib/rethtool/interface_settings.rb in rethtool-0.0.3 vs lib/rethtool/interface_settings.rb in rethtool-0.0.4

- old
+ new

@@ -34,10 +34,11 @@ end # Create a new InterfaceSettings object. Simply pass it the name of the # interface you want to get the settings for. def initialize(interface) + @interface = interface cmd = Rethtool::EthtoolCmd.new cmd.cmd = Rethtool::ETHTOOL_CMD_GSET @data = Rethtool.ioctl(interface, cmd) end @@ -85,9 +86,17 @@ # (fec > full > half). def best_mode modes = self.advertised_modes best_speed = modes.map { |m| m.speed }.sort.last high_speed_modes = modes.find_all { |m| m.speed == best_speed } + + # Somewhere recently, RHEL decided to release a kernel or libc update + # that changes the behaviour of the ethtool ioctl so that instead of + # returning EOPNOTSUPP when you ask for available speeds on an interface + # that doesn't support that (like bonded NICs), it now returns success with + # an empty list. WHO DOES THAT SORT OF SHIT?!? So we've got to fake it + # ourselves. + raise Errno::EOPNOTSUPP.new("#{@interface} doesn't support enumerating speed modes") if modes.empty? if high_speed_modes.length == 0 raise RuntimeError.new("Can't happen: no modes with the best speed?!?") elsif high_speed_modes.length == 1 high_speed_modes.first