summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2016-08-01 18:48:15 +0200
committerThomas Haller <thaller@redhat.com>2016-08-24 10:59:39 +0200
commit5f1662066dcf5143b9065ebb56704a061ca2ffd9 (patch)
treefab2a6e5b2fdf7a1a7d4cc798829a455a3615177
parent9382fb0213e18349f335d2f9d714d9e46a446e83 (diff)
downloadNetworkManager-5f1662066dcf5143b9065ebb56704a061ca2ffd9.tar.gz
libnm-core/team: treat "" team config as no config
https://bugzilla.redhat.com/show_bug.cgi?id=1366300 (cherry picked from commit 0fc8b856c37374daaf3ec4d95e25e2e670d8d3f5)
-rw-r--r--libnm-core/nm-connection.c34
-rw-r--r--libnm-core/nm-setting-team-port.c22
-rw-r--r--libnm-core/nm-setting-team.c3
3 files changed, 48 insertions, 11 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index 2fd3401c0c..57f964095e 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -907,6 +907,38 @@ _normalize_wireless_mac_address_randomization (NMConnection *self, GHashTable *p
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:
* @connection: the #NMConnection to verify
@@ -1150,6 +1182,8 @@ nm_connection_normalize (NMConnection *connection,
was_modified |= _normalize_infiniband_mtu (connection, parameters);
was_modified |= _normalize_bond_mode (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. */
success = _nm_connection_verify (connection, error);
diff --git a/libnm-core/nm-setting-team-port.c b/libnm-core/nm-setting-team-port.c
index 8d570c9e1c..123304fee6 100644
--- a/libnm-core/nm-setting-team-port.c
+++ b/libnm-core/nm-setting-team-port.c
@@ -87,16 +87,6 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
{
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) {
NMSettingConnection *s_con;
const char *slave_type;
@@ -125,6 +115,18 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
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;
}
diff --git a/libnm-core/nm-setting-team.c b/libnm-core/nm-setting-team.c
index 36cd312b6e..df89694f66 100644
--- a/libnm-core/nm-setting-team.c
+++ b/libnm-core/nm-setting-team.c
@@ -94,7 +94,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
"%s.%s: ",
NM_SETTING_TEAM_SETTING_NAME,
NM_SETTING_TEAM_CONFIG);
- return FALSE;
+ /* We treat an empty string as no config for compatibility. */
+ return *priv->config ? FALSE : NM_SETTING_VERIFY_NORMALIZABLE;
}
}