Commit 4f166d71 authored by Thomas Graf's avatar Thomas Graf Committed by Dan Williams
Browse files

bonding: convert individual bonding options to a dict



Removes all bonding options properties and adds a "options" dict to hold
them all. Accessible via accessor functions. ifcfg interface is
unchanged.
Signed-off-by: default avatarThomas Graf <tgraf@redhat.com>
parent 5a3e1cae
......@@ -176,17 +176,16 @@ global:
nm_setting_bluetooth_get_connection_type;
nm_setting_bluetooth_get_type;
nm_setting_bluetooth_new;
nm_setting_bond_add_option;
nm_setting_bond_error_get_type;
nm_setting_bond_error_quark;
nm_setting_bond_get_arp_interval;
nm_setting_bond_get_arp_ip_target;
nm_setting_bond_get_downdelay;
nm_setting_bond_get_interface_name;
nm_setting_bond_get_miimon;
nm_setting_bond_get_mode;
nm_setting_bond_get_num_options;
nm_setting_bond_get_option;
nm_setting_bond_get_option_by_name;
nm_setting_bond_get_type;
nm_setting_bond_get_updelay;
nm_setting_bond_new;
nm_setting_bond_remove_option;
nm_setting_cdma_error_get_type;
nm_setting_cdma_error_quark;
nm_setting_cdma_get_number;
......
This diff is collapsed.
......@@ -54,12 +54,15 @@ typedef enum {
GQuark nm_setting_bond_error_quark (void);
#define NM_SETTING_BOND_INTERFACE_NAME "interface-name"
#define NM_SETTING_BOND_MODE "mode"
#define NM_SETTING_BOND_MIIMON "miimon"
#define NM_SETTING_BOND_DOWNDELAY "down-delay"
#define NM_SETTING_BOND_UPDELAY "up-delay"
#define NM_SETTING_BOND_ARP_INTERVAL "arp-interval"
#define NM_SETTING_BOND_ARP_IP_TARGET "arp-ip-target"
#define NM_SETTING_BOND_OPTIONS "options"
/* Valid options for the 'options' property */
#define NM_SETTING_BOND_OPTION_MODE "mode"
#define NM_SETTING_BOND_OPTION_MIIMON "miimon"
#define NM_SETTING_BOND_OPTION_DOWNDELAY "downdelay"
#define NM_SETTING_BOND_OPTION_UPDELAY "updelay"
#define NM_SETTING_BOND_OPTION_ARP_INTERVAL "arp_interval"
#define NM_SETTING_BOND_OPTION_ARP_IP_TARGET "arp_ip_target"
typedef struct {
NMSetting parent;
......@@ -79,12 +82,18 @@ GType nm_setting_bond_get_type (void);
NMSetting * nm_setting_bond_new (void);
const char * nm_setting_bond_get_interface_name (NMSettingBond *setting);
const char * nm_setting_bond_get_mode (NMSettingBond *setting);
guint32 nm_setting_bond_get_miimon (NMSettingBond *setting);
guint32 nm_setting_bond_get_downdelay (NMSettingBond *setting);
guint32 nm_setting_bond_get_updelay (NMSettingBond *setting);
guint32 nm_setting_bond_get_arp_interval (NMSettingBond *setting);
const char * nm_setting_bond_get_arp_ip_target (NMSettingBond *setting);
guint32 nm_setting_bond_get_num_options (NMSettingBond *setting);
gboolean nm_setting_bond_get_option (NMSettingBond *setting,
guint32 idx,
const char **out_name,
const char **out_value);
const char * nm_setting_bond_get_option_by_name (NMSettingBond *setting,
const char *name);
gboolean nm_setting_bond_add_option (NMSettingBond *setting,
const char *name,
const char *item);
gboolean nm_setting_bond_remove_option (NMSettingBond *setting,
const char *name);
G_END_DECLS
......
......@@ -1238,28 +1238,15 @@ set_bond_attr (const char *iface, const char *attr, const char *value)
return ret;
}
static gboolean
set_bond_attr_int (const char *iface, const char *attr,
guint32 value)
{
char buf[128];
snprintf (buf, sizeof(buf), "%u", value);
return set_bond_attr (iface, attr, buf);
}
gboolean
nm_system_apply_bonding_config (NMSettingBond *s_bond)
{
const char *name, *val;
const char *name;
guint32 i;
name = nm_setting_bond_get_interface_name (s_bond);
g_assert (name);
if ((val = nm_setting_bond_get_mode (s_bond)))
set_bond_attr (name, "mode", val);
/*
* FIXME:
*
......@@ -1278,13 +1265,15 @@ nm_system_apply_bonding_config (NMSettingBond *s_bond)
* Not sure if this is actually being used and it seems dangerous as
* the result is pretty much unforeseeable.
*/
if ((val = nm_setting_bond_get_arp_ip_target (s_bond)))
set_bond_attr (name, "arp_ip_target", val);
set_bond_attr_int (name, "miimon", nm_setting_bond_get_miimon (s_bond));
set_bond_attr_int (name, "downdelay", nm_setting_bond_get_downdelay (s_bond));
set_bond_attr_int (name, "updelay", nm_setting_bond_get_updelay (s_bond));
set_bond_attr_int (name, "arp_interval", nm_setting_bond_get_arp_interval (s_bond));
for (i = 0; i < nm_setting_bond_get_num_options (s_bond); i++) {
const char *key, *value;
if (!nm_setting_bond_get_option (s_bond, i, &key, &value))
continue;
set_bond_attr (name, key, value);
}
return TRUE;
}
......
......@@ -3566,19 +3566,7 @@ handle_bond_option (NMSettingBond *s_bond,
const char *key,
const char *value)
{
if (!g_strcmp0 (key, "mode"))
g_object_set (s_bond, NM_SETTING_BOND_MODE, value, NULL);
else if (!g_strcmp0 (key, "miimon"))
g_object_set (s_bond, NM_SETTING_BOND_MIIMON, strtoul(value, NULL, 0), NULL);
else if (!g_strcmp0 (key, "updelay"))
g_object_set (s_bond, NM_SETTING_BOND_UPDELAY, strtoul(value, NULL, 0), NULL);
else if (!g_strcmp0 (key, "downdelay"))
g_object_set (s_bond, NM_SETTING_BOND_DOWNDELAY, strtoul(value, NULL, 0), NULL);
else if (!g_strcmp0 (key, "arp_interval"))
g_object_set (s_bond, NM_SETTING_BOND_ARP_INTERVAL, strtoul(value, NULL, 0), NULL);
else if (!g_strcmp0 (key, "arp_ip_target"))
g_object_set (s_bond, NM_SETTING_BOND_ARP_IP_TARGET, value, NULL);
else
if (!nm_setting_bond_add_option (s_bond, key, value))
PLUGIN_WARN (IFCFG_PLUGIN_NAME, " warning: invalid bonding option '%s'", key);
}
......
......@@ -11817,9 +11817,9 @@ test_read_bond_main (void)
"bond-main", "failed to verify %s: DEVICE=%s does not match bond0",
TEST_IFCFG_BOND_MAIN, nm_setting_bond_get_interface_name (s_bond));
ASSERT (nm_setting_bond_get_miimon (s_bond) == 100,
"bond-main", "failed to verify %s: miimon=%d does not match 100",
TEST_IFCFG_BOND_MAIN, nm_setting_bond_get_miimon (s_bond));
ASSERT (g_strcmp0 (nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MIIMON), "100") == 0,
"bond-main", "failed to verify %s: miimon=%s does not match 100",
TEST_IFCFG_BOND_MAIN, nm_setting_bond_get_option_by_name (s_bond, NM_SETTING_BOND_OPTION_MIIMON));
g_free (unmanaged);
g_free (keyfile);
......@@ -11867,7 +11867,7 @@ test_read_bond_slave (void)
"bond-slave-read", "failed to verify %s: master is not bond0",
TEST_IFCFG_BOND_SLAVE);
ASSERT (g_strcmp0 (nm_setting_connection_get_slave_type (s_con), "bond") == 0,
ASSERT (g_strcmp0 (nm_setting_connection_get_slave_type (s_con), NM_SETTING_BOND_SETTING_NAME) == 0,
"bond-slave-read", "failed to verify %s: slave-type is not bond",
TEST_IFCFG_BOND_SLAVE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment