mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 11:19:16 +02:00
libnm-core/team: treat "" team config as no config
https://bugzilla.redhat.com/show_bug.cgi?id=1366300
This commit is contained in:
parent
4f6fd1bf0e
commit
0fc8b856c3
3 changed files with 48 additions and 11 deletions
|
|
@ -907,6 +907,38 @@ _normalize_wireless_mac_address_randomization (NMConnection *self, GHashTable *p
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_normalize_team_config (NMConnection *self, GHashTable *parameters)
|
||||||
|
{
|
||||||
|
NMSettingTeam *s_team = nm_connection_get_setting_team (self);
|
||||||
|
|
||||||
|
if (s_team) {
|
||||||
|
const char *config = nm_setting_team_get_config (s_team);
|
||||||
|
|
||||||
|
if (config && !*config) {
|
||||||
|
g_object_set (s_team, NM_SETTING_TEAM_CONFIG, NULL, NULL);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_normalize_team_port_config (NMConnection *self, GHashTable *parameters)
|
||||||
|
{
|
||||||
|
NMSettingTeamPort *s_team_port = nm_connection_get_setting_team_port (self);
|
||||||
|
|
||||||
|
if (s_team_port) {
|
||||||
|
const char *config = nm_setting_team_port_get_config (s_team_port);
|
||||||
|
|
||||||
|
if (config && !*config) {
|
||||||
|
g_object_set (s_team_port, NM_SETTING_TEAM_PORT_CONFIG, NULL, NULL);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nm_connection_verify:
|
* nm_connection_verify:
|
||||||
* @connection: the #NMConnection to verify
|
* @connection: the #NMConnection to verify
|
||||||
|
|
@ -1150,6 +1182,8 @@ nm_connection_normalize (NMConnection *connection,
|
||||||
was_modified |= _normalize_infiniband_mtu (connection, parameters);
|
was_modified |= _normalize_infiniband_mtu (connection, parameters);
|
||||||
was_modified |= _normalize_bond_mode (connection, parameters);
|
was_modified |= _normalize_bond_mode (connection, parameters);
|
||||||
was_modified |= _normalize_wireless_mac_address_randomization (connection, parameters);
|
was_modified |= _normalize_wireless_mac_address_randomization (connection, parameters);
|
||||||
|
was_modified |= _normalize_team_config (connection, parameters);
|
||||||
|
was_modified |= _normalize_team_port_config (connection, parameters);
|
||||||
|
|
||||||
/* Verify anew. */
|
/* Verify anew. */
|
||||||
success = _nm_connection_verify (connection, error);
|
success = _nm_connection_verify (connection, error);
|
||||||
|
|
|
||||||
|
|
@ -87,16 +87,6 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||||
{
|
{
|
||||||
NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (setting);
|
NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (setting);
|
||||||
|
|
||||||
if (priv->config) {
|
|
||||||
if (!_nm_utils_check_valid_json (priv->config, error)) {
|
|
||||||
g_prefix_error (error,
|
|
||||||
"%s.%s: ",
|
|
||||||
NM_SETTING_TEAM_PORT_SETTING_NAME,
|
|
||||||
NM_SETTING_TEAM_PORT_CONFIG);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connection) {
|
if (connection) {
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
const char *slave_type;
|
const char *slave_type;
|
||||||
|
|
@ -125,6 +115,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (priv->config) {
|
||||||
|
if (!_nm_utils_check_valid_json (priv->config, error)) {
|
||||||
|
g_prefix_error (error,
|
||||||
|
"%s.%s: ",
|
||||||
|
NM_SETTING_TEAM_PORT_SETTING_NAME,
|
||||||
|
NM_SETTING_TEAM_PORT_CONFIG);
|
||||||
|
/* We treat an empty string as no config for compatibility. */
|
||||||
|
return *priv->config ? FALSE : NM_SETTING_VERIFY_NORMALIZABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
|
||||||
"%s.%s: ",
|
"%s.%s: ",
|
||||||
NM_SETTING_TEAM_SETTING_NAME,
|
NM_SETTING_TEAM_SETTING_NAME,
|
||||||
NM_SETTING_TEAM_CONFIG);
|
NM_SETTING_TEAM_CONFIG);
|
||||||
return FALSE;
|
/* We treat an empty string as no config for compatibility. */
|
||||||
|
return *priv->config ? FALSE : NM_SETTING_VERIFY_NORMALIZABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue