1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA.
19 * Copyright 2011 - 2013 Red Hat, Inc.
22 #include "nm-default.h"
27 #include <netinet/in.h>
28 #include <arpa/inet.h>
30 #include "nm-setting-bond.h"
32 #include "nm-utils-private.h"
33 #include "nm-connection-private.h"
34 #include "nm-setting-infiniband.h"
35 #include "nm-core-internal.h"
38 * SECTION:nm-setting-bond
39 * @short_description: Describes connection properties for bonds
41 * The #NMSettingBond object is a #NMSetting subclass that describes properties
42 * necessary for bond connections.
45 G_DEFINE_TYPE_WITH_CODE (NMSettingBond, nm_setting_bond, NM_TYPE_SETTING,
46 _nm_register_setting (BOND, 1))
47 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BOND)
49 #define NM_SETTING_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BOND, NMSettingBondPrivate))
53 } NMSettingBondPrivate;
70 static const BondDefault defaults[] = {
71 { NM_SETTING_BOND_OPTION_MODE, "balance-rr", NM_BOND_OPTION_TYPE_BOTH, 0, 6,
72 { "balance-rr", "active-backup", "balance-xor", "broadcast", "802.3ad", "balance-tlb", "balance-alb", NULL } },
73 { NM_SETTING_BOND_OPTION_MIIMON, "100", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT },
74 { NM_SETTING_BOND_OPTION_DOWNDELAY, "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT },
75 { NM_SETTING_BOND_OPTION_UPDELAY, "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT },
76 { NM_SETTING_BOND_OPTION_ARP_INTERVAL, "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT },
77 { NM_SETTING_BOND_OPTION_ARP_IP_TARGET, "", NM_BOND_OPTION_TYPE_IP },
78 { NM_SETTING_BOND_OPTION_ARP_VALIDATE, "none", NM_BOND_OPTION_TYPE_BOTH, 0, 3,
79 { "none", "active", "backup", "all", NULL } },
80 { NM_SETTING_BOND_OPTION_PRIMARY, "", NM_BOND_OPTION_TYPE_IFNAME },
81 { NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, "always", NM_BOND_OPTION_TYPE_BOTH, 0, 2,
82 { "always", "better", "failure", NULL } },
83 { NM_SETTING_BOND_OPTION_FAIL_OVER_MAC, "none", NM_BOND_OPTION_TYPE_BOTH, 0, 2,
84 { "none", "active", "follow", NULL } },
85 { NM_SETTING_BOND_OPTION_USE_CARRIER, "1", NM_BOND_OPTION_TYPE_INT, 0, 1 },
86 { NM_SETTING_BOND_OPTION_AD_SELECT, "stable", NM_BOND_OPTION_TYPE_BOTH, 0, 2,
87 { "stable", "bandwidth", "count", NULL } },
88 { NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, "layer2", NM_BOND_OPTION_TYPE_BOTH, 0, 2,
89 { "layer2", "layer3+4", "layer2+3", NULL } },
90 { NM_SETTING_BOND_OPTION_RESEND_IGMP, "1", NM_BOND_OPTION_TYPE_INT, 0, 255 },
91 { NM_SETTING_BOND_OPTION_LACP_RATE, "slow", NM_BOND_OPTION_TYPE_BOTH, 0, 1,
92 { "slow", "fast", NULL } },
96 * nm_setting_bond_new:
98 * Creates a new #NMSettingBond object with default values.
100 * Returns: (transfer full): the new empty #NMSettingBond object
103 nm_setting_bond_new (void)
105 return (NMSetting *) g_object_new (NM_TYPE_SETTING_BOND, NULL);
109 * nm_setting_bond_get_num_options:
110 * @setting: the #NMSettingBond
112 * Returns the number of options that should be set for this bond when it
113 * is activated. This can be used to retrieve each option individually
114 * using nm_setting_bond_get_option().
116 * Returns: the number of bonding options
119 nm_setting_bond_get_num_options (NMSettingBond *setting)
121 g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0);
123 return g_hash_table_size (NM_SETTING_BOND_GET_PRIVATE (setting)->options);
127 * nm_setting_bond_get_option:
128 * @setting: the #NMSettingBond
129 * @idx: index of the desired option, from 0 to
130 * nm_setting_bond_get_num_options() - 1
131 * @out_name: (out) (transfer none): on return, the name of the bonding option;
132 * this value is owned by the setting and should not be modified
133 * @out_value: (out) (transfer none): on return, the value of the name of the
134 * bonding option; this value is owned by the setting and should not be
137 * Given an index, return the value of the bonding option at that index. Indexes
138 * are *not* guaranteed to be static across modifications to options done by
139 * nm_setting_bond_add_option() and nm_setting_bond_remove_option(),
140 * and should not be used to refer to options except for short periods of time
141 * such as during option iteration.
143 * Returns: %TRUE on success if the index was valid and an option was found,
144 * %FALSE if the index was invalid (ie, greater than the number of options
145 * currently held by the setting)
148 nm_setting_bond_get_option (NMSettingBond *setting,
150 const char **out_name,
151 const char **out_value)
153 NMSettingBondPrivate *priv;
155 const char *_key = NULL, *_value = NULL;
157 g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
159 priv = NM_SETTING_BOND_GET_PRIVATE (setting);
161 if (idx >= nm_setting_bond_get_num_options (setting))
164 keys = g_hash_table_get_keys (priv->options);
165 _key = g_list_nth_data (keys, idx);
166 _value = g_hash_table_lookup (priv->options, _key);
178 validate_int (const char *name, const char *value, const BondDefault *def)
183 for (i = 0; i < strlen (value); i++) {
184 if (!g_ascii_isdigit (value[i]) && value[i] != '-')
189 num = strtol (value, NULL, 10);
192 if (num < def->min || num > def->max)
199 validate_list (const char *name, const char *value, const BondDefault *def)
203 for (i = 0; i < G_N_ELEMENTS (def->list) && def->list[i]; i++) {
204 if (g_strcmp0 (def->list[i], value) == 0)
208 /* empty validation list means all values pass */
209 return def->list[0] == NULL ? TRUE : FALSE;
213 validate_ip (const char *name, const char *value)
216 gboolean success = TRUE;
219 if (!value || !value[0])
222 ips = g_strsplit_set (value, ",", 0);
223 for (iter = ips; iter && *iter && success; iter++)
224 success = !!inet_aton (*iter, &addr);
231 validate_ifname (const char *name, const char *value)
233 if (!value || !value[0])
236 return nm_utils_iface_valid_name (value);
240 * nm_setting_bond_validate_option:
241 * @name: the name of the option to validate
242 * @value: the value of the option to validate
244 * Checks whether @name is a valid bond option and @value is a valid value for
245 * the @name. If @value is %NULL, the function only validates the option name.
247 * Returns: %TRUE, if the @value is valid for the given name.
248 * If the @name is not a valid option, %FALSE will be returned.
251 nm_setting_bond_validate_option (const char *name,
256 if (!name || !name[0])
259 for (i = 0; i < G_N_ELEMENTS (defaults); i++) {
260 if (g_strcmp0 (defaults[i].opt, name) == 0) {
263 switch (defaults[i].opt_type) {
264 case NM_BOND_OPTION_TYPE_INT:
265 return validate_int (name, value, &defaults[i]);
266 case NM_BOND_OPTION_TYPE_STRING:
267 return validate_list (name, value, &defaults[i]);
268 case NM_BOND_OPTION_TYPE_BOTH:
269 return ( validate_int (name, value, &defaults[i])
270 || validate_list (name, value, &defaults[i]));
271 case NM_BOND_OPTION_TYPE_IP:
272 return validate_ip (name, value);
273 case NM_BOND_OPTION_TYPE_IFNAME:
274 return validate_ifname (name, value);
283 * nm_setting_bond_get_option_by_name:
284 * @setting: the #NMSettingBond
285 * @name: the option name for which to retrieve the value
287 * Returns the value associated with the bonding option specified by
288 * @name, if it exists.
290 * Returns: the value, or %NULL if the key/value pair was never added to the
291 * setting; the value is owned by the setting and must not be modified
294 nm_setting_bond_get_option_by_name (NMSettingBond *setting,
297 g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL);
299 if (!nm_setting_bond_validate_option (name, NULL))
302 return g_hash_table_lookup (NM_SETTING_BOND_GET_PRIVATE (setting)->options, name);
306 * nm_setting_bond_add_option:
307 * @setting: the #NMSettingBond
308 * @name: name for the option
309 * @value: value for the option
311 * Add an option to the table. The option is compared to an internal list
312 * of allowed options. Option names may contain only alphanumeric characters
313 * (ie [a-zA-Z0-9]). Adding a new name replaces any existing name/value pair
314 * that may already exist.
316 * The order of how to set several options is relevant because there are options
317 * that conflict with each other.
319 * Returns: %TRUE if the option was valid and was added to the internal option
320 * list, %FALSE if it was not.
323 nm_setting_bond_add_option (NMSettingBond *setting,
327 NMSettingBondPrivate *priv;
329 g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
331 if (!value || !nm_setting_bond_validate_option (name, value))
334 priv = NM_SETTING_BOND_GET_PRIVATE (setting);
336 g_hash_table_insert (priv->options, g_strdup (name), g_strdup (value));
338 if ( !strcmp (name, NM_SETTING_BOND_OPTION_MIIMON)
339 && strcmp (value, "0") != 0) {
340 g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
341 g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
342 } else if ( !strcmp (name, NM_SETTING_BOND_OPTION_ARP_INTERVAL)
343 && strcmp (value, "0") != 0) {
344 g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_MIIMON);
345 g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_DOWNDELAY);
346 g_hash_table_remove (priv->options, NM_SETTING_BOND_OPTION_UPDELAY);
349 g_object_notify (G_OBJECT (setting), NM_SETTING_BOND_OPTIONS);
355 * nm_setting_bond_remove_option:
356 * @setting: the #NMSettingBond
357 * @name: name of the option to remove
359 * Remove the bonding option referenced by @name from the internal option
362 * Returns: %TRUE if the option was found and removed from the internal option
363 * list, %FALSE if it was not.
366 nm_setting_bond_remove_option (NMSettingBond *setting,
371 g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
373 if (!nm_setting_bond_validate_option (name, NULL))
376 found = g_hash_table_remove (NM_SETTING_BOND_GET_PRIVATE (setting)->options, name);
378 g_object_notify (G_OBJECT (setting), NM_SETTING_BOND_OPTIONS);
383 * nm_setting_bond_get_valid_options:
384 * @setting: the #NMSettingBond
386 * Returns a list of valid bond options.
388 * Returns: (transfer none): a %NULL-terminated array of strings of valid bond options.
391 nm_setting_bond_get_valid_options (NMSettingBond *setting)
393 static const char *array[G_N_ELEMENTS (defaults) + 1] = { NULL };
396 /* initialize the array once */
397 if (G_UNLIKELY (array[0] == NULL)) {
398 for (i = 0; i < G_N_ELEMENTS (defaults); i++)
399 array[i] = defaults[i].opt;
406 * nm_setting_bond_get_option_default:
407 * @setting: the #NMSettingBond
408 * @name: the name of the option
410 * Returns: the value of the bond option if not overridden by an entry in
411 * the #NMSettingBond:options property.
414 nm_setting_bond_get_option_default (NMSettingBond *setting, const char *name)
418 g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL);
419 g_return_val_if_fail (nm_setting_bond_validate_option (name, NULL), NULL);
421 for (i = 0; i < G_N_ELEMENTS (defaults); i++) {
422 if (g_strcmp0 (defaults[i].opt, name) == 0)
423 return defaults[i].val;
425 /* Any option that passes nm_setting_bond_validate_option() should also be found in defaults */
426 g_assert_not_reached ();
430 * nm_setting_bond_get_option_type:
431 * @setting: the #NMSettingBond
432 * @name: the name of the option
434 * Returns: the type of the bond option.
437 _nm_setting_bond_get_option_type (NMSettingBond *setting, const char *name)
441 g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NM_BOND_OPTION_TYPE_INT);
442 g_return_val_if_fail (nm_setting_bond_validate_option (name, NULL), NM_BOND_OPTION_TYPE_INT);
444 for (i = 0; i < G_N_ELEMENTS (defaults); i++) {
445 if (nm_streq0 (defaults[i].opt, name))
446 return defaults[i].opt_type;
448 /* Any option that passes nm_setting_bond_validate_option() should also be found in defaults */
449 g_assert_not_reached ();
453 verify (NMSetting *setting, NMConnection *connection, GError **error)
455 NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting);
457 const char *key, *value;
458 int mode, miimon = 0, arp_interval = 0;
459 const char *mode_orig, *mode_new;
460 const char *arp_ip_target = NULL;
461 const char *lacp_rate;
464 g_hash_table_iter_init (&iter, priv->options);
465 while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value)) {
466 if (!value[0] || !nm_setting_bond_validate_option (key, value)) {
469 NM_CONNECTION_ERROR_INVALID_PROPERTY,
470 _("invalid option '%s' or its value '%s'"),
472 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
477 value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MIIMON);
479 miimon = atoi (value);
480 value = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
482 arp_interval = atoi (value);
484 /* Can only set one of miimon and arp_interval */
485 if (miimon > 0 && arp_interval > 0) {
488 NM_CONNECTION_ERROR_INVALID_PROPERTY,
489 _("only one of '%s' and '%s' can be set"),
490 NM_SETTING_BOND_OPTION_MIIMON,
491 NM_SETTING_BOND_OPTION_ARP_INTERVAL);
492 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
496 /* Verify bond mode */
497 mode_orig = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_MODE);
501 NM_CONNECTION_ERROR_INVALID_PROPERTY,
502 _("mandatory option '%s' is missing"),
503 NM_SETTING_BOND_OPTION_MODE);
504 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
507 mode = nm_utils_bond_mode_string_to_int (mode_orig);
511 NM_CONNECTION_ERROR_INVALID_PROPERTY,
512 _("'%s' is not a valid value for '%s'"),
513 value, NM_SETTING_BOND_OPTION_MODE);
514 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
517 mode_new = nm_utils_bond_mode_int_to_string (mode);
519 /* Make sure mode is compatible with other settings */
520 if ( strcmp (mode_new, "balance-alb") == 0
521 || strcmp (mode_new, "balance-tlb") == 0) {
522 if (arp_interval > 0) {
525 NM_CONNECTION_ERROR_INVALID_PROPERTY,
526 _("'%s=%s' is incompatible with '%s > 0'"),
527 NM_SETTING_BOND_OPTION_MODE, mode_new, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
528 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
533 primary = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_PRIMARY);
534 if (strcmp (mode_new, "active-backup") == 0) {
535 if (primary && !nm_utils_iface_valid_name (primary)) {
538 NM_CONNECTION_ERROR_INVALID_PROPERTY,
539 _("'%s' is not a valid interface name for '%s' option"),
540 primary, NM_SETTING_BOND_OPTION_PRIMARY);
541 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
548 NM_CONNECTION_ERROR_INVALID_PROPERTY,
549 _("'%s' option is only valid for '%s=%s'"),
550 NM_SETTING_BOND_OPTION_PRIMARY,
551 NM_SETTING_BOND_OPTION_MODE, "active-backup");
552 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
557 if (nm_connection_get_setting_infiniband (connection)) {
558 if (strcmp (mode_new, "active-backup") != 0) {
561 NM_CONNECTION_ERROR_INVALID_PROPERTY,
562 _("'%s=%s' is not a valid configuration for '%s'"),
563 NM_SETTING_BOND_OPTION_MODE, mode_new, NM_SETTING_INFINIBAND_SETTING_NAME);
564 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
570 /* updelay and downdelay can only be used with miimon */
571 if (g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_UPDELAY)) {
574 NM_CONNECTION_ERROR_INVALID_PROPERTY,
575 _("'%s' option requires '%s' option to be set"),
576 NM_SETTING_BOND_OPTION_UPDELAY, NM_SETTING_BOND_OPTION_MIIMON);
577 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
580 if (g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_DOWNDELAY)) {
583 NM_CONNECTION_ERROR_INVALID_PROPERTY,
584 _("'%s' option requires '%s' option to be set"),
585 NM_SETTING_BOND_OPTION_DOWNDELAY, NM_SETTING_BOND_OPTION_MIIMON);
586 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
591 /* arp_ip_target can only be used with arp_interval, and must
592 * contain a comma-separated list of IPv4 addresses.
594 arp_ip_target = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
595 if (arp_interval > 0) {
600 if (!arp_ip_target) {
603 NM_CONNECTION_ERROR_INVALID_PROPERTY,
604 _("'%s' option requires '%s' option to be set"),
605 NM_SETTING_BOND_OPTION_ARP_INTERVAL, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
606 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
610 addrs = g_strsplit (arp_ip_target, ",", -1);
614 NM_CONNECTION_ERROR_INVALID_PROPERTY,
615 _("'%s' option is empty"),
616 NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
617 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
622 for (i = 0; addrs[i]; i++) {
623 if (!inet_pton (AF_INET, addrs[i], &addr)) {
626 NM_CONNECTION_ERROR_INVALID_PROPERTY,
627 _("'%s' is not a valid IPv4 address for '%s' option"),
628 NM_SETTING_BOND_OPTION_ARP_IP_TARGET, addrs[i]);
629 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
639 NM_CONNECTION_ERROR_INVALID_PROPERTY,
640 _("'%s' option requires '%s' option to be set"),
641 NM_SETTING_BOND_OPTION_ARP_IP_TARGET, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
642 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
647 lacp_rate = g_hash_table_lookup (priv->options, NM_SETTING_BOND_OPTION_LACP_RATE);
649 && g_strcmp0 (mode_new, "802.3ad")
650 && strcmp (lacp_rate, "slow") != 0
651 && strcmp (lacp_rate, "0") != 0) {
654 NM_CONNECTION_ERROR_INVALID_PROPERTY,
655 _("'%s' option is only valid with mode '%s'"),
656 NM_SETTING_BOND_OPTION_LACP_RATE, "802.3ad");
657 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
661 if (!_nm_connection_verify_required_interface_name (connection, error))
664 /* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */
666 if (g_strcmp0 (mode_orig, mode_new) != 0) {
669 NM_CONNECTION_ERROR_INVALID_PROPERTY,
670 _("'%s' option should be string"),
671 NM_SETTING_BOND_OPTION_MODE);
672 g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
673 return NM_SETTING_VERIFY_NORMALIZABLE;
680 nm_setting_bond_init (NMSettingBond *setting)
682 NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting);
684 priv->options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
686 /* Default values: */
687 nm_setting_bond_add_option (setting, NM_SETTING_BOND_OPTION_MODE, "balance-rr");
691 finalize (GObject *object)
693 NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object);
695 g_hash_table_destroy (priv->options);
697 G_OBJECT_CLASS (nm_setting_bond_parent_class)->finalize (object);
701 set_property (GObject *object, guint prop_id,
702 const GValue *value, GParamSpec *pspec)
704 NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object);
708 g_hash_table_unref (priv->options);
709 priv->options = _nm_utils_copy_strdict (g_value_get_boxed (value));
712 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
718 get_property (GObject *object, guint prop_id,
719 GValue *value, GParamSpec *pspec)
721 NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object);
725 g_value_take_boxed (value, _nm_utils_copy_strdict (priv->options));
728 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
734 nm_setting_bond_class_init (NMSettingBondClass *setting_class)
736 GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
737 NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
739 g_type_class_add_private (setting_class, sizeof (NMSettingBondPrivate));
741 /* virtual methods */
742 object_class->set_property = set_property;
743 object_class->get_property = get_property;
744 object_class->finalize = finalize;
745 parent_class->verify = verify;
749 * NMSettingBond:options:
751 * Dictionary of key/value pairs of bonding options. Both keys and values
752 * must be strings. Option names must contain only alphanumeric characters
755 * Type: GHashTable(utf8,utf8)
759 * variable: BONDING_OPTS
760 * description: Bonding options.
761 * example: BONDING_OPTS="miimon=100 mode=broadcast"
764 g_object_class_install_property
765 (object_class, PROP_OPTIONS,
766 g_param_spec_boxed (NM_SETTING_BOND_OPTIONS, "", "",
769 NM_SETTING_PARAM_INFERRABLE |
770 G_PARAM_STATIC_STRINGS));
771 _nm_setting_class_transform_property (parent_class, NM_SETTING_BOND_OPTIONS,
772 G_VARIANT_TYPE ("a{ss}"),
773 _nm_utils_strdict_to_dbus,
774 _nm_utils_strdict_from_dbus);
777 * property: interface-name
779 * description: Deprecated in favor of connection.interface-name, but can
780 * be used for backward-compatibility with older daemons, to set the
781 * bond's interface name.
784 _nm_setting_class_add_dbus_only_property (parent_class, "interface-name",
785 G_VARIANT_TYPE_STRING,
786 _nm_setting_get_deprecated_virtual_interface_name,