Skip to content

Commit

Permalink
add ethtool options to new backend
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Sep 2, 2019
1 parent cd458a0 commit 567f369
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
6 changes: 5 additions & 1 deletion src/lib/y2network/connection_config/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,22 @@ class Base
attr_accessor :ip_aliases
# @return [Integer, nil]
attr_accessor :mtu
# @return [Startmode, nil]
# @return [Startmode]
attr_accessor :startmode
# @return [String] Connection's description (e.g., "Ethernet Card 0")
attr_accessor :description
# @return [String] Link layer address
attr_accessor :lladdress
# @return [String] configuration for ethtools when initializing
attr_accessor :ethtool_options

# Constructor
def initialize
@ip_aliases = []
@bootproto = BootProtocol::STATIC # TODO: maybe do test query if physical interface is attached?
@startmode = Startmode.create("manual")
@description = ""
@ethtool_options = ""
end

# Propose reasonable defaults for given config. Useful for newly created devices.
Expand Down
27 changes: 7 additions & 20 deletions src/lib/y2network/interface_config_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.
require "yast"
require "forwardable"

require "y2network/connection_config"
require "y2network/hwinfo"
Expand All @@ -36,6 +37,7 @@ module Y2Network
# {Yast::LanItemsClass#Commit Yast::LanItems.Commit(builder)} use it.
class InterfaceConfigBuilder
include Yast::Logger
extend Forwardable

# Load fresh instance of interface config builder for given type.
# It can be specialized type or generic, depending if specialized is needed.
Expand All @@ -56,14 +58,17 @@ def self.for(type, config: nil)
# @return [String] Device name (eth0, wlan0, etc.)
attr_reader :name
# @return [Y2Network::InterfaceType] type of @see Y2Network::Interface which is intended to be build
attr_accessor :type
attr_reader :type
# @return [Y2Network::ConnectionConfig] connection config on which builder operates
attr_reader :connection_config
# @return [Symbol] Mechanism to rename the interface (:none -no hardware based-, :mac or :bus_id)
attr_writer :renaming_mechanism
# @return [Y2Network::Interface,nil] Underlying interface if it exists
attr_reader :interface

def_delegators :@connection_config,
:startmode, :ethtool_options, :ethtool_options=

# Constructor
#
# Load with reasonable defaults
Expand Down Expand Up @@ -192,9 +197,7 @@ def firewall_zone
end

# sets assigned firewall zone
def firewall_zone=(value)
@firewall_zone = value
end
attr_writer :firewall_zone

# @return [Y2Network::BootProtocol]
def boot_protocol
Expand All @@ -207,11 +210,6 @@ def boot_protocol=(value)
@connection_config.bootproto = Y2Network::BootProtocol.from_name(value)
end

# @return [Startmode]
def startmode
@connection_config.startmode
end

# @param [String,Y2Network::Startmode] name startmode name used to create Startmode object
# or object itself
def startmode=(name)
Expand Down Expand Up @@ -285,17 +283,6 @@ def aliases=(value)
@aliases = value
end

# TODO: eth only?
# @return [String]
def ethtool_options
@config["ETHTOOL_OPTIONS"]
end

# @param [String] value
def ethtool_options=(value)
@config["ETHTOOL_OPTIONS"] = value
end

# @return [String]
def ip_address
default = @connection_config.ip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def connection_config
conn.lladdress = file.lladdr
conn.startmode = Startmode.create(file.startmode || "manual")
conn.startmode.priority = file.ifplugd_priority if conn.startmode.name == "ifplugd"
conn.ethtool_options = file.ethtool_options
update_connection_config(conn)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def write(conn)
file.lladdr = conn.lladdress
file.startmode = conn.startmode.to_s
file.ifplugd_priority = conn.startmode.priority if conn.startmode.name == "ifplugd"
file.ethtool_options = conn.ethtool_options unless conn.ethtool_options.empty?
add_ips(conn)
update_file(conn)
end
Expand Down
4 changes: 4 additions & 0 deletions src/lib/y2network/sysconfig/interface_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ def variable_name(param_name)
# @return [String] Link layer address
define_variable(:lladdr)

# !@attribute [r] ethtool_options
# @return [String] setting variables on device activation. See man ethtool
define_variable(:ethtool_options)

# !@attribute [r] wireless_key_length
# @return [Integer] Length in bits for all keys used
define_variable(:wireless_key_length, :integer)
Expand Down

0 comments on commit 567f369

Please sign in to comment.