From 21661c6f71b5f1bd76c3bbdcbe609f49f594d6e7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 8 Nov 2022 21:47:18 +0100 Subject: [PATCH] ifcfg-rh: fix persisting ethtool options If there were any pause options and any non-pause options, the created setting was invalid. I don't think it's reasonably possible to parse the broken settings. So there is no workaround trying to read the existing broken settings from disk. Luckily, the broken setting was just silently ignored by the parser, so you simply could not persist certain settings. https://bugzilla.redhat.com/show_bug.cgi?id=2134569 Fixes: 652ddca04c52 ('ethtool: Introducing PAUSE support') --- src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c | 2 ++ .../network-scripts/ifcfg-test_roundtrip_ethtool-9.cexpected | 2 +- src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c index d8c6a839f0..41fde901ac 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c @@ -1372,6 +1372,8 @@ 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_printf(str, " %" G_GUINT32_FORMAT, u32); } + + is_first = TRUE; for (ethtool_id = _NM_ETHTOOL_ID_PAUSE_FIRST; ethtool_id <= _NM_ETHTOOL_ID_PAUSE_LAST; ethtool_id++) { nm_assert(nms_ifcfg_rh_utils_get_ethtool_name(ethtool_id)); diff --git a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-9.cexpected b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-9.cexpected index 784ad22427..1703b0dc77 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-9.cexpected +++ b/src/core/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_roundtrip_ethtool-9.cexpected @@ -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 ; -G net0 rx 512 ; -A net0 pause-autoneg off" BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no diff --git a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 4b13970801..71ea6a33e4 100644 --- a/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/src/core/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -3557,7 +3557,7 @@ test_roundtrip_ethtool(void) s_ethtool = _nm_connection_new_setting(connection, NM_TYPE_SETTING_ETHTOOL); nm_setting_option_set_boolean(s_ethtool, NM_ETHTOOL_OPTNAME_PAUSE_AUTONEG, FALSE); - //FIXME: nm_setting_option_set_uint32(s_ethtool, NM_ETHTOOL_OPTNAME_RING_RX, 512); + nm_setting_option_set_uint32(s_ethtool, NM_ETHTOOL_OPTNAME_RING_RX, 512); _writer_new_connec_exp(connection, TEST_SCRATCH_DIR, TEST_IFCFG_DIR "/ifcfg-test_roundtrip_ethtool-9.cexpected", @@ -3616,8 +3616,6 @@ test_roundtrip_ethtool(void) ethtool_ids[i] = i; nmtst_rand_perm(NULL, ethtool_ids, NULL, sizeof(ethtool_ids[0]), G_N_ELEMENTS(ethtool_ids)); - l = 1; /* FIXME */ - for (i = 0; i < l; i++) { NMEthtoolID ethtool_id = ethtool_ids[i]; const GVariantType *vtype;