summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-08-26 17:33:22 +0200
committerThomas Haller <thaller@redhat.com>2021-08-26 23:05:18 +0200
commite3924a3ab6fa0e0d9d1369ce9a4d4d8a7c31e6bd (patch)
treea7a530f31b730d13b88790fae16f52660ff4fd63 /src
parentf15498eda31bb5f229c56cc668fe484c1ef37d3a (diff)
downloadNetworkManager-e3924a3ab6fa0e0d9d1369ce9a4d4d8a7c31e6bd.tar.gz
ifcfg-rh: refactor write_bond_port_setting() and always write queue-id
- the writer/reader should be lossless. There is a difference on whether a NMConnection has/hasn't a NMSettingBondPort instance. If we thus have a NMSettingBondPort, we must always encode that in the ifcfg file, by writing BOND_PORT_QUEUE_ID=0. Otherwise, the reader will not create the setting. - it's really not the task of the writer to validate what it writes. All these write_bridge_port_setting() really should not fail. They should serialize the setting as good as they can. And if they cannot, it's probably a bug in the writer (by not being lossless). write_bond_port_setting() did not ever fail. It should not ever fail. So don't let the function return a potential failure, and don't handle a failure that should never happen.
Diffstat (limited to 'src')
-rw-r--r--src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c23
1 files changed, 6 insertions, 17 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 9c5676f872..b648d5be6a 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
@@ -1889,24 +1889,14 @@ write_bridge_port_setting(NMConnection *connection, shvarFile *ifcfg, GError **e
return TRUE;
}
-static gboolean
-write_bond_port_setting(NMConnection *connection, shvarFile *ifcfg, GError **error)
+static void
+write_bond_port_setting(NMConnection *connection, shvarFile *ifcfg)
{
- NMSettingBondPort *s_port = NULL;
- guint16 queue_id = NM_BOND_PORT_QUEUE_ID_DEF;
+ NMSettingBondPort *s_port;
s_port = _nm_connection_get_setting_bond_port(connection);
- if (!s_port)
- return TRUE;
-
- queue_id = nm_setting_bond_port_get_queue_id(s_port);
- if (queue_id
- != get_setting_default_checked_uint(NM_BOND_PORT_QUEUE_ID_DEF,
- s_port,
- NM_SETTING_BOND_PORT_QUEUE_ID))
- svSetValueInt64(ifcfg, "BOND_PORT_QUEUE_ID", queue_id);
-
- return TRUE;
+ if (s_port)
+ svSetValueInt64(ifcfg, "BOND_PORT_QUEUE_ID", nm_setting_bond_port_get_queue_id(s_port));
}
static gboolean
@@ -3391,8 +3381,7 @@ do_write_construct(NMConnection * connection,
if (!write_bridge_port_setting(connection, ifcfg, error))
return FALSE;
- if (!write_bond_port_setting(connection, ifcfg, error))
- return FALSE;
+ write_bond_port_setting(connection, ifcfg);
if (!write_team_port_setting(connection, ifcfg, error))
return FALSE;