ifcfg: enable writing/reading of speed and duplex when autoneg is enabled

This commit is contained in:
Francesco Giudici 2018-06-14 20:08:52 +02:00
parent 064ea1c58e
commit 193aae91eb
2 changed files with 12 additions and 13 deletions

View file

@ -4174,8 +4174,8 @@ parse_ethtool_options (shvarFile *ifcfg, NMSettingWired *s_wired, const char *va
NM_SETTING_WIRED_WAKE_ON_LAN, wol_flags,
NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, ignore_wol_password ? NULL : wol_password,
NM_SETTING_WIRED_AUTO_NEGOTIATE, autoneg,
NM_SETTING_WIRED_SPEED, autoneg ? 0 : speed,
NM_SETTING_WIRED_DUPLEX, autoneg ? NULL : duplex,
NM_SETTING_WIRED_SPEED, speed,
NM_SETTING_WIRED_DUPLEX, duplex,
NULL);
}

View file

@ -1135,6 +1135,9 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
/* Stuff ETHTOOL_OPT with required options */
str = NULL;
auto_negotiate = nm_setting_wired_get_auto_negotiate (s_wired);
speed = nm_setting_wired_get_speed (s_wired);
duplex = nm_setting_wired_get_duplex (s_wired);
/* autoneg off + speed 0 + duplex NULL, means we want NM
* to skip link configuration which is default. So write
* down link config only if we have auto-negotiate true or
@ -1143,18 +1146,14 @@ write_wired_setting (NMConnection *connection, shvarFile *ifcfg, GError **error)
if (auto_negotiate) {
str = g_string_sized_new (64);
g_string_printf (str, "autoneg on");
} else {
speed = nm_setting_wired_get_speed (s_wired);
duplex = nm_setting_wired_get_duplex (s_wired);
if (speed || duplex) {
str = g_string_sized_new (64);
g_string_printf (str, "autoneg off");
if (speed)
g_string_append_printf (str, " speed %u", speed);
if (duplex)
g_string_append_printf (str, " duplex %s", duplex);
}
} else if (speed || duplex) {
str = g_string_sized_new (64);
g_string_printf (str, "autoneg off");
}
if (speed)
g_string_append_printf (str, " speed %u", speed);
if (duplex)
g_string_append_printf (str, " duplex %s", duplex);
wol = nm_setting_wired_get_wake_on_lan (s_wired);
wol_password = nm_setting_wired_get_wake_on_lan_password (s_wired);