2019-09-10 11:19:01 +02:00
|
|
|
// SPDX-License-Identifier: LGPL-2.1+
|
2015-09-17 18:13:49 +02:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2015 Red Hat, Inc.
|
2015-09-17 18:13:49 +02:00
|
|
|
*/
|
|
|
|
|
|
2016-02-19 14:57:48 +01:00
|
|
|
#include "nm-default.h"
|
2015-09-17 18:13:49 +02:00
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
#include "nm-setting-macvlan.h"
|
|
|
|
|
|
2015-09-17 18:13:49 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "nm-utils.h"
|
|
|
|
|
#include "nm-setting-connection.h"
|
|
|
|
|
#include "nm-setting-private.h"
|
|
|
|
|
#include "nm-setting-wired.h"
|
|
|
|
|
#include "nm-connection-private.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:nm-setting-macvlan
|
|
|
|
|
* @short_description: Describes connection properties for macvlan interfaces
|
|
|
|
|
*
|
|
|
|
|
* The #NMSettingMacvlan object is a #NMSetting subclass that describes properties
|
|
|
|
|
* necessary for connection to macvlan interfaces.
|
|
|
|
|
**/
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
2015-09-17 18:13:49 +02:00
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
NM_GOBJECT_PROPERTIES_DEFINE_BASE (
|
|
|
|
|
PROP_PARENT,
|
|
|
|
|
PROP_MODE,
|
|
|
|
|
PROP_PROMISCUOUS,
|
|
|
|
|
PROP_TAP,
|
|
|
|
|
);
|
2015-09-17 18:13:49 +02:00
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
char *parent;
|
|
|
|
|
NMSettingMacvlanMode mode;
|
|
|
|
|
gboolean promiscuous;
|
|
|
|
|
gboolean tap;
|
|
|
|
|
} NMSettingMacvlanPrivate;
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
G_DEFINE_TYPE (NMSettingMacvlan, nm_setting_macvlan, NM_TYPE_SETTING)
|
2015-09-17 18:13:49 +02:00
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
#define NM_SETTING_MACVLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_MACVLAN, NMSettingMacvlanPrivate))
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2015-09-17 18:13:49 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_macvlan_get_parent:
|
|
|
|
|
* @setting: the #NMSettingMacvlan
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingMacvlan:parent property of the setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_macvlan_get_parent (NMSettingMacvlan *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_MACVLAN (setting), NULL);
|
|
|
|
|
return NM_SETTING_MACVLAN_GET_PRIVATE (setting)->parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_macvlan_get_mode:
|
|
|
|
|
* @setting: the #NMSettingMacvlan
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingMacvlan:mode property of the setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
NMSettingMacvlanMode
|
|
|
|
|
nm_setting_macvlan_get_mode (NMSettingMacvlan *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_MACVLAN (setting), NM_SETTING_MACVLAN_MODE_UNKNOWN);
|
|
|
|
|
return NM_SETTING_MACVLAN_GET_PRIVATE (setting)->mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_macvlan_get_promiscuous:
|
|
|
|
|
* @setting: the #NMSettingMacvlan
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingMacvlan:promiscuous property of the setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_macvlan_get_promiscuous (NMSettingMacvlan *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_MACVLAN (setting), FALSE);
|
|
|
|
|
return NM_SETTING_MACVLAN_GET_PRIVATE (setting)->promiscuous;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_macvlan_get_tap:
|
|
|
|
|
* @setting: the #NMSettingMacvlan
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingMacvlan:tap property of the setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_macvlan_get_tap (NMSettingMacvlan *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_MACVLAN (setting), FALSE);
|
|
|
|
|
return NM_SETTING_MACVLAN_GET_PRIVATE (setting)->tap;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2015-09-17 18:13:49 +02:00
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE (setting);
|
|
|
|
|
NMSettingWired *s_wired;
|
|
|
|
|
|
2017-12-18 08:36:51 +01:00
|
|
|
if (connection)
|
2015-09-17 18:13:49 +02:00
|
|
|
s_wired = nm_connection_get_setting_wired (connection);
|
2017-12-18 08:36:51 +01:00
|
|
|
else
|
2015-09-17 18:13:49 +02:00
|
|
|
s_wired = NULL;
|
|
|
|
|
|
|
|
|
|
if (priv->parent) {
|
|
|
|
|
if ( !nm_utils_is_uuid (priv->parent)
|
2016-12-23 12:51:26 +01:00
|
|
|
&& !nm_utils_is_valid_iface_name (priv->parent, NULL)) {
|
2015-09-17 18:13:49 +02:00
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("'%s' is neither an UUID nor an interface name"),
|
|
|
|
|
priv->parent);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_MACVLAN_SETTING_NAME, NM_SETTING_MACVLAN_PARENT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* If parent is NULL, the parent must be specified via
|
|
|
|
|
* NMSettingWired:mac-address.
|
|
|
|
|
*/
|
|
|
|
|
if ( connection
|
|
|
|
|
&& (!s_wired || !nm_setting_wired_get_mac_address (s_wired))) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_MISSING_PROPERTY,
|
|
|
|
|
_("property is not specified and neither is '%s:%s'"),
|
|
|
|
|
NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_MACVLAN_SETTING_NAME, NM_SETTING_MACVLAN_PARENT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!priv->promiscuous && priv->mode != NM_SETTING_MACVLAN_MODE_PASSTHRU) {
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2016-03-30 00:26:21 +02:00
|
|
|
_("non promiscuous operation is allowed only in passthru mode"));
|
2015-09-17 18:13:49 +02:00
|
|
|
g_prefix_error (error, "%s.%s: ",
|
|
|
|
|
NM_SETTING_MACVLAN_SETTING_NAME,
|
|
|
|
|
NM_SETTING_MACVLAN_PROMISCUOUS);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-09-17 18:13:49 +02:00
|
|
|
static void
|
2019-01-11 08:32:54 +01:00
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
2015-09-17 18:13:49 +02:00
|
|
|
{
|
|
|
|
|
NMSettingMacvlan *setting = NM_SETTING_MACVLAN (object);
|
|
|
|
|
NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_PARENT:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_string (value, priv->parent);
|
2015-09-17 18:13:49 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_MODE:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint (value, priv->mode);
|
2015-09-17 18:13:49 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_PROMISCUOUS:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_boolean (value, priv->promiscuous);
|
2015-09-17 18:13:49 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_TAP:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_boolean (value, priv->tap);
|
2015-09-17 18:13:49 +02:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-11 08:32:54 +01:00
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
2015-09-17 18:13:49 +02:00
|
|
|
{
|
|
|
|
|
NMSettingMacvlan *setting = NM_SETTING_MACVLAN (object);
|
|
|
|
|
NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_PARENT:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_free (priv->parent);
|
|
|
|
|
priv->parent = g_value_dup_string (value);
|
2015-09-17 18:13:49 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_MODE:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->mode = g_value_get_uint (value);
|
2015-09-17 18:13:49 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_PROMISCUOUS:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->promiscuous = g_value_get_boolean (value);
|
2015-09-17 18:13:49 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_TAP:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->tap = g_value_get_boolean (value);
|
2015-09-17 18:13:49 +02:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_setting_macvlan_init (NMSettingMacvlan *setting)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_macvlan_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #NMSettingMacvlan object with default values.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new empty #NMSettingMacvlan object
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
NMSetting *
|
|
|
|
|
nm_setting_macvlan_new (void)
|
|
|
|
|
{
|
|
|
|
|
return (NMSetting *) g_object_new (NM_TYPE_SETTING_MACVLAN, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-17 18:13:49 +02:00
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMSettingMacvlan *setting = NM_SETTING_MACVLAN (object);
|
|
|
|
|
NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_free (priv->parent);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_setting_macvlan_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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_macvlan_class_init (NMSettingMacvlanClass *klass)
|
2015-09-17 18:13:49 +02: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);
|
2015-09-17 18:13:49 +02: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 (NMSettingMacvlanPrivate));
|
2015-09-17 18:13:49 +02:00
|
|
|
|
|
|
|
|
object_class->get_property = get_property;
|
2019-01-11 08:32:54 +01:00
|
|
|
object_class->set_property = set_property;
|
2015-09-17 18:13:49 +02:00
|
|
|
object_class->finalize = finalize;
|
|
|
|
|
|
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
|
|
|
setting_class->verify = verify;
|
2015-09-17 18:13:49 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingMacvlan:parent:
|
|
|
|
|
*
|
|
|
|
|
* If given, specifies the parent interface name or parent connection UUID
|
|
|
|
|
* from which this MAC-VLAN interface should be created. If this property is
|
|
|
|
|
* not specified, the connection must contain an #NMSettingWired setting
|
|
|
|
|
* with a #NMSettingWired:mac-address property.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_PARENT] =
|
|
|
|
|
g_param_spec_string (NM_SETTING_MACVLAN_PARENT, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2015-09-17 18:13:49 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingMacvlan:mode:
|
|
|
|
|
*
|
|
|
|
|
* The macvlan mode, which specifies the communication mechanism between multiple
|
|
|
|
|
* macvlans on the same lower device.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_MODE] =
|
|
|
|
|
g_param_spec_uint (NM_SETTING_MACVLAN_MODE, "", "",
|
|
|
|
|
0, G_MAXUINT, 0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2015-09-17 18:13:49 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingMacvlan:promiscuous:
|
|
|
|
|
*
|
|
|
|
|
* Whether the interface should be put in promiscuous mode.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_PROMISCUOUS] =
|
|
|
|
|
g_param_spec_boolean (NM_SETTING_MACVLAN_PROMISCUOUS, "", "",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2015-09-17 18:13:49 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingMacvlan:tap:
|
|
|
|
|
*
|
|
|
|
|
* Whether the interface should be a MACVTAP.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_TAP] =
|
|
|
|
|
g_param_spec_boolean (NM_SETTING_MACVLAN_TAP, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
|
|
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 (setting_class, NM_META_SETTING_TYPE_MACVLAN);
|
2015-09-17 18:13:49 +02:00
|
|
|
}
|