summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-08-23 00:48:50 +0200
committerJiří Klimeš <jklimes@redhat.com>2014-10-02 12:06:45 +0200
commitd5b951530da58b8fccd12ee2634dddf44e8c1742 (patch)
treec6a000e3dcd3eab9571277ee9566b14b00824885
parent1e4dd486984cb4fd2ddc81b39b57916c927a4899 (diff)
downloadNetworkManager-d5b951530da58b8fccd12ee2634dddf44e8c1742.tar.gz
libnm: add bonding option "lacp_rate" to NMSettingBond
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--libnm-core/nm-setting-bond.c16
-rw-r--r--libnm-core/nm-setting-bond.h1
-rw-r--r--libnm-util/nm-setting-bond.c16
-rw-r--r--libnm-util/nm-setting-bond.h1
-rw-r--r--src/devices/nm-device-bond.c1
5 files changed, 35 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c
index c7eb9b2db5..3725553e14 100644
--- a/libnm-core/nm-setting-bond.c
+++ b/libnm-core/nm-setting-bond.c
@@ -111,6 +111,8 @@ static const BondDefault defaults[] = {
{ NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, "0", TYPE_BOTH, 0, 2,
{ "layer2", "layer3+4", "layer2+3", NULL } },
{ NM_SETTING_BOND_OPTION_RESEND_IGMP, "1", TYPE_INT, 0, 255 },
+ { NM_SETTING_BOND_OPTION_LACP_RATE, "0", TYPE_BOTH, 0, 1,
+ { "slow", "fast", NULL } },
};
/**
@@ -462,6 +464,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NULL };
int miimon = 0, arp_interval = 0;
const char *arp_ip_target = NULL;
+ const char *lacp_rate;
const char *primary;
g_hash_table_iter_init (&iter, priv->options);
@@ -643,6 +646,19 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
}
}
+ lacp_rate = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_LACP_RATE);
+ if ( lacp_rate
+ && (g_strcmp0 (value, "802.3ad") != 0 && g_strcmp0 (value, "4") != 0)
+ && (strcmp (lacp_rate, "slow") != 0 && strcmp (lacp_rate, "0") != 0)) {
+ g_set_error (error,
+ NM_SETTING_BOND_ERROR,
+ NM_SETTING_BOND_ERROR_INVALID_OPTION,
+ _("'%s' option is only valid with mode '%s'"),
+ NM_SETTING_BOND_OPTION_LACP_RATE, "802.3ad");
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
+ return FALSE;
+ }
+
return _nm_setting_verify_required_virtual_interface_name (all_settings, error);
}
diff --git a/libnm-core/nm-setting-bond.h b/libnm-core/nm-setting-bond.h
index c3cee4d550..18f5e105f6 100644
--- a/libnm-core/nm-setting-bond.h
+++ b/libnm-core/nm-setting-bond.h
@@ -74,6 +74,7 @@ GQuark nm_setting_bond_error_quark (void);
#define NM_SETTING_BOND_OPTION_AD_SELECT "ad_select"
#define NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY "xmit_hash_policy"
#define NM_SETTING_BOND_OPTION_RESEND_IGMP "resend_igmp"
+#define NM_SETTING_BOND_OPTION_LACP_RATE "lacp_rate"
typedef struct {
NMSetting parent;
diff --git a/libnm-util/nm-setting-bond.c b/libnm-util/nm-setting-bond.c
index f321d0af2f..7d82d31d23 100644
--- a/libnm-util/nm-setting-bond.c
+++ b/libnm-util/nm-setting-bond.c
@@ -120,6 +120,8 @@ static const BondDefault defaults[] = {
{ NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, "0", TYPE_BOTH, 0, 2,
{ "layer2", "layer3+4", "layer2+3", NULL } },
{ NM_SETTING_BOND_OPTION_RESEND_IGMP, "1", TYPE_INT, 0, 255 },
+ { NM_SETTING_BOND_OPTION_LACP_RATE, "0", TYPE_BOTH, 0, 1,
+ { "slow", "fast", NULL } },
};
/**
@@ -487,6 +489,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
NULL };
int miimon = 0, arp_interval = 0;
const char *arp_ip_target = NULL;
+ const char *lacp_rate;
const char *primary;
g_hash_table_iter_init (&iter, priv->options);
@@ -668,6 +671,19 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
}
}
+ lacp_rate = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_LACP_RATE);
+ if ( lacp_rate
+ && (g_strcmp0 (value, "802.3ad") != 0 && g_strcmp0 (value, "4") != 0)
+ && (strcmp (lacp_rate, "slow") != 0 && strcmp (lacp_rate, "0") != 0)) {
+ g_set_error (error,
+ NM_SETTING_BOND_ERROR,
+ NM_SETTING_BOND_ERROR_INVALID_OPTION,
+ _("'%s' option is only valid with mode '%s'"),
+ NM_SETTING_BOND_OPTION_LACP_RATE, "802.3ad");
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
+ return FALSE;
+ }
+
return _nm_setting_verify_deprecated_virtual_iface_name (
priv->interface_name, FALSE,
NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_INTERFACE_NAME,
diff --git a/libnm-util/nm-setting-bond.h b/libnm-util/nm-setting-bond.h
index e7807380bf..cf969995ec 100644
--- a/libnm-util/nm-setting-bond.h
+++ b/libnm-util/nm-setting-bond.h
@@ -71,6 +71,7 @@ GQuark nm_setting_bond_error_quark (void);
#define NM_SETTING_BOND_OPTION_AD_SELECT "ad_select"
#define NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY "xmit_hash_policy"
#define NM_SETTING_BOND_OPTION_RESEND_IGMP "resend_igmp"
+#define NM_SETTING_BOND_OPTION_LACP_RATE "lacp_rate"
typedef struct {
NMSetting parent;
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c
index 40151d4722..e365ee6d66 100644
--- a/src/devices/nm-device-bond.c
+++ b/src/devices/nm-device-bond.c
@@ -360,6 +360,7 @@ apply_bonding_config (NMDevice *device)
set_simple_option (device, "ad_select", s_bond, NM_SETTING_BOND_OPTION_AD_SELECT);
set_simple_option (device, "xmit_hash_policy", s_bond, NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY);
set_simple_option (device, "resend_igmp", s_bond, NM_SETTING_BOND_OPTION_RESEND_IGMP);
+ set_simple_option (device, "lacp_rate", s_bond, NM_SETTING_BOND_OPTION_LACP_RATE);
return NM_ACT_STAGE_RETURN_SUCCESS;
}