2019-09-10 11:19:01 +02:00
|
|
|
// SPDX-License-Identifier: LGPL-2.1+
|
2014-07-24 08:53:33 -04:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2011 - 2013 Red Hat, Inc.
|
2014-07-24 08:53:33 -04:00
|
|
|
*/
|
|
|
|
|
|
2016-02-19 14:57:48 +01:00
|
|
|
#include "nm-default.h"
|
2014-11-13 10:07:02 -05:00
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
#include "nm-setting-bond.h"
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
|
|
#include "nm-utils.h"
|
|
|
|
|
#include "nm-utils-private.h"
|
2014-10-21 22:30:31 -04:00
|
|
|
#include "nm-connection-private.h"
|
2014-10-21 22:09:52 -04:00
|
|
|
#include "nm-setting-infiniband.h"
|
2016-03-16 11:22:07 +01:00
|
|
|
#include "nm-core-internal.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-11-21 13:07:42 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* SECTION:nm-setting-bond
|
|
|
|
|
* @short_description: Describes connection properties for bonds
|
|
|
|
|
*
|
|
|
|
|
* The #NMSettingBond object is a #NMSetting subclass that describes properties
|
|
|
|
|
* necessary for bond connections.
|
|
|
|
|
**/
|
|
|
|
|
|
2017-11-21 13:07:42 +01:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2019-01-11 08:28:26 +01:00
|
|
|
NM_GOBJECT_PROPERTIES_DEFINE (NMSettingBond,
|
2014-07-24 08:53:33 -04:00
|
|
|
PROP_OPTIONS,
|
2019-01-11 08:28:26 +01:00
|
|
|
);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-11-21 13:07:42 +01:00
|
|
|
typedef struct {
|
|
|
|
|
GHashTable *options;
|
2017-11-21 14:01:02 +01:00
|
|
|
NMUtilsNamedValue *options_idx_cache;
|
2017-11-21 13:07:42 +01:00
|
|
|
} NMSettingBondPrivate;
|
|
|
|
|
|
libnm: use NMMetaSettingInfo for tracking setting priority
Previously, each (non abstract) NMSetting class had to register
its name and priority via _nm_register_setting().
Note, that libnm-core.la already links against "nm-meta-setting.c",
which also redundantly keeps track of the settings name and gtype
as well.
Re-use NMMetaSettingInfo also in libnm-core.la, to track this meta
data.
The goal is to get rid of private data structures that track
meta data about NMSetting classes. In this case, "registered_settings"
hash. Instead, we should have one place where all this meta data
is tracked. This was, it is also accessible as internal API,
which can be useful (for keyfile).
Note that NMSettingClass has some overlap with NMMetaSettingInfo.
One difference is, that NMMetaSettingInfo is const, while NMSettingClass
is only initialized during the class_init() method. Appart from that,
it's mostly a matter of taste, whether we attach meta data to
NMSettingClass, to NMMetaSettingInfo, or to a static-array indexed
by NMMetaSettingType.
Note, that previously, _nm_register_setting() was private API. That
means, no user could subclass a functioning NMSetting instance. The same
is still true: NMMetaSettingInfo is internal API and users cannot access
it to create their own NMSetting subclasses. But that is almost desired.
libnm is not designed, to be extensible via subclassing, nor is it
clear why that would be a useful thing to do. One day, we should remove
the NMSetting and NMSettingClass definitions from public headers. Their
only use is subclassing the types, which however does not work.
While libnm-core was linking already against nm-meta-setting.c,
nm_meta_setting_infos was unreferenced. So, this change increases
the binary size of libnm and NetworkManager (1032 bytes). Note however
that roughly the same information was previously allocated at runtime.
2018-07-27 14:08:14 +02:00
|
|
|
G_DEFINE_TYPE (NMSettingBond, nm_setting_bond, NM_TYPE_SETTING)
|
2017-11-21 13:07:42 +01:00
|
|
|
|
|
|
|
|
#define NM_SETTING_BOND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BOND, NMSettingBondPrivate))
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-02-19 10:52:21 +01:00
|
|
|
static const char *const valid_options_lst[] = {
|
|
|
|
|
NM_SETTING_BOND_OPTION_MODE,
|
|
|
|
|
NM_SETTING_BOND_OPTION_MIIMON,
|
|
|
|
|
NM_SETTING_BOND_OPTION_DOWNDELAY,
|
|
|
|
|
NM_SETTING_BOND_OPTION_UPDELAY,
|
|
|
|
|
NM_SETTING_BOND_OPTION_ARP_INTERVAL,
|
|
|
|
|
NM_SETTING_BOND_OPTION_ARP_IP_TARGET,
|
|
|
|
|
NM_SETTING_BOND_OPTION_ARP_VALIDATE,
|
|
|
|
|
NM_SETTING_BOND_OPTION_PRIMARY,
|
|
|
|
|
NM_SETTING_BOND_OPTION_PRIMARY_RESELECT,
|
|
|
|
|
NM_SETTING_BOND_OPTION_FAIL_OVER_MAC,
|
|
|
|
|
NM_SETTING_BOND_OPTION_USE_CARRIER,
|
|
|
|
|
NM_SETTING_BOND_OPTION_AD_SELECT,
|
|
|
|
|
NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY,
|
|
|
|
|
NM_SETTING_BOND_OPTION_RESEND_IGMP,
|
|
|
|
|
NM_SETTING_BOND_OPTION_LACP_RATE,
|
|
|
|
|
NM_SETTING_BOND_OPTION_ACTIVE_SLAVE,
|
|
|
|
|
NM_SETTING_BOND_OPTION_AD_ACTOR_SYS_PRIO,
|
|
|
|
|
NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM,
|
|
|
|
|
NM_SETTING_BOND_OPTION_AD_USER_PORT_KEY,
|
|
|
|
|
NM_SETTING_BOND_OPTION_ALL_SLAVES_ACTIVE,
|
|
|
|
|
NM_SETTING_BOND_OPTION_ARP_ALL_TARGETS,
|
|
|
|
|
NM_SETTING_BOND_OPTION_MIN_LINKS,
|
|
|
|
|
NM_SETTING_BOND_OPTION_NUM_GRAT_ARP,
|
|
|
|
|
NM_SETTING_BOND_OPTION_NUM_UNSOL_NA,
|
|
|
|
|
NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE,
|
|
|
|
|
NM_SETTING_BOND_OPTION_TLB_DYNAMIC_LB,
|
|
|
|
|
NM_SETTING_BOND_OPTION_LP_INTERVAL,
|
|
|
|
|
NULL,
|
|
|
|
|
};
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
typedef struct {
|
|
|
|
|
const char *val;
|
2020-02-19 10:52:21 +01:00
|
|
|
NMBondOptionType opt_type;
|
2014-07-24 08:53:33 -04:00
|
|
|
guint min;
|
|
|
|
|
guint max;
|
2020-02-19 10:52:21 +01:00
|
|
|
const char *const*list;
|
|
|
|
|
} OptionMeta;
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
_nm_assert_bond_meta (const OptionMeta *option_meta)
|
|
|
|
|
{
|
|
|
|
|
nm_assert (option_meta);
|
|
|
|
|
|
|
|
|
|
switch (option_meta->opt_type) {
|
|
|
|
|
case NM_BOND_OPTION_TYPE_BOTH:
|
|
|
|
|
nm_assert (option_meta->val);
|
|
|
|
|
nm_assert (option_meta->list);
|
|
|
|
|
nm_assert (option_meta->list[0]);
|
|
|
|
|
nm_assert (option_meta->min == 0);
|
|
|
|
|
nm_assert (option_meta->max == NM_PTRARRAY_LEN (option_meta->list) - 1);
|
|
|
|
|
nm_assert (g_strv_contains (option_meta->list, option_meta->val));
|
|
|
|
|
return TRUE;
|
|
|
|
|
case NM_BOND_OPTION_TYPE_INT:
|
|
|
|
|
nm_assert (option_meta->val);
|
|
|
|
|
nm_assert (!option_meta->list);
|
|
|
|
|
nm_assert (option_meta->min < option_meta->max);
|
|
|
|
|
nm_assert (NM_STRCHAR_ALL (option_meta->val, ch, g_ascii_isdigit (ch)));
|
|
|
|
|
nm_assert (NM_STRCHAR_ALL (option_meta->val, ch, g_ascii_isdigit (ch)));
|
|
|
|
|
nm_assert (({
|
|
|
|
|
_nm_utils_ascii_str_to_uint64 (option_meta->val, 10, option_meta->min, option_meta->max, 0);
|
|
|
|
|
errno == 0;
|
|
|
|
|
}));
|
|
|
|
|
return TRUE;
|
|
|
|
|
case NM_BOND_OPTION_TYPE_IP:
|
|
|
|
|
case NM_BOND_OPTION_TYPE_IFNAME:
|
|
|
|
|
nm_assert (option_meta->val);
|
|
|
|
|
/* fall-through */
|
|
|
|
|
case NM_BOND_OPTION_TYPE_MAC:
|
|
|
|
|
nm_assert (!option_meta->list);
|
|
|
|
|
nm_assert (option_meta->min == 0);
|
|
|
|
|
nm_assert (option_meta->max == 0);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nm_assert_not_reached ();
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char const *const _option_default_strv_ad_select[] = NM_MAKE_STRV ("stable", "bandwidth", "count");
|
|
|
|
|
static char const *const _option_default_strv_arp_all_targets[] = NM_MAKE_STRV ("any", "all");
|
|
|
|
|
static char const *const _option_default_strv_arp_validate[] = NM_MAKE_STRV ("none", "active", "backup", "all", "filter", "filter_active", "filter_backup");
|
|
|
|
|
static char const *const _option_default_strv_fail_over_mac[] = NM_MAKE_STRV ("none", "active", "follow");
|
|
|
|
|
static char const *const _option_default_strv_lacp_rate[] = NM_MAKE_STRV ("slow", "fast");
|
|
|
|
|
static char const *const _option_default_strv_mode[] = NM_MAKE_STRV ("balance-rr", "active-backup", "balance-xor", "broadcast", "802.3ad", "balance-tlb", "balance-alb");
|
|
|
|
|
static char const *const _option_default_strv_primary_reselect[] = NM_MAKE_STRV ("always", "better", "failure");
|
|
|
|
|
static char const *const _option_default_strv_xmit_hash_policy[] = NM_MAKE_STRV ("layer2", "layer3+4", "layer2+3", "encap2+3", "encap3+4");
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
NM_UTILS_STRING_TABLE_LOOKUP_STRUCT_DEFINE (
|
|
|
|
|
_get_option_meta,
|
|
|
|
|
OptionMeta,
|
|
|
|
|
{
|
|
|
|
|
G_STATIC_ASSERT_EXPR (G_N_ELEMENTS (LIST) == G_N_ELEMENTS (valid_options_lst) - 1);
|
|
|
|
|
|
|
|
|
|
if (NM_MORE_ASSERT_ONCE (5)) {
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
nm_assert (G_N_ELEMENTS (LIST) == NM_PTRARRAY_LEN (valid_options_lst));
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (LIST); i++)
|
|
|
|
|
_nm_assert_bond_meta (&LIST[i].value);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ return NULL; },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_ACTIVE_SLAVE, { "", NM_BOND_OPTION_TYPE_IFNAME } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_AD_ACTOR_SYS_PRIO, { "65535", NM_BOND_OPTION_TYPE_INT, 1, 65535 } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM, { NULL, NM_BOND_OPTION_TYPE_MAC } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_AD_SELECT, { "stable", NM_BOND_OPTION_TYPE_BOTH, 0, 2, _option_default_strv_ad_select } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_AD_USER_PORT_KEY, { "0", NM_BOND_OPTION_TYPE_INT, 0, 1023 } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_ALL_SLAVES_ACTIVE, { "0", NM_BOND_OPTION_TYPE_INT, 0, 1 } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_ARP_ALL_TARGETS, { "any", NM_BOND_OPTION_TYPE_BOTH, 0, 1, _option_default_strv_arp_all_targets } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_ARP_INTERVAL, { "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_ARP_IP_TARGET, { "", NM_BOND_OPTION_TYPE_IP } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_ARP_VALIDATE, { "none", NM_BOND_OPTION_TYPE_BOTH, 0, 6, _option_default_strv_arp_validate } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_DOWNDELAY, { "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_FAIL_OVER_MAC, { "none", NM_BOND_OPTION_TYPE_BOTH, 0, 2, _option_default_strv_fail_over_mac } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_LACP_RATE, { "slow", NM_BOND_OPTION_TYPE_BOTH, 0, 1, _option_default_strv_lacp_rate } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_LP_INTERVAL, { "1", NM_BOND_OPTION_TYPE_INT, 1, G_MAXINT } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_MIIMON, { "100", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_MIN_LINKS, { "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_MODE, { "balance-rr", NM_BOND_OPTION_TYPE_BOTH, 0, 6, _option_default_strv_mode } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_NUM_GRAT_ARP, { "1", NM_BOND_OPTION_TYPE_INT, 0, 255 } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_NUM_UNSOL_NA, { "1", NM_BOND_OPTION_TYPE_INT, 0, 255 } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE, { "1", NM_BOND_OPTION_TYPE_INT, 0, 65535 } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_PRIMARY, { "", NM_BOND_OPTION_TYPE_IFNAME } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_PRIMARY_RESELECT, { "always", NM_BOND_OPTION_TYPE_BOTH, 0, 2, _option_default_strv_primary_reselect } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_RESEND_IGMP, { "1", NM_BOND_OPTION_TYPE_INT, 0, 255 } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_TLB_DYNAMIC_LB, { "1", NM_BOND_OPTION_TYPE_INT, 0, 1 } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_UPDELAY, { "0", NM_BOND_OPTION_TYPE_INT, 0, G_MAXINT } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_USE_CARRIER, { "1", NM_BOND_OPTION_TYPE_INT, 0, 1 } },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_XMIT_HASH_POLICY, { "layer2", NM_BOND_OPTION_TYPE_BOTH, 0, 4, _option_default_strv_xmit_hash_policy } },
|
|
|
|
|
);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-11-21 13:07:42 +01:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2020-02-21 11:41:07 +01:00
|
|
|
#define BIT(x) (((guint32) 1) << (x))
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
NM_UTILS_STRING_TABLE_LOOKUP_DEFINE (
|
|
|
|
|
_bond_option_unsupp_mode,
|
|
|
|
|
guint32,
|
|
|
|
|
{ ; },
|
|
|
|
|
{ return 0; },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_ACTIVE_SLAVE, ~(BIT (NM_BOND_MODE_ACTIVEBACKUP) | BIT (NM_BOND_MODE_TLB) | BIT (NM_BOND_MODE_ALB)) },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_AD_ACTOR_SYS_PRIO, ~(BIT (NM_BOND_MODE_8023AD)) },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM, ~(BIT (NM_BOND_MODE_8023AD)) },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_AD_USER_PORT_KEY, ~(BIT (NM_BOND_MODE_8023AD)) },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_ARP_INTERVAL, (BIT (NM_BOND_MODE_8023AD) | BIT (NM_BOND_MODE_TLB) | BIT (NM_BOND_MODE_ALB)) },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_ARP_IP_TARGET, (BIT (NM_BOND_MODE_8023AD) | BIT (NM_BOND_MODE_TLB) | BIT (NM_BOND_MODE_ALB)) },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_ARP_VALIDATE, (BIT (NM_BOND_MODE_8023AD) | BIT (NM_BOND_MODE_TLB) | BIT (NM_BOND_MODE_ALB)) },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_LACP_RATE, ~(BIT (NM_BOND_MODE_8023AD)) },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_PACKETS_PER_SLAVE, ~(BIT (NM_BOND_MODE_ROUNDROBIN)) },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_PRIMARY, ~(BIT (NM_BOND_MODE_ACTIVEBACKUP) | BIT (NM_BOND_MODE_TLB) | BIT (NM_BOND_MODE_ALB)) },
|
|
|
|
|
{ NM_SETTING_BOND_OPTION_TLB_DYNAMIC_LB, ~(BIT (NM_BOND_MODE_TLB)) },
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
_nm_setting_bond_option_supported (const char *option, NMBondMode mode)
|
|
|
|
|
{
|
|
|
|
|
nm_assert (option);
|
|
|
|
|
nm_assert (_NM_INT_NOT_NEGATIVE (mode) && mode < 32);
|
|
|
|
|
|
|
|
|
|
return !NM_FLAGS_ANY (_bond_option_unsupp_mode (option), BIT (mode));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char*
|
|
|
|
|
_bond_get_option (NMSettingBond *self,
|
|
|
|
|
const char *option)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (self), NULL);
|
|
|
|
|
g_return_val_if_fail (option, NULL);
|
|
|
|
|
|
|
|
|
|
return g_hash_table_lookup (NM_SETTING_BOND_GET_PRIVATE (self)->options, option);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char*
|
|
|
|
|
_bond_get_option_default (NMSettingBond *self,
|
|
|
|
|
const char *option)
|
|
|
|
|
{
|
|
|
|
|
const OptionMeta *option_meta;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (self), NULL);
|
|
|
|
|
|
|
|
|
|
option_meta = _get_option_meta (option);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (option_meta, NULL);
|
|
|
|
|
|
|
|
|
|
return option_meta->val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char*
|
|
|
|
|
_bond_get_option_or_default (NMSettingBond *self,
|
|
|
|
|
const char *option)
|
|
|
|
|
{
|
|
|
|
|
const char *value;
|
|
|
|
|
|
|
|
|
|
value = _bond_get_option (self, option);
|
|
|
|
|
if (!value) {
|
|
|
|
|
value = _bond_get_option_default (self, option);
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char*
|
|
|
|
|
_bond_get_option_normalized (NMSettingBond* self,
|
|
|
|
|
const char* option,
|
|
|
|
|
gboolean get_default_only)
|
|
|
|
|
{
|
|
|
|
|
const char *arp_interval_str;
|
|
|
|
|
const char *mode_str;
|
|
|
|
|
gint64 arp_interval;
|
|
|
|
|
NMBondMode mode;
|
|
|
|
|
const char *value = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (self), NULL);
|
|
|
|
|
g_return_val_if_fail (option, NULL);
|
|
|
|
|
|
|
|
|
|
mode_str = _bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_MODE);
|
|
|
|
|
mode = _nm_setting_bond_mode_from_string (mode_str);
|
|
|
|
|
g_return_val_if_fail (mode != NM_BOND_MODE_UNKNOWN, NULL);
|
|
|
|
|
|
|
|
|
|
if (!_nm_setting_bond_option_supported (option, mode))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Apply custom NetworkManager policies here */
|
|
|
|
|
if (!get_default_only) {
|
|
|
|
|
if (NM_IN_STRSET (option,
|
|
|
|
|
NM_SETTING_BOND_OPTION_UPDELAY,
|
|
|
|
|
NM_SETTING_BOND_OPTION_DOWNDELAY,
|
|
|
|
|
NM_SETTING_BOND_OPTION_MIIMON)) {
|
|
|
|
|
/* if arp_interval is explicitly set and miimon is not, then disable miimon
|
|
|
|
|
* (and related updelay and downdelay) as recommended by the kernel docs */
|
|
|
|
|
arp_interval_str = _bond_get_option (self, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
|
|
|
|
|
arp_interval = _nm_utils_ascii_str_to_int64 (arp_interval_str, 10, 0, G_MAXINT, 0);
|
|
|
|
|
|
|
|
|
|
if (!arp_interval || _bond_get_option (self, NM_SETTING_BOND_OPTION_MIIMON)) {
|
|
|
|
|
value = _bond_get_option (self, option);
|
|
|
|
|
} else {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
} else if (NM_IN_STRSET (option,
|
|
|
|
|
NM_SETTING_BOND_OPTION_NUM_GRAT_ARP,
|
|
|
|
|
NM_SETTING_BOND_OPTION_NUM_UNSOL_NA)) {
|
|
|
|
|
/* just get one of the 2, at kernel level they're the same bond option */
|
|
|
|
|
value = _bond_get_option (self, NM_SETTING_BOND_OPTION_NUM_GRAT_ARP);
|
|
|
|
|
if (!value) {
|
|
|
|
|
value = _bond_get_option (self, NM_SETTING_BOND_OPTION_NUM_UNSOL_NA);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
value = _bond_get_option (self, option);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!value) {
|
|
|
|
|
/* Apply rules that change the default value of an option */
|
|
|
|
|
if (nm_streq (option, NM_SETTING_BOND_OPTION_AD_ACTOR_SYSTEM)) {
|
|
|
|
|
/* The default value depends on the current mode */
|
|
|
|
|
if (NM_IN_STRSET (mode_str, "4", "802.3ad"))
|
|
|
|
|
return "00:00:00:00:00:00";
|
|
|
|
|
else
|
|
|
|
|
return "";
|
|
|
|
|
} else {
|
|
|
|
|
return _bond_get_option_or_default (self, option);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char*
|
|
|
|
|
nm_setting_bond_get_option_or_default (NMSettingBond *self,
|
|
|
|
|
const char *option)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (self), NULL);
|
|
|
|
|
g_return_val_if_fail (option, NULL);
|
|
|
|
|
|
|
|
|
|
return _bond_get_option_normalized (self,
|
|
|
|
|
option,
|
|
|
|
|
FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-27 17:20:09 +01:00
|
|
|
static int
|
|
|
|
|
_atoi (const char *value)
|
|
|
|
|
{
|
|
|
|
|
int v;
|
|
|
|
|
|
|
|
|
|
v = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXINT, -1);
|
|
|
|
|
nm_assert (v >= 0);
|
|
|
|
|
return v;
|
|
|
|
|
};
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* nm_setting_bond_get_num_options:
|
|
|
|
|
* @setting: the #NMSettingBond
|
|
|
|
|
*
|
|
|
|
|
* Returns the number of options that should be set for this bond when it
|
|
|
|
|
* is activated. This can be used to retrieve each option individually
|
|
|
|
|
* using nm_setting_bond_get_option().
|
|
|
|
|
*
|
|
|
|
|
* Returns: the number of bonding options
|
|
|
|
|
**/
|
|
|
|
|
guint32
|
|
|
|
|
nm_setting_bond_get_num_options (NMSettingBond *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (setting), 0);
|
|
|
|
|
|
|
|
|
|
return g_hash_table_size (NM_SETTING_BOND_GET_PRIVATE (setting)->options);
|
|
|
|
|
}
|
|
|
|
|
|
libnm: sort "mode" in nm_setting_bond_get_option() first
Internally, the options are tracked in a hash table and of undefined
sort order. However, nm_setting_bond_get_option() always returns a stable
(sorted) order.
Move "mode" as first, because that is usually the most interesting option.
The effect is:
$ nmcli -o connection show "$BOND_PROFILE"
...
-bond.options: arp_interval=5,arp_ip_target=192.168.7.7,arp_validate=active,mode=balance-rr,use_carrier=0
+bond.options: mode=balance-rr,arp_interval=5,arp_ip_target=192.168.7.7,arp_validate=active,use_carrier=0
This doesn't affect keyfile, which sorts the hash keys themself (and
doesn't treat the "mode" special).
This however does affect ifcfg-rh writer how it writes the BONDING_OPTS
variable. I think this change is fine and preferable.
2020-02-19 16:16:02 +01:00
|
|
|
static int
|
|
|
|
|
_get_option_sort (gconstpointer p_a, gconstpointer p_b, gpointer _unused)
|
|
|
|
|
{
|
|
|
|
|
const char *a = *((const char *const*) p_a);
|
|
|
|
|
const char *b = *((const char *const*) p_b);
|
|
|
|
|
|
|
|
|
|
NM_CMP_DIRECT (nm_streq (b, NM_SETTING_BOND_OPTION_MODE),
|
|
|
|
|
nm_streq (a, NM_SETTING_BOND_OPTION_MODE));
|
|
|
|
|
NM_CMP_DIRECT_STRCMP (a, b);
|
|
|
|
|
nm_assert_not_reached ();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 16:47:36 +01:00
|
|
|
static void
|
|
|
|
|
_ensure_options_idx_cache (NMSettingBondPrivate *priv)
|
|
|
|
|
{
|
|
|
|
|
if (!G_UNLIKELY (priv->options_idx_cache))
|
|
|
|
|
priv->options_idx_cache = nm_utils_named_values_from_str_dict_with_sort (priv->options, NULL, _get_option_sort, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* nm_setting_bond_get_option:
|
|
|
|
|
* @setting: the #NMSettingBond
|
|
|
|
|
* @idx: index of the desired option, from 0 to
|
|
|
|
|
* nm_setting_bond_get_num_options() - 1
|
2014-11-13 14:14:11 -05:00
|
|
|
* @out_name: (out) (transfer none): on return, the name of the bonding option;
|
|
|
|
|
* this value is owned by the setting and should not be modified
|
|
|
|
|
* @out_value: (out) (transfer none): on return, the value of the name of the
|
|
|
|
|
* bonding option; this value is owned by the setting and should not be
|
|
|
|
|
* modified
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
|
|
|
|
* Given an index, return the value of the bonding option at that index. Indexes
|
|
|
|
|
* are *not* guaranteed to be static across modifications to options done by
|
|
|
|
|
* nm_setting_bond_add_option() and nm_setting_bond_remove_option(),
|
|
|
|
|
* and should not be used to refer to options except for short periods of time
|
|
|
|
|
* such as during option iteration.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE on success if the index was valid and an option was found,
|
|
|
|
|
* %FALSE if the index was invalid (ie, greater than the number of options
|
|
|
|
|
* currently held by the setting)
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_bond_get_option (NMSettingBond *setting,
|
|
|
|
|
guint32 idx,
|
|
|
|
|
const char **out_name,
|
|
|
|
|
const char **out_value)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBondPrivate *priv;
|
2017-12-08 17:34:22 +01:00
|
|
|
guint len;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
|
|
|
|
|
2017-11-21 13:25:57 +01:00
|
|
|
len = g_hash_table_size (priv->options);
|
|
|
|
|
if (idx >= len)
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
|
2020-02-19 16:47:36 +01:00
|
|
|
_ensure_options_idx_cache (priv);
|
2017-11-21 14:01:02 +01:00
|
|
|
|
|
|
|
|
NM_SET_OUT (out_name, priv->options_idx_cache[idx].name);
|
|
|
|
|
NM_SET_OUT (out_value, priv->options_idx_cache[idx].value_str);
|
2014-07-24 08:53:33 -04:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2020-02-19 10:52:21 +01:00
|
|
|
validate_int (const char *name, const char *value, const OptionMeta *option_meta)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2019-01-31 13:40:53 +01:00
|
|
|
guint64 num;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2019-01-31 13:40:53 +01:00
|
|
|
if (!NM_STRCHAR_ALL (value, ch, g_ascii_isdigit (ch)))
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
2019-01-31 13:40:53 +01:00
|
|
|
|
2020-02-19 10:52:21 +01:00
|
|
|
num = _nm_utils_ascii_str_to_uint64 (value, 10, option_meta->min, option_meta->max, G_MAXUINT64);
|
2019-01-31 13:40:53 +01:00
|
|
|
if ( num == G_MAXUINT64
|
|
|
|
|
&& errno != 0)
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2020-02-19 10:52:21 +01:00
|
|
|
validate_list (const char *name, const char *value, const OptionMeta *option_meta)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2020-02-19 10:52:21 +01:00
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
nm_assert (option_meta->list);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2020-02-19 10:52:21 +01:00
|
|
|
for (i = 0; option_meta->list[i]; i++) {
|
|
|
|
|
if (nm_streq (option_meta->list[i], value))
|
2014-07-24 08:53:33 -04:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2020-02-19 10:52:21 +01:00
|
|
|
return FALSE;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
validate_ip (const char *name, const char *value)
|
|
|
|
|
{
|
2017-06-02 13:15:18 +02:00
|
|
|
gs_free char *value_clone = NULL;
|
2014-07-24 08:53:33 -04:00
|
|
|
struct in_addr addr;
|
|
|
|
|
|
|
|
|
|
if (!value || !value[0])
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2017-06-02 13:15:18 +02:00
|
|
|
value_clone = g_strdup (value);
|
|
|
|
|
value = value_clone;
|
|
|
|
|
for (;;) {
|
|
|
|
|
char *eow;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-06-02 13:15:18 +02:00
|
|
|
/* we do not skip over empty words. E.g
|
|
|
|
|
* "192.168.1.1," is an error.
|
|
|
|
|
*
|
|
|
|
|
* ... for no particular reason. */
|
|
|
|
|
|
|
|
|
|
eow = strchr (value, ',');
|
|
|
|
|
if (eow)
|
|
|
|
|
*eow = '\0';
|
|
|
|
|
|
|
|
|
|
if (inet_pton (AF_INET, value, &addr) != 1)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!eow)
|
|
|
|
|
break;
|
|
|
|
|
value = eow + 1;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
validate_ifname (const char *name, const char *value)
|
|
|
|
|
{
|
2020-02-12 18:01:13 +01:00
|
|
|
return nm_utils_ifname_valid_kernel (value, NULL);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bond_validate_option:
|
|
|
|
|
* @name: the name of the option to validate
|
|
|
|
|
* @value: the value of the option to validate
|
|
|
|
|
*
|
|
|
|
|
* Checks whether @name is a valid bond option and @value is a valid value for
|
|
|
|
|
* the @name. If @value is %NULL, the function only validates the option name.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE, if the @value is valid for the given name.
|
|
|
|
|
* If the @name is not a valid option, %FALSE will be returned.
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_bond_validate_option (const char *name,
|
|
|
|
|
const char *value)
|
|
|
|
|
{
|
2020-02-19 10:52:21 +01:00
|
|
|
const OptionMeta *option_meta;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2020-02-19 10:52:21 +01:00
|
|
|
option_meta = _get_option_meta (name);
|
|
|
|
|
if (!option_meta)
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
|
2020-02-19 10:52:21 +01:00
|
|
|
if (!value)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
switch (option_meta->opt_type) {
|
|
|
|
|
case NM_BOND_OPTION_TYPE_INT:
|
|
|
|
|
return validate_int (name, value, option_meta);
|
|
|
|
|
case NM_BOND_OPTION_TYPE_BOTH:
|
|
|
|
|
return ( validate_int (name, value, option_meta)
|
|
|
|
|
|| validate_list (name, value, option_meta));
|
|
|
|
|
case NM_BOND_OPTION_TYPE_IP:
|
|
|
|
|
return validate_ip (name, value);
|
|
|
|
|
case NM_BOND_OPTION_TYPE_MAC:
|
|
|
|
|
return nm_utils_hwaddr_valid (value, ETH_ALEN);
|
|
|
|
|
case NM_BOND_OPTION_TYPE_IFNAME:
|
|
|
|
|
return validate_ifname (name, value);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
2020-02-19 10:52:21 +01:00
|
|
|
|
|
|
|
|
nm_assert_not_reached ();
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bond_get_option_by_name:
|
|
|
|
|
* @setting: the #NMSettingBond
|
|
|
|
|
* @name: the option name for which to retrieve the value
|
|
|
|
|
*
|
|
|
|
|
* Returns the value associated with the bonding option specified by
|
|
|
|
|
* @name, if it exists.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the value, or %NULL if the key/value pair was never added to the
|
|
|
|
|
* setting; the value is owned by the setting and must not be modified
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_bond_get_option_by_name (NMSettingBond *setting,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL);
|
|
|
|
|
|
|
|
|
|
if (!nm_setting_bond_validate_option (name, NULL))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2020-02-21 11:41:07 +01:00
|
|
|
return _bond_get_option (setting, name);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bond_add_option:
|
|
|
|
|
* @setting: the #NMSettingBond
|
|
|
|
|
* @name: name for the option
|
|
|
|
|
* @value: value for the option
|
|
|
|
|
*
|
|
|
|
|
* Add an option to the table. The option is compared to an internal list
|
|
|
|
|
* of allowed options. Option names may contain only alphanumeric characters
|
|
|
|
|
* (ie [a-zA-Z0-9]). Adding a new name replaces any existing name/value pair
|
|
|
|
|
* that may already exist.
|
|
|
|
|
*
|
|
|
|
|
* The order of how to set several options is relevant because there are options
|
|
|
|
|
* that conflict with each other.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the option was valid and was added to the internal option
|
|
|
|
|
* list, %FALSE if it was not.
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_bond_add_option (NMSettingBond *setting,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *value)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBondPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
if (!value || !nm_setting_bond_validate_option (name, value))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
|
|
|
|
|
2017-11-21 14:01:02 +01:00
|
|
|
nm_clear_g_free (&priv->options_idx_cache);
|
2014-07-24 08:53:33 -04:00
|
|
|
g_hash_table_insert (priv->options, g_strdup (name), g_strdup (value));
|
|
|
|
|
|
2019-01-11 08:28:26 +01:00
|
|
|
_notify (setting, PROP_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bond_remove_option:
|
|
|
|
|
* @setting: the #NMSettingBond
|
|
|
|
|
* @name: name of the option to remove
|
|
|
|
|
*
|
|
|
|
|
* Remove the bonding option referenced by @name from the internal option
|
|
|
|
|
* list.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the option was found and removed from the internal option
|
|
|
|
|
* list, %FALSE if it was not.
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_bond_remove_option (NMSettingBond *setting,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
2017-11-21 14:01:02 +01:00
|
|
|
NMSettingBondPrivate *priv;
|
2014-07-24 08:53:33 -04:00
|
|
|
gboolean found;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
if (!nm_setting_bond_validate_option (name, NULL))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2017-11-21 14:01:02 +01:00
|
|
|
priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
nm_clear_g_free (&priv->options_idx_cache);
|
|
|
|
|
found = g_hash_table_remove (priv->options, name);
|
2014-07-24 08:53:33 -04:00
|
|
|
if (found)
|
2019-01-11 08:28:26 +01:00
|
|
|
_notify (setting, PROP_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bond_get_valid_options:
|
2017-04-27 09:00:55 +02:00
|
|
|
* @setting: (allow-none): the #NMSettingBond
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
|
|
|
|
* Returns a list of valid bond options.
|
|
|
|
|
*
|
2017-03-27 17:07:28 +02:00
|
|
|
* The @setting argument is unused and may be passed as %NULL.
|
|
|
|
|
*
|
2014-07-24 08:53:33 -04:00
|
|
|
* Returns: (transfer none): a %NULL-terminated array of strings of valid bond options.
|
|
|
|
|
**/
|
|
|
|
|
const char **
|
|
|
|
|
nm_setting_bond_get_valid_options (NMSettingBond *setting)
|
|
|
|
|
{
|
2020-02-19 10:52:21 +01:00
|
|
|
return (const char **) valid_options_lst;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bond_get_option_default:
|
|
|
|
|
* @setting: the #NMSettingBond
|
|
|
|
|
* @name: the name of the option
|
|
|
|
|
*
|
|
|
|
|
* Returns: the value of the bond option if not overridden by an entry in
|
|
|
|
|
* the #NMSettingBond:options property.
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_bond_get_option_default (NMSettingBond *setting, const char *name)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NULL);
|
2020-02-19 10:52:21 +01:00
|
|
|
|
2020-02-21 11:41:07 +01:00
|
|
|
if (!name) {
|
|
|
|
|
return NULL;
|
2016-07-04 16:39:28 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-21 11:41:07 +01:00
|
|
|
return _bond_get_option_normalized (setting,
|
|
|
|
|
name,
|
|
|
|
|
TRUE);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2016-03-16 11:22:07 +01:00
|
|
|
/**
|
|
|
|
|
* nm_setting_bond_get_option_type:
|
|
|
|
|
* @setting: the #NMSettingBond
|
|
|
|
|
* @name: the name of the option
|
|
|
|
|
*
|
|
|
|
|
* Returns: the type of the bond option.
|
|
|
|
|
**/
|
|
|
|
|
NMBondOptionType
|
|
|
|
|
_nm_setting_bond_get_option_type (NMSettingBond *setting, const char *name)
|
|
|
|
|
{
|
2020-02-19 10:52:21 +01:00
|
|
|
const OptionMeta *option_meta;
|
2016-03-16 11:22:07 +01:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BOND (setting), NM_BOND_OPTION_TYPE_INT);
|
|
|
|
|
|
2020-02-19 10:52:21 +01:00
|
|
|
option_meta = _get_option_meta (name);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (option_meta, NM_BOND_OPTION_TYPE_INT);
|
|
|
|
|
|
|
|
|
|
return option_meta->opt_type;
|
2016-03-16 11:22:07 +01:00
|
|
|
}
|
|
|
|
|
|
2020-02-13 09:43:08 +01:00
|
|
|
NM_UTILS_STRING_TABLE_LOOKUP_DEFINE (
|
|
|
|
|
_nm_setting_bond_mode_from_string,
|
|
|
|
|
NMBondMode,
|
|
|
|
|
{ g_return_val_if_fail (name, NM_BOND_MODE_UNKNOWN); },
|
|
|
|
|
{ return NM_BOND_MODE_UNKNOWN; },
|
|
|
|
|
{ "802.3ad", NM_BOND_MODE_8023AD },
|
|
|
|
|
{ "active-backup", NM_BOND_MODE_ACTIVEBACKUP },
|
|
|
|
|
{ "balance-alb", NM_BOND_MODE_ALB },
|
|
|
|
|
{ "balance-rr", NM_BOND_MODE_ROUNDROBIN },
|
|
|
|
|
{ "balance-tlb", NM_BOND_MODE_TLB },
|
|
|
|
|
{ "balance-xor", NM_BOND_MODE_XOR },
|
|
|
|
|
{ "broadcast", NM_BOND_MODE_BROADCAST },
|
|
|
|
|
);
|
2016-07-04 16:25:39 +02:00
|
|
|
|
2017-11-21 13:07:42 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static gboolean
|
2014-10-21 22:30:31 -04:00
|
|
|
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2020-02-20 15:38:01 +01:00
|
|
|
NMSettingBond *self = NM_SETTING_BOND (setting);
|
2014-07-24 08:53:33 -04:00
|
|
|
NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
2020-02-19 16:47:36 +01:00
|
|
|
int mode;
|
2020-02-20 15:38:01 +01:00
|
|
|
int miimon;
|
|
|
|
|
int arp_interval;
|
|
|
|
|
int num_grat_arp;
|
|
|
|
|
int num_unsol_na;
|
2020-02-19 16:47:36 +01:00
|
|
|
const char *mode_orig;
|
|
|
|
|
const char *mode_new;
|
2014-07-24 08:53:33 -04:00
|
|
|
const char *arp_ip_target = NULL;
|
2014-08-23 00:48:50 +02:00
|
|
|
const char *lacp_rate;
|
2014-07-24 08:53:33 -04:00
|
|
|
const char *primary;
|
2017-06-05 13:51:18 +02:00
|
|
|
NMBondMode bond_mode;
|
2020-02-19 16:47:36 +01:00
|
|
|
guint i;
|
|
|
|
|
const NMUtilsNamedValue *n;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2020-02-19 16:47:36 +01:00
|
|
|
_ensure_options_idx_cache (priv);
|
|
|
|
|
|
|
|
|
|
if (priv->options_idx_cache) {
|
|
|
|
|
for (i = 0; priv->options_idx_cache[i].name; i++) {
|
|
|
|
|
n = &priv->options_idx_cache[i];
|
|
|
|
|
|
|
|
|
|
if ( !n->value_str
|
|
|
|
|
|| !nm_setting_bond_validate_option (n->name, n->value_str)) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("invalid option '%s' or its value '%s'"),
|
|
|
|
|
n->name, n->value_str);
|
2020-02-21 11:41:07 +01:00
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2020-02-19 16:47:36 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-21 11:41:07 +01:00
|
|
|
miimon = _atoi (_bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_MIIMON));
|
|
|
|
|
arp_interval = _atoi (_bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_ARP_INTERVAL));
|
|
|
|
|
num_grat_arp = _atoi (_bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_NUM_GRAT_ARP));
|
|
|
|
|
num_unsol_na = _atoi (_bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_NUM_UNSOL_NA));
|
|
|
|
|
|
|
|
|
|
/* Option restrictions:
|
|
|
|
|
*
|
|
|
|
|
* arp_interval conflicts [ alb, tlb ]
|
|
|
|
|
* arp_interval needs arp_ip_target
|
|
|
|
|
* arp_validate does not work with [ BOND_MODE_8023AD, BOND_MODE_TLB, BOND_MODE_ALB ]
|
|
|
|
|
* downdelay needs miimon
|
|
|
|
|
* updelay needs miimon
|
|
|
|
|
* primary needs [ active-backup, tlb, alb ]
|
|
|
|
|
*/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-12-17 14:29:24 +01:00
|
|
|
/* Verify bond mode */
|
2020-02-21 11:41:07 +01:00
|
|
|
mode_orig = _bond_get_option (self, NM_SETTING_BOND_OPTION_MODE);
|
2016-03-18 16:08:54 +01:00
|
|
|
if (!mode_orig) {
|
2014-07-24 08:53:33 -04:00
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("mandatory option '%s' is missing"),
|
|
|
|
|
NM_SETTING_BOND_OPTION_MODE);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2016-03-18 16:08:54 +01:00
|
|
|
mode = nm_utils_bond_mode_string_to_int (mode_orig);
|
2014-12-17 14:29:24 +01:00
|
|
|
if (mode == -1) {
|
2014-07-24 08:53:33 -04:00
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("'%s' is not a valid value for '%s'"),
|
2020-02-21 11:41:07 +01:00
|
|
|
mode_orig,
|
|
|
|
|
NM_SETTING_BOND_OPTION_MODE);
|
|
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2016-03-18 16:08:54 +01:00
|
|
|
mode_new = nm_utils_bond_mode_int_to_string (mode);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/* Make sure mode is compatible with other settings */
|
2020-02-19 15:12:54 +01:00
|
|
|
if (NM_IN_STRSET (mode_new, "balance-alb",
|
|
|
|
|
"balance-tlb")) {
|
2014-07-24 08:53:33 -04:00
|
|
|
if (arp_interval > 0) {
|
|
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("'%s=%s' is incompatible with '%s > 0'"),
|
2020-02-21 11:41:07 +01:00
|
|
|
NM_SETTING_BOND_OPTION_MODE,
|
|
|
|
|
mode_new,
|
|
|
|
|
NM_SETTING_BOND_OPTION_ARP_INTERVAL);
|
|
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-21 11:41:07 +01:00
|
|
|
primary = _bond_get_option (self, NM_SETTING_BOND_OPTION_PRIMARY);
|
2020-02-19 15:12:54 +01:00
|
|
|
if (NM_IN_STRSET (mode_new, "active-backup")) {
|
2016-12-23 12:51:26 +01:00
|
|
|
GError *tmp_error = NULL;
|
|
|
|
|
|
2020-02-12 18:01:13 +01:00
|
|
|
if (primary && !nm_utils_ifname_valid_kernel (primary, &tmp_error)) {
|
2014-07-24 08:53:33 -04:00
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2017-08-11 11:05:12 +02:00
|
|
|
_("'%s' is not valid for the '%s' option: %s"),
|
2016-12-23 12:51:26 +01:00
|
|
|
primary, NM_SETTING_BOND_OPTION_PRIMARY, tmp_error->message);
|
2020-02-21 11:41:07 +01:00
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2016-12-23 12:51:26 +01:00
|
|
|
g_error_free (tmp_error);
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-02-21 11:41:07 +01:00
|
|
|
} else if (primary) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("'%s' option is only valid for '%s=%s'"),
|
|
|
|
|
NM_SETTING_BOND_OPTION_PRIMARY,
|
|
|
|
|
NM_SETTING_BOND_OPTION_MODE, "active-backup");
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
|
|
|
|
return FALSE;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2020-02-19 15:12:54 +01:00
|
|
|
if ( connection
|
|
|
|
|
&& nm_connection_get_setting_infiniband (connection)) {
|
|
|
|
|
if (!NM_IN_STRSET (mode_new, "active-backup")) {
|
2014-07-24 08:53:33 -04:00
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("'%s=%s' is not a valid configuration for '%s'"),
|
2016-03-18 16:08:54 +01:00
|
|
|
NM_SETTING_BOND_OPTION_MODE, mode_new, NM_SETTING_INFINIBAND_SETTING_NAME);
|
2020-02-21 11:41:07 +01:00
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (miimon == 0) {
|
2020-02-27 17:20:09 +01:00
|
|
|
/* updelay and downdelay need miimon to be enabled to be valid */
|
2020-02-21 11:41:07 +01:00
|
|
|
if (_atoi (_bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_UPDELAY))) {
|
2014-07-24 08:53:33 -04:00
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2020-02-27 17:20:09 +01:00
|
|
|
_("'%s' option requires '%s' option to be enabled"),
|
2014-07-24 08:53:33 -04:00
|
|
|
NM_SETTING_BOND_OPTION_UPDELAY, NM_SETTING_BOND_OPTION_MIIMON);
|
2020-02-21 11:41:07 +01:00
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-02-27 17:20:09 +01:00
|
|
|
|
2020-02-21 11:41:07 +01:00
|
|
|
if (_atoi (_bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_DOWNDELAY))) {
|
2014-07-24 08:53:33 -04:00
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2020-02-27 17:20:09 +01:00
|
|
|
_("'%s' option requires '%s' option to be enabled"),
|
2014-07-24 08:53:33 -04:00
|
|
|
NM_SETTING_BOND_OPTION_DOWNDELAY, NM_SETTING_BOND_OPTION_MIIMON);
|
2020-02-21 11:41:07 +01:00
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* arp_ip_target can only be used with arp_interval, and must
|
|
|
|
|
* contain a comma-separated list of IPv4 addresses.
|
|
|
|
|
*/
|
2020-02-21 11:41:07 +01:00
|
|
|
arp_ip_target = _bond_get_option (self, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
|
2014-07-24 08:53:33 -04:00
|
|
|
if (arp_interval > 0) {
|
|
|
|
|
char **addrs;
|
|
|
|
|
guint32 addr;
|
|
|
|
|
|
|
|
|
|
if (!arp_ip_target) {
|
|
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("'%s' option requires '%s' option to be set"),
|
2020-02-21 11:41:07 +01:00
|
|
|
NM_SETTING_BOND_OPTION_ARP_INTERVAL,
|
|
|
|
|
NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
|
|
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addrs = g_strsplit (arp_ip_target, ",", -1);
|
|
|
|
|
if (!addrs[0]) {
|
|
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("'%s' option is empty"),
|
|
|
|
|
NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
|
2020-02-21 11:41:07 +01:00
|
|
|
g_prefix_error (error, "%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
g_strfreev (addrs);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; addrs[i]; i++) {
|
|
|
|
|
if (!inet_pton (AF_INET, addrs[i], &addr)) {
|
|
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("'%s' is not a valid IPv4 address for '%s' option"),
|
2020-02-21 11:41:07 +01:00
|
|
|
NM_SETTING_BOND_OPTION_ARP_IP_TARGET,
|
|
|
|
|
addrs[i]);
|
|
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
g_strfreev (addrs);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_strfreev (addrs);
|
|
|
|
|
} else {
|
|
|
|
|
if (arp_ip_target) {
|
|
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("'%s' option requires '%s' option to be set"),
|
2020-02-21 11:41:07 +01:00
|
|
|
NM_SETTING_BOND_OPTION_ARP_IP_TARGET,
|
|
|
|
|
NM_SETTING_BOND_OPTION_ARP_INTERVAL);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-21 11:41:07 +01:00
|
|
|
lacp_rate = _bond_get_option (self, NM_SETTING_BOND_OPTION_LACP_RATE);
|
2014-08-23 00:48:50 +02:00
|
|
|
if ( lacp_rate
|
2020-02-19 15:12:54 +01:00
|
|
|
&& !nm_streq0 (mode_new, "802.3ad")
|
|
|
|
|
&& !NM_IN_STRSET (lacp_rate, "0", "slow")) {
|
2014-08-23 00:48:50 +02:00
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-08-23 00:48:50 +02:00
|
|
|
_("'%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);
|
2016-03-15 17:37:06 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-21 11:41:07 +01:00
|
|
|
if ( _bond_get_option (self, NM_SETTING_BOND_OPTION_NUM_GRAT_ARP)
|
|
|
|
|
&& _bond_get_option (self, NM_SETTING_BOND_OPTION_NUM_UNSOL_NA)
|
2020-02-20 15:38:01 +01:00
|
|
|
&& num_grat_arp != num_unsol_na) {
|
2016-03-15 17:37:06 +01:00
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("'%s' and '%s' cannot have different values"),
|
|
|
|
|
NM_SETTING_BOND_OPTION_NUM_GRAT_ARP,
|
|
|
|
|
NM_SETTING_BOND_OPTION_NUM_UNSOL_NA);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
2014-08-23 00:48:50 +02:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-17 15:02:58 +01:00
|
|
|
if (!_nm_connection_verify_required_interface_name (connection, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */
|
|
|
|
|
|
2020-02-19 15:12:54 +01:00
|
|
|
if (!nm_streq0 (mode_orig, mode_new)) {
|
2014-12-17 15:02:58 +01:00
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("'%s' option should be string"),
|
|
|
|
|
NM_SETTING_BOND_OPTION_MODE);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_BOND_SETTING_NAME, NM_SETTING_BOND_OPTIONS);
|
|
|
|
|
return NM_SETTING_VERIFY_NORMALIZABLE;
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-05 13:51:18 +02:00
|
|
|
/* normalize unsupported options for the current mode */
|
|
|
|
|
bond_mode = _nm_setting_bond_mode_from_string (mode_new);
|
2020-02-19 16:47:36 +01:00
|
|
|
for (i = 0; priv->options_idx_cache[i].name; i++) {
|
|
|
|
|
n = &priv->options_idx_cache[i];
|
|
|
|
|
if (!_nm_setting_bond_option_supported (n->name, bond_mode)) {
|
2017-06-05 13:51:18 +02:00
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("'%s' option is not valid with mode '%s'"),
|
2020-02-19 16:47:36 +01:00
|
|
|
n->name, mode_new);
|
2020-02-21 11:41:07 +01:00
|
|
|
g_prefix_error (error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_BOND_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BOND_OPTIONS);
|
2017-06-05 13:51:18 +02:00
|
|
|
return NM_SETTING_VERIFY_NORMALIZABLE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-17 15:02:58 +01:00
|
|
|
return TRUE;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2017-11-21 13:07:42 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-03-18 16:28:38 +01:00
|
|
|
static gboolean
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
options_equal_asym (NMSettingBond *s_bond,
|
|
|
|
|
NMSettingBond *s_bond2,
|
2016-09-22 18:15:19 +02:00
|
|
|
NMSettingCompareFlags flags)
|
2016-03-18 16:28:38 +01:00
|
|
|
{
|
|
|
|
|
GHashTableIter iter;
|
|
|
|
|
const char *key, *value, *value2;
|
|
|
|
|
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
g_hash_table_iter_init (&iter, NM_SETTING_BOND_GET_PRIVATE (s_bond)->options);
|
2016-03-18 16:28:38 +01:00
|
|
|
while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) {
|
2016-09-22 18:15:19 +02:00
|
|
|
|
|
|
|
|
if (NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) {
|
|
|
|
|
/* when doing an inferrable match, the active-slave should be ignored
|
|
|
|
|
* as it might be differ from the setting in the connection.
|
|
|
|
|
*
|
|
|
|
|
* Also, the fail_over_mac setting can change, see for example
|
|
|
|
|
* https://bugzilla.redhat.com/show_bug.cgi?id=1375558#c8 */
|
|
|
|
|
if (NM_IN_STRSET (key, "fail_over_mac", "active_slave"))
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-21 11:41:07 +01:00
|
|
|
value2 = _bond_get_option (s_bond2, key);
|
2016-03-18 16:28:38 +01:00
|
|
|
|
|
|
|
|
if (!value2) {
|
|
|
|
|
if (nm_streq (key, "num_grat_arp"))
|
2020-02-21 11:41:07 +01:00
|
|
|
value2 = _bond_get_option (s_bond2, "num_unsol_na");
|
2016-03-18 16:28:38 +01:00
|
|
|
else if (nm_streq (key, "num_unsol_na"))
|
2020-02-21 11:41:07 +01:00
|
|
|
value2 = _bond_get_option (s_bond2, "num_grat_arp");
|
2016-03-18 16:28:38 +01:00
|
|
|
}
|
|
|
|
|
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
if (!value2)
|
2020-02-21 11:41:07 +01:00
|
|
|
value2 = _bond_get_option_default (s_bond2, key);
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
if (!nm_streq (value, value2))
|
|
|
|
|
return FALSE;
|
2016-03-18 16:28:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2016-09-22 18:15:19 +02:00
|
|
|
options_equal (NMSettingBond *s_bond,
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
NMSettingBond *s_bond2,
|
2016-09-22 18:15:19 +02:00
|
|
|
NMSettingCompareFlags flags)
|
2016-03-18 16:28:38 +01:00
|
|
|
{
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
return options_equal_asym (s_bond, s_bond2, flags)
|
|
|
|
|
&& options_equal_asym (s_bond2, s_bond, flags);
|
2016-03-18 16:28:38 +01:00
|
|
|
}
|
|
|
|
|
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
static NMTernary
|
|
|
|
|
compare_property (const NMSettInfoSetting *sett_info,
|
|
|
|
|
guint property_idx,
|
2019-04-25 10:17:47 +02:00
|
|
|
NMConnection *con_a,
|
|
|
|
|
NMSetting *set_a,
|
|
|
|
|
NMConnection *con_b,
|
|
|
|
|
NMSetting *set_b,
|
2016-03-18 16:28:38 +01:00
|
|
|
NMSettingCompareFlags flags)
|
|
|
|
|
{
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
if (nm_streq (sett_info->property_infos[property_idx].name, NM_SETTING_BOND_OPTIONS)) {
|
2019-04-25 10:17:47 +02:00
|
|
|
return ( !set_b
|
|
|
|
|
|| options_equal (NM_SETTING_BOND (set_a),
|
|
|
|
|
NM_SETTING_BOND (set_b),
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
flags));
|
2016-03-18 16:28:38 +01:00
|
|
|
}
|
|
|
|
|
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
return NM_SETTING_CLASS (nm_setting_bond_parent_class)->compare_property (sett_info,
|
|
|
|
|
property_idx,
|
2019-04-25 10:17:47 +02:00
|
|
|
con_a,
|
|
|
|
|
set_a,
|
|
|
|
|
con_b,
|
|
|
|
|
set_b,
|
libnm: rework compare_property() implementation for NMSetting
NMSetting's compare_property() has and had two callers:
nm_setting_compare() and nm_setting_diff().
compare_property() accepts a NMSettingCompareFlags argument, but
at the same time, both callers have another complex (and
inconsistent!) set of pre-checks for shortcuting the call of
compare_property(): should_compare_prop().
Merge should_compare_prop() into compare_property(). This way,
nm_setting_compare() and nm_setting_diff() has less additional
code, and are simpler to follow. Especially nm_setting_compare()
is now trivial. And nm_setting_diff() is still complicated, but
not related to the question how the property compares or whether
it should be compared at all.
If you want to know whether it should be compared, all you need to do
now is follow NMSettingClass.compare_property().
This changes function pointer NMSettingClass.compare_property(),
which is public API. However, no user can actually use this (and shall
not!), because _nm_setting_class_commit_full() etc. is private API. A
user outside of libnm-core cannot create his/her own subclasses of
NMSetting, and never could in the past. So, this API/ABI change doesn't
matter.
2019-01-09 09:08:39 +01:00
|
|
|
flags);
|
2016-03-18 16:28:38 +01:00
|
|
|
}
|
|
|
|
|
|
2017-11-21 13:07:42 +01:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
static void
|
2017-11-21 13:07:42 +01:00
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object);
|
|
|
|
|
|
2017-11-21 13:07:42 +01:00
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_OPTIONS:
|
|
|
|
|
g_value_take_boxed (value, _nm_utils_copy_strdict (priv->options));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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_OPTIONS:
|
2017-11-21 14:01:02 +01:00
|
|
|
nm_clear_g_free (&priv->options_idx_cache);
|
2014-06-24 17:40:08 -04:00
|
|
|
g_hash_table_unref (priv->options);
|
|
|
|
|
priv->options = _nm_utils_copy_strdict (g_value_get_boxed (value));
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-21 13:07:42 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
2017-11-21 13:07:42 +01:00
|
|
|
nm_setting_bond_init (NMSettingBond *setting)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
priv->options = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free);
|
|
|
|
|
|
|
|
|
|
/* Default values: */
|
|
|
|
|
nm_setting_bond_add_option (setting, NM_SETTING_BOND_OPTION_MODE, "balance-rr");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object);
|
|
|
|
|
|
2017-11-21 14:01:02 +01:00
|
|
|
nm_clear_g_free (&priv->options_idx_cache);
|
2017-11-21 13:07:42 +01:00
|
|
|
g_hash_table_destroy (priv->options);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_setting_bond_parent_class)->finalize (object);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
nm_setting_bond_class_init (NMSettingBondClass *klass)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
NMSettingClass *setting_class = NM_SETTING_CLASS (klass);
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
GArray *properties_override = _nm_sett_info_property_override_create_array ();
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
g_type_class_add_private (klass, sizeof (NMSettingBondPrivate));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2016-03-18 16:28:38 +01:00
|
|
|
object_class->get_property = get_property;
|
2019-01-11 08:32:54 +01:00
|
|
|
object_class->set_property = set_property;
|
2016-03-18 16:28:38 +01:00
|
|
|
object_class->finalize = finalize;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
setting_class->verify = verify;
|
|
|
|
|
setting_class->compare_property = compare_property;
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
2015-02-10 12:24:25 +01:00
|
|
|
* NMSettingBond:options: (type GHashTable(utf8,utf8)):
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
|
|
|
|
* Dictionary of key/value pairs of bonding options. Both keys and values
|
|
|
|
|
* must be strings. Option names must contain only alphanumeric characters
|
|
|
|
|
* (ie, [a-zA-Z0-9]).
|
|
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: options
|
|
|
|
|
* variable: BONDING_OPTS
|
|
|
|
|
* description: Bonding options.
|
|
|
|
|
* example: BONDING_OPTS="miimon=100 mode=broadcast"
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_OPTIONS] =
|
|
|
|
|
g_param_spec_boxed (NM_SETTING_BOND_OPTIONS, "", "",
|
|
|
|
|
G_TYPE_HASH_TABLE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2019-09-22 15:32:04 +02:00
|
|
|
_nm_properties_override_gobj (properties_override, obj_properties[PROP_OPTIONS], &nm_sett_info_propert_type_strdict);
|
2014-08-04 19:57:20 -04:00
|
|
|
|
2014-11-16 15:36:18 -05:00
|
|
|
/* ---dbus---
|
|
|
|
|
* property: interface-name
|
|
|
|
|
* format: string
|
|
|
|
|
* description: Deprecated in favor of connection.interface-name, but can
|
|
|
|
|
* be used for backward-compatibility with older daemons, to set the
|
|
|
|
|
* bond's interface name.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-09-22 15:32:04 +02:00
|
|
|
_nm_properties_override_dbus (properties_override, "interface-name", &nm_sett_info_propert_type_deprecated_interface_name);
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
|
2019-01-11 08:28:26 +01:00
|
|
|
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
|
|
|
|
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
_nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_BOND,
|
|
|
|
|
NULL, properties_override);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|