diff options
| author | Michael Biebl <biebl@debian.org> | 2015-05-05 17:48:57 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2015-05-05 17:48:57 +0200 |
| commit | f408e27bccfacf347605a8d98649975a68f38a17 (patch) | |
| tree | 654fd6695c31511baf919b1c0870d119a352ed75 /libnm-core/nm-setting-bond.c | |
| parent | 2c032d8f1c6292c1338a615e6ec40252889ba85c (diff) | |
Imported Upstream version 1.0.2 upstream/1.0.2
Diffstat (limited to 'libnm-core/nm-setting-bond.c')
| -rw-r--r-- | libnm-core/nm-setting-bond.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index bb053125..5441a090 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -440,15 +440,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting); GHashTableIter iter; const char *key, *value; - const char *valid_modes[] = { "balance-rr", - "active-backup", - "balance-xor", - "broadcast", - "802.3ad", - "balance-tlb", - "balance-alb", - NULL }; - int miimon = 0, arp_interval = 0; + int mode, miimon = 0, arp_interval = 0; + const char *mode_orig, *mode_new; const char *arp_ip_target = NULL; const char *lacp_rate; const char *primary; @@ -484,7 +477,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); } - value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MODE); + /* Verify bond mode */ + mode_orig = value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MODE); if (!value) { g_set_error (error, NM_CONNECTION_ERROR, @@ -494,7 +488,8 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); return FALSE; } - if (!_nm_utils_string_in_list (value, valid_modes)) { + mode = nm_utils_bond_mode_string_to_int (value); + if (mode == -1) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -503,6 +498,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); return FALSE; } + mode_new = value = nm_utils_bond_mode_int_to_string (mode); /* Make sure mode is compatible with other settings */ if ( strcmp (value, "balance-alb") == 0 @@ -645,7 +641,22 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - return _nm_connection_verify_required_interface_name (connection, error); + if (!_nm_connection_verify_required_interface_name (connection, error)) + return FALSE; + + /* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */ + + if (g_strcmp0 (mode_orig, mode_new) != 0) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' option should be string"), + NM_SETTING_BOND_OPTION_MODE); + g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS); + return NM_SETTING_VERIFY_NORMALIZABLE; + } + + return TRUE; } static void |