ifcfg-rh: fix persisting all-default NMSettingEthtool settings
We somehow need to encode an NMSettingEthtool instance that has all options unset. Previously, that would result in no "$ETHTOOL_OPTS" variable and thus the reader would loose a previously existing setting. Hack it by writing a bogus ETHTOOL_OPTS="-A $IFACE" line.
This commit is contained in:
@@ -1376,6 +1376,13 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error
|
||||
g_string_append(str, nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id));
|
||||
g_string_append(str, b ? " on" : " off");
|
||||
}
|
||||
|
||||
if (!str) {
|
||||
/* 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. */
|
||||
_ethtool_gstring_prepare(&str, &is_first, 'A', iface);
|
||||
}
|
||||
}
|
||||
|
||||
if (str) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
TYPE=Ethernet
|
||||
PROXY_METHOD=none
|
||||
BROWSER_ONLY=no
|
||||
ETHTOOL_OPTS="-A net0"
|
||||
BOOTPROTO=dhcp
|
||||
DEFROUTE=yes
|
||||
IPV4_FAILURE_FATAL=no
|
||||
|
@@ -3969,7 +3969,8 @@ test_roundtrip_ethtool(void)
|
||||
NULL,
|
||||
NM_SETTING_WIRED_SETTING_NAME,
|
||||
NULL);
|
||||
/* TODO: add empty NMSettingEthtool, which currently would break the test. */
|
||||
s_ethtool = nm_setting_ethtool_new();
|
||||
nm_connection_add_setting(connection, s_ethtool);
|
||||
_writer_new_connec_exp(connection,
|
||||
TEST_SCRATCH_DIR,
|
||||
TEST_IFCFG_DIR "/ifcfg-test_roundtrip_ethtool-2.cexpected",
|
||||
|
Reference in New Issue
Block a user