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.
This commit is contained in:
Thomas Haller 2021-08-26 17:33:22 +02:00
parent f15498eda3
commit e3924a3ab6
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

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