ifcfg-rh: fix persisting all-default NMSettingEthtool with autoneg/wol flags

Fixes: 26ed9e6714 ('ifcfg-rh: fix persisting all-default NMSettingEthtool settings')
(cherry picked from commit 4303d33727)
This commit is contained in:
Thomas Haller 2022-11-08 21:50:42 +01:00
parent 553e037220
commit 40564c5d6a
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
3 changed files with 7 additions and 9 deletions

View file

@ -1312,6 +1312,7 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error
gboolean is_first;
guint32 u32;
gboolean b;
gboolean any_option = FALSE;
s_con = nm_connection_get_setting_connection(connection);
if (s_con) {
@ -1341,6 +1342,7 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error
g_string_append_c(str, ' ');
g_string_append(str, nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id));
g_string_append(str, b ? " on" : " off");
any_option = TRUE;
}
is_first = TRUE;
@ -1356,6 +1358,7 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error
g_string_append_c(str, ' ');
g_string_append(str, nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id));
g_string_append_printf(str, " %" G_GUINT32_FORMAT, u32);
any_option = TRUE;
}
is_first = TRUE;
@ -1371,6 +1374,7 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error
g_string_append_c(str, ' ');
g_string_append(str, nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id));
g_string_append_printf(str, " %" G_GUINT32_FORMAT, u32);
any_option = TRUE;
}
is_first = TRUE;
@ -1386,9 +1390,10 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error
g_string_append_c(str, ' ');
g_string_append(str, nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id));
g_string_append(str, b ? " on" : " off");
any_option = TRUE;
}
if (!str) {
if (!any_option) {
/* Write an empty dummy "-A" option without arguments. This is to
* ensure that the reader will create an (all default) NMSettingEthtool.
* Also, it seems that `ethtool -A "$IFACE"` is silently accepted. */

View file

@ -1,7 +1,7 @@
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
ETHTOOL_OPTS="autoneg on ; -A net0 pause-autoneg off"
ETHTOOL_OPTS="autoneg on ; -A net0"
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no

View file

@ -3527,8 +3527,6 @@ test_roundtrip_ethtool(void)
g_object_set(s_wired, NM_SETTING_WIRED_AUTO_NEGOTIATE, TRUE, NULL);
s_ethtool = _nm_connection_new_setting(connection, NM_TYPE_SETTING_ETHTOOL);
/* FIXME: ensure proper round-trip with no ethtool settings set. */
nm_setting_option_set_boolean(s_ethtool, NM_ETHTOOL_OPTNAME_PAUSE_AUTONEG, FALSE);
_writer_new_connec_exp(connection,
TEST_SCRATCH_DIR,
TEST_IFCFG_DIR "/ifcfg-test_roundtrip_ethtool-8.cexpected",
@ -3633,11 +3631,6 @@ test_roundtrip_ethtool(void)
nmtst_get_rand_bool() ? g_variant_new_boolean(FALSE) : NULL);
}
if (!nm_setting_option_get_all_names(s_ethtool, NULL)) {
// FIXME.
continue;
}
check_roundtrip:
_writer_new_connection_reread(con2,
TEST_SCRATCH_DIR,