summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2016-03-16 10:20:45 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2016-03-18 22:31:24 +0100
commitb469a5cc736bf2263979699a41dcad9539d51d72 (patch)
treef18ee5e581f98a9f13bdf935059ec4d15e094e07
parentb82e61e0af883e3f2aeb04e51fdaa51d24cea808 (diff)
downloadNetworkManager-b469a5cc736bf2263979699a41dcad9539d51d72.tar.gz
cli: allow setting multiple IPs in bond 'arp_ip_target' option
The bond 'arp_ip_target' option contains a list of comma-separated IP addresses; but comma is also used to separate options and so at the moment it is not possible to specify multiple IPs as the command $ nmcli c m b1 bond.options \ mode=0,arp_interval=1,arp_ip_target=1.1.1.1,2.2.2.2 interprets 2.2.2.2 as the next option. Allows spaces to be used as separators for the IPs of the 'arp_ip_target': $ nmcli c m b1 bond.options \ "mode=0,arp_interval=1,arp_ip_target=1.1.1.1 2.2.2.2"
-rw-r--r--clients/cli/settings.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index 3fb841a154..06e9fb4722 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -1150,8 +1150,19 @@ nmc_property_bond_get_options (NMSetting *setting, NmcPropertyGetType get_type)
bond_options_s = g_string_new (NULL);
for (i = 0; i < nm_setting_bond_get_num_options (s_bond); i++) {
const char *key, *value;
+ gs_free char *tmp_value = NULL;
+ char *p;
nm_setting_bond_get_option (s_bond, i, &key, &value);
+
+ if (nm_streq0 (key, NM_SETTING_BOND_OPTION_ARP_IP_TARGET)) {
+ value = tmp_value = g_strdup (value);
+ for (p = tmp_value; p && *p; p++) {
+ if (*p == ',')
+ *p = ' ';
+ }
+ }
+
g_string_append_printf (bond_options_s, "%s=%s,", key, value);
}
g_string_truncate (bond_options_s, bond_options_s->len-1); /* chop off trailing ',' */
@@ -3651,10 +3662,28 @@ _validate_bond_option_value (const char *option, const char *value, GError **err
return value;
}
+static gboolean
+_bond_add_option (NMSettingBond *setting,
+ const char *name,
+ const char *value)
+{
+ gs_free char *tmp_value = NULL;
+ char *p;
+
+ if (nm_streq0 (name, NM_SETTING_BOND_OPTION_ARP_IP_TARGET)) {
+ value = tmp_value = g_strdup (value);
+ for (p = tmp_value; p && *p; p++)
+ if (*p == ' ')
+ *p = ',';
+ }
+
+ return nm_setting_bond_add_option (setting, name, value);
+}
+
DEFINE_SETTER_OPTIONS (nmc_property_bond_set_options,
NM_SETTING_BOND,
NMSettingBond,
- nm_setting_bond_add_option,
+ _bond_add_option,
nm_setting_bond_get_valid_options,
_validate_bond_option_value)
DEFINE_REMOVER_OPTION (nmc_property_bond_remove_option_options,