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: 652ddca04c ('ethtool: Introducing PAUSE support')
This commit is contained in:
Thomas Haller 2022-11-08 21:47:18 +01:00
parent 3755e6b175
commit 21661c6f71
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
3 changed files with 4 additions and 4 deletions

View file

@ -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));

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 ; -G net0 rx 512 ; -A net0 pause-autoneg off"
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no

View file

@ -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;