diff options
author | Thomas Graf <tgraf@redhat.com> | 2011-10-18 13:48:42 +0200 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2011-11-09 23:16:31 -0600 |
commit | a2a0d788182b20b23abc6b33ba1e344084b00b11 (patch) | |
tree | 497846a66befefdf45bfd6299a9fc3f7e3e60e9e /libnm-util | |
parent | d0b71957e788ad820e555f52f99e5ac836e237f8 (diff) | |
download | NetworkManager-a2a0d788182b20b23abc6b33ba1e344084b00b11.tar.gz |
bonding: settings parser for ifcfg plugin + NMSettingBond class
Introduced a new TYPE=bond for ifcfg-rh configuration files.
Alternatively BONDING_MASTER=yes can be specified instead of
setting the type explicitely to maintain backwards compatibility
with existing configuration files.
Bonding device files require a DEVICE= line to be present which
specifies the virtual bonding interface in the kernel. We do not
allow auto-generation of the name in order to keep confusion to
a minimum when reusing existing bonding interfaces.
The BONDING_OPTS= parameter can be used to specify various bonding
related options, such as:
- mode
- miimon
- updelay
- downdelay
- arp_interval
- arp_ip_target
By default, the NMSettingBond class uses a miimon value of 100 which
seems like a sensible default value for 99% of all configurations.
If this is not suitable, an arp_ip_target needs to be specified
manually.
A writer is not yet implemented.
Changes v2:
- renamed DeviceName property to InterfaceName
- moved code to validate device name to dev_valid_name() for future use
Signed-off-by: Thomas Graf <tgraf@redhat.com>
Diffstat (limited to 'libnm-util')
-rw-r--r-- | libnm-util/Makefile.am | 2 | ||||
-rw-r--r-- | libnm-util/libnm-util.ver | 12 | ||||
-rw-r--r-- | libnm-util/nm-connection.c | 25 | ||||
-rw-r--r-- | libnm-util/nm-connection.h | 2 | ||||
-rw-r--r-- | libnm-util/nm-setting-bond.c | 563 | ||||
-rw-r--r-- | libnm-util/nm-setting-bond.h | 94 |
6 files changed, 697 insertions, 1 deletions
diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am index 1327565ae3..627c3e3492 100644 --- a/libnm-util/Makefile.am +++ b/libnm-util/Makefile.am @@ -15,6 +15,7 @@ libnm_util_include_HEADERS = \ nm-setting.h \ nm-setting-8021x.h \ nm-setting-bluetooth.h \ + nm-setting-bond.h \ nm-setting-connection.h \ nm-setting-ip4-config.h \ nm-setting-ip6-config.h \ @@ -44,6 +45,7 @@ libnm_util_la_csources = \ nm-setting.c \ nm-setting-8021x.c \ nm-setting-bluetooth.c \ + nm-setting-bond.c \ nm-setting-connection.c \ nm-setting-ip4-config.c \ nm-setting-ip6-config.c \ diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver index 2c4b927847..1a400cb5d6 100644 --- a/libnm-util/libnm-util.ver +++ b/libnm-util/libnm-util.ver @@ -16,6 +16,7 @@ global: nm_connection_get_setting; nm_connection_get_setting_802_1x; nm_connection_get_setting_bluetooth; + nm_connection_get_setting_bond; nm_connection_get_setting_by_name; nm_connection_get_setting_cdma; nm_connection_get_setting_connection; @@ -167,6 +168,17 @@ global: nm_setting_bluetooth_get_connection_type; nm_setting_bluetooth_get_type; nm_setting_bluetooth_new; + nm_setting_bond_error_get_type; + nm_setting_bond_error_quark; + nm_setting_bond_new; + nm_setting_bond_get_type; + nm_setting_bond_get_interface_name; + nm_setting_bond_get_mode; + nm_setting_bond_get_miimon; + nm_setting_bond_get_downdelay; + nm_setting_bond_get_updelay; + nm_setting_bond_get_arp_interval; + nm_setting_bond_get_arp_ip_target; nm_setting_cdma_error_get_type; nm_setting_cdma_error_quark; nm_setting_cdma_get_number; diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index cdc3b81f01..de6e94879f 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -44,6 +44,7 @@ #include "nm-setting-wireless-security.h" #include "nm-setting-vpn.h" #include "nm-setting-olpc-mesh.h" +#include "nm-setting-bond.h" #include "nm-setting-serial.h" #include "nm-setting-gsm.h" @@ -135,7 +136,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; static GHashTable *registered_settings = NULL; -#define DEFAULT_MAP_SIZE 16 +#define DEFAULT_MAP_SIZE 17 static struct SettingInfo { const char *name; @@ -242,6 +243,11 @@ register_default_settings (void) NM_SETTING_WIMAX_ERROR, 1, TRUE); + register_one_setting (NM_SETTING_BOND_SETTING_NAME, + NM_TYPE_SETTING_BOND, + NM_SETTING_BOND_ERROR, + 1, TRUE); + register_one_setting (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_TYPE_SETTING_WIRELESS_SECURITY, NM_SETTING_WIRELESS_SECURITY_ERROR, @@ -1339,6 +1345,23 @@ nm_connection_get_setting_bluetooth (NMConnection *connection) } /** + * nm_connection_get_setting_bond: + * @connection: the #NMConnection + * + * A shortcut to return any #NMSettingBond the connection might contain. + * + * Returns: (transfer none): an #NMSettingBond if the connection contains one, otherwise NULL + **/ +NMSettingBond * +nm_connection_get_setting_bond (NMConnection *connection) +{ + g_return_val_if_fail (connection != NULL, NULL); + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + return (NMSettingBond *) nm_connection_get_setting (connection, NM_TYPE_SETTING_BOND); +} + +/** * nm_connection_get_setting_cdma: * @connection: the #NMConnection * diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h index 069dc84c16..60141384bb 100644 --- a/libnm-util/nm-connection.h +++ b/libnm-util/nm-connection.h @@ -32,6 +32,7 @@ #include <nm-setting-8021x.h> #include <nm-setting-bluetooth.h> +#include <nm-setting-bond.h> #include <nm-setting-cdma.h> #include <nm-setting-connection.h> #include <nm-setting-gsm.h> @@ -183,6 +184,7 @@ const char * nm_connection_get_id (NMConnection *connection); NMSetting8021x * nm_connection_get_setting_802_1x (NMConnection *connection); NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection); +NMSettingBond * nm_connection_get_setting_bond (NMConnection *connection); NMSettingCdma * nm_connection_get_setting_cdma (NMConnection *connection); NMSettingConnection * nm_connection_get_setting_connection (NMConnection *connection); NMSettingGsm * nm_connection_get_setting_gsm (NMConnection *connection); diff --git a/libnm-util/nm-setting-bond.c b/libnm-util/nm-setting-bond.c new file mode 100644 index 0000000000..582e1f9668 --- /dev/null +++ b/libnm-util/nm-setting-bond.c @@ -0,0 +1,563 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * Thomas Graf <tgraf@redhat.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2011 Red Hat, Inc. + */ + +#include <string.h> +#include <ctype.h> +#include <dbus/dbus-glib.h> + +#include "nm-setting-bond.h" +#include "nm-param-spec-specialized.h" +#include "nm-utils.h" +#include "nm-utils-private.h" +#include "nm-dbus-glib-types.h" + +/** + * SECTION:nm-setting-bond + * @short_description: Describes connection properties for bonds + * @include: nm-setting-bond.h + * + * The #NMSettingBond object is a #NMSetting subclass that describes properties + * necessary for bond connections. + **/ + +/** + * nm_setting_bond_error_quark: + * + * Registers an error quark for #NMSettingBond if necessary. + * + * Returns: the error quark used for #NMSettingBond errors. + **/ +GQuark +nm_setting_bond_error_quark (void) +{ + static GQuark quark; + + if (G_UNLIKELY (!quark)) + quark = g_quark_from_static_string ("nm-setting-bond-error-quark"); + return quark; +} + +/* This should really be standard. */ +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } + +GType +nm_setting_bond_error_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) { + static const GEnumValue values[] = { + /* Unknown error. */ + ENUM_ENTRY (NM_SETTING_BOND_ERROR_UNKNOWN, "UnknownError"), + /* The specified property was invalid. */ + ENUM_ENTRY (NM_SETTING_BOND_ERROR_INVALID_PROPERTY, "InvalidProperty"), + /* The specified property was missing and is required. */ + ENUM_ENTRY (NM_SETTING_BOND_ERROR_MISSING_PROPERTY, "MissingProperty"), + { 0, 0, 0 } + }; + + etype = g_enum_register_static ("NMSettingBondError", values); + } + + return etype; +} + + +G_DEFINE_TYPE (NMSettingBond, nm_setting_bond, NM_TYPE_SETTING) + +#define NM_SETTING_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BOND, NMSettingBondPrivate)) + +typedef struct { + char * interface_name; + char * mode; + guint32 miimon; + guint32 downdelay; + guint32 updelay; + guint32 arp_interval; + char * arp_ip_target; +} NMSettingBondPrivate; + +enum { + PROP_0, + PROP_INTERFACE_NAME, + PROP_MODE, + PROP_MIIMON, + PROP_DOWNDELAY, + PROP_UPDELAY, + PROP_ARP_INTERVAL, + PROP_ARP_IP_TARGET, + LAST_PROP +}; + +/** + * nm_setting_bond_new: + * + * Creates a new #NMSettingBond object with default values. + * + * Returns: (transfer full): the new empty #NMSettingBond object + **/ +NMSetting * +nm_setting_bond_new (void) +{ + return (NMSetting *) g_object_new (NM_TYPE_SETTING_BOND, NULL); +} + +/** + * nm_setting_bond_get_interface_name + * @setting: the #NMSettingBond + * + * Returns: the #NMSettingBond:interface-name property of the setting + **/ +const char * +nm_setting_bond_get_interface_name (NMSettingBond *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0); + + return NM_SETTING_BOND_GET_PRIVATE (setting)->interface_name; +} + +/** + * nm_setting_bond_get_mode: + * @setting: the #NMSettingBond + * + * Returns: the #NMSettingBond:mode property of the setting + **/ +const char * +nm_setting_bond_get_mode (NMSettingBond *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0); + + return NM_SETTING_BOND_GET_PRIVATE (setting)->mode; +} + +/** + * nm_setting_bond_get_miimon: + * @setting: the #NMSettingBond + * + * Returns: the #NMSettingBond:miimon property of the setting + **/ +guint32 +nm_setting_bond_get_miimon (NMSettingBond *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0); + + return NM_SETTING_BOND_GET_PRIVATE (setting)->miimon; +} + +/** + * nm_setting_bond_get_downdelay: + * @setting: the #NMSettingBond + * + * Returns: the #NMSettingBond:downdelay property of the setting + **/ +guint32 +nm_setting_bond_get_downdelay (NMSettingBond *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0); + + return NM_SETTING_BOND_GET_PRIVATE (setting)->downdelay; +} + +/** + * nm_setting_bond_get_updelay: + * @setting: the #NMSettingBond + * + * Returns: the #NMSettingBond:updelay property of the setting + **/ +guint32 +nm_setting_bond_get_updelay (NMSettingBond *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0); + + return NM_SETTING_BOND_GET_PRIVATE (setting)->updelay; +} + +/** + * nm_setting_bond_get_arp_interval: + * @setting: the #NMSettingBond + * + * Returns: the #NMSettingBond:arp_interval property of the setting + **/ +guint32 +nm_setting_bond_get_arp_interval (NMSettingBond *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0); + + return NM_SETTING_BOND_GET_PRIVATE (setting)->arp_interval; +} + +/** + * nm_setting_bond_get_arp_ip_target: + * @setting: the #NMSettingBond + * + * Returns: the #NMSettingBond:arp_ip_target property of the setting + **/ +const char * +nm_setting_bond_get_arp_ip_target (NMSettingBond *setting) +{ + g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0); + + return NM_SETTING_BOND_GET_PRIVATE (setting)->arp_ip_target; +} + +/* + * This function is a 1:1 copy of the kernel's + * dev_valid_name() in net/core/dev.c + */ +static gboolean +dev_valid_name(const char *name) +{ + if (*name == '\0') + return FALSE; + + if (strlen (name) >= 16) + return FALSE; + + if (!strcmp (name, ".") || !strcmp (name, "..")) + return FALSE; + + while (*name) { + if (*name == '/' || isspace (*name)) + return FALSE; + name++; + } + + return TRUE; +} + +static gboolean +verify (NMSetting *setting, GSList *all_settings, GError **error) +{ + NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting); + const char *valid_modes[] = { "balance-rr", + "active-backup", + "balance-xor", + "broadcast", + "802.3ad", + "balance-tlb", + "balance-alb", + NULL }; + + if (!priv->interface_name || !strlen(priv->interface_name)) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_MISSING_PROPERTY, + NM_SETTING_BOND_INTERFACE_NAME); + return FALSE; + } + + if (!dev_valid_name (priv->interface_name)) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_PROPERTY, + NM_SETTING_BOND_INTERFACE_NAME); + return FALSE; + } + + if (priv->mode && !_nm_utils_string_in_list (priv->mode, valid_modes)) { + g_set_error (error, + NM_SETTING_BOND_ERROR, + NM_SETTING_BOND_ERROR_INVALID_PROPERTY, + NM_SETTING_BOND_MODE); + return FALSE; + } + + /* XXX: Validate arp-ip-target */ + + return TRUE; +} + +static void +nm_setting_bond_init (NMSettingBond *setting) +{ + g_object_set (setting, NM_SETTING_NAME, NM_SETTING_BOND_SETTING_NAME, + NM_SETTING_BOND_MIIMON, 100, /* default: miimon=100 */ + NULL); +} + +static void +finalize (GObject *object) +{ + NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object); + + g_free (priv->interface_name); + g_free (priv->mode); + g_free (priv->arp_ip_target); + + G_OBJECT_CLASS (nm_setting_bond_parent_class)->finalize (object); +} + +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_INTERFACE_NAME: + priv->interface_name = g_value_dup_string (value); + break; + case PROP_MODE: + priv->mode = g_value_dup_string (value); + break; + case PROP_MIIMON: + priv->miimon = g_value_get_uint (value); + break; + case PROP_DOWNDELAY: + priv->downdelay = g_value_get_uint (value); + break; + case PROP_UPDELAY: + priv->updelay = g_value_get_uint (value); + break; + case PROP_ARP_INTERVAL: + priv->arp_interval = g_value_get_uint (value); + break; + case PROP_ARP_IP_TARGET: + g_free (priv->arp_ip_target); + priv->arp_ip_target = g_value_dup_string (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +get_property (GObject *object, guint prop_id, + GValue *value, GParamSpec *pspec) +{ + NMSettingBond *setting = NM_SETTING_BOND (object); + + switch (prop_id) { + case PROP_INTERFACE_NAME: + g_value_set_string (value, nm_setting_bond_get_interface_name (setting)); + break; + case PROP_MODE: + g_value_set_string (value, nm_setting_bond_get_mode (setting)); + break; + case PROP_MIIMON: + g_value_set_uint (value, nm_setting_bond_get_miimon (setting)); + break; + case PROP_DOWNDELAY: + g_value_set_uint (value, nm_setting_bond_get_downdelay (setting)); + break; + case PROP_UPDELAY: + g_value_set_uint (value, nm_setting_bond_get_updelay (setting)); + break; + case PROP_ARP_INTERVAL: + g_value_set_uint (value, nm_setting_bond_get_arp_interval (setting)); + break; + case PROP_ARP_IP_TARGET: + g_value_set_string (value, nm_setting_bond_get_arp_ip_target (setting)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +nm_setting_bond_class_init (NMSettingBondClass *setting_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (setting_class); + NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class); + + g_type_class_add_private (setting_class, sizeof (NMSettingBondPrivate)); + + /* virtual methods */ + object_class->set_property = set_property; + object_class->get_property = get_property; + object_class->finalize = finalize; + parent_class->verify = verify; + + /* Properties */ + /** + * NMSettingBond:interface-name: + * + * Name of virtual kernel interface + **/ + g_object_class_install_property + (object_class, PROP_INTERFACE_NAME, + g_param_spec_string (NM_SETTING_BOND_INTERFACE_NAME, + "InterfaceName", + "The name of the virtual in-kernel bonding nework interface", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingBond:mode: + * + * Bonding policy + **/ + g_object_class_install_property + (object_class, PROP_MODE, + g_param_spec_string (NM_SETTING_BOND_MODE, + "Mode", + "The bonding policy to use. One of 'balance-rr' (default), " + "'active-backup', 'balance-xor', 'broadcast', '802.3ad', " + "'balance-tlb', 'balance-alb'.", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingBond:miimon: + * + * Specifies the MII link monitoring frequency in milliseconds. + * This determines how often the link state of each slave is + * inspected for link failures. A value of zero disables MII + * link monitoring. A value of 100 is a good starting point. + * The use_carrier option, below, affects how the link state is + * determined. + **/ + g_object_class_install_property + (object_class, PROP_MIIMON, + g_param_spec_uint (NM_SETTING_BOND_MIIMON, + "MiiMon", + "Specifies the MII link monitoring frequency in milliseconds. " + "This determines how often the link state of each slave is " + "inspected for link failures. A value of zero disables MII " + "link monitoring. A value of 100 is a good starting point. " + "The use_carrier option, below, affects how the link state is " + "determined. The default value is 0.", + 0, G_MAXUINT32, 100, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingBond:downdelay: + * + * Specifies the time, in milliseconds, to wait before disabling + * a slave after a link failure has been detected. This option + * is only valid for the miimon link monitor. The downdelay + * value should be a multiple of the miimon value; if not, it + * will be rounded down to the nearest multiple. The default + * value is 0. + **/ + g_object_class_install_property + (object_class, PROP_DOWNDELAY, + g_param_spec_uint (NM_SETTING_BOND_DOWNDELAY, + "DownDelay", + "Specifies the time, in milliseconds, to wait before disabling " + "a slave after a link failure has been detected. This option " + "is only valid for the miimon link monitor. The downdelay " + "value should be a multiple of the miimon value; if not, it " + "will be rounded down to the nearest multiple. The default " + "value is 0.", + 0, G_MAXUINT32, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingBond:updelay: + * + * Specifies the time, in milliseconds, to wait before enabling a + * slave after a link recovery has been detected. This option is + * only valid for the miimon link monitor. The updelay value + * should be a multiple of the miimon value; if not, it will be + * rounded down to the nearest multiple. The default value is 0. + **/ + g_object_class_install_property + (object_class, PROP_UPDELAY, + g_param_spec_uint (NM_SETTING_BOND_UPDELAY, + "UpDelay", + "Specifies the time, in milliseconds, to wait before enabling a " + "slave after a link recovery has been detected. This option is " + "only valid for the miimon link monitor. The updelay value " + "should be a multiple of the miimon value; if not, it will be " + "rounded down to the nearest multiple. The default value is 0.", + 0, G_MAXUINT32, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingBond:arp_interval: + * + * Specifies the ARP link monitoring frequency in milliseconds. + * + * The ARP monitor works by periodically checking the slave + * devices to determine whether they have sent or received + * traffic recently (the precise criteria depends upon the + * bonding mode, and the state of the slave). Regular traffic is + * generated via ARP probes issued for the addresses specified by + * the arp-ip-target option. + * + * This behavior can be modified by the arp-validate option. + * + * If ARP monitoring is used in an etherchannel compatible mode + * (modes 0 and 2), the switch should be configured in a mode + * that evenly distributes packets across all links. If the + * switch is configured to distribute the packets in an XOR + * fashion, all replies from the ARP targets will be received on + * the same link which could cause the other team members to + * fail. ARP monitoring should not be used in conjunction with + * miimon. A value of 0 disables ARP monitoring. The default + * value is 0. + **/ + g_object_class_install_property + (object_class, PROP_ARP_INTERVAL, + g_param_spec_uint (NM_SETTING_BOND_ARP_INTERVAL, + "ArpInterval", + "Specifies the ARP link monitoring frequency in milliseconds. " + "The ARP monitor works by periodically checking the slave " + "devices to determine whether they have sent or received " + "traffic recently (the precise criteria depends upon the " + "bonding mode, and the state of the slave). Regular traffic is " + "generated via ARP probes issued for the addresses specified by " + "the arp-ip-target option. " + "This behavior can be modified by the arp-validate option. " + "If ARP monitoring is used in an etherchannel compatible mode " + "(modes 0 and 2), the switch should be configured in a mode " + "that evenly distributes packets across all links. If the " + "switch is configured to distribute the packets in an XOR " + "fashion, all replies from the ARP targets will be received on " + "the same link which could cause the other team members to " + "fail. ARP monitoring should not be used in conjunction with " + "miimon. A value of 0 disables ARP monitoring. The default " + "value is 0.", + 0, G_MAXUINT32, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE)); + + /** + * NMSettingBond:arp_ip_target: + * + * Specifies the IP addresses to use as ARP monitoring peers when + * arp_interval is > 0. These are the targets of the ARP request + * sent to determine the health of the link to the targets. + * Specify these values in ddd.ddd.ddd.ddd format. Multiple IP + * addresses must be separated by a comma. At least one IP + * address must be given for ARP monitoring to function. The + * maximum number of targets that can be specified is 16. The + * default value is no IP addresses. + **/ + g_object_class_install_property + (object_class, PROP_ARP_IP_TARGET, + g_param_spec_string (NM_SETTING_BOND_ARP_IP_TARGET, + "ArpIpTarget", + "Specifies the IP addresses to use as ARP monitoring peers when " + "arp-interval is > 0. These are the targets of the ARP request " + "sent to determine the health of the link to the targets. " + "Specify these values in ddd.ddd.ddd.ddd format. Multiple IP " + "addresses must be separated by a comma. At least one IP " + "address must be given for ARP monitoring to function. The " + "maximum number of targets that can be specified is 16. The " + "default value is no IP addresses.", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); +} diff --git a/libnm-util/nm-setting-bond.h b/libnm-util/nm-setting-bond.h new file mode 100644 index 0000000000..6ef699240d --- /dev/null +++ b/libnm-util/nm-setting-bond.h @@ -0,0 +1,94 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* + * Thomas Graf <tgraf@redhat.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * (C) Copyright 2011 Red Hat, Inc. + */ + +#ifndef NM_SETTING_BOND_H +#define NM_SETTING_BOND_H + +#include <nm-setting.h> + +G_BEGIN_DECLS + +#define NM_TYPE_SETTING_BOND (nm_setting_bond_get_type ()) +#define NM_SETTING_BOND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_BOND, NMSettingBond)) +#define NM_SETTING_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_BOND, NMSettingBondClass)) +#define NM_IS_SETTING_BOND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_BOND)) +#define NM_IS_SETTING_BOND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_SETTING_BOND)) +#define NM_SETTING_BOND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_BOND, NMSettingBondClass)) + +#define NM_SETTING_BOND_SETTING_NAME "bond" + +/** + * NMSettingBondError: + * @NM_SETTING_BOND_ERROR_UNKNOWN: unknown or unclassified error + * @NM_SETTING_BOND_ERROR_INVALID_PROPERTY: the property was invalid + * @NM_SETTING_BOND_ERROR_MISSING_PROPERTY: the property was missing and is + * required + */ +typedef enum { + NM_SETTING_BOND_ERROR_UNKNOWN = 0, + NM_SETTING_BOND_ERROR_INVALID_PROPERTY, + NM_SETTING_BOND_ERROR_MISSING_PROPERTY, +} NMSettingBondError; + +#define NM_TYPE_SETTING_BOND_ERROR (nm_setting_bond_error_get_type ()) +GType nm_setting_bond_error_get_type (void); + +#define NM_SETTING_BOND_ERROR nm_setting_bond_error_quark () +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" + +typedef struct { + NMSetting parent; +} NMSettingBond; + +typedef struct { + NMSettingClass parent; + + /* Padding for future expansion */ + void (*_reserved1) (void); + void (*_reserved2) (void); + void (*_reserved3) (void); + void (*_reserved4) (void); +} NMSettingBondClass; + +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); + +G_END_DECLS + +#endif /* NM_SETTING_BOND_H */ |