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 - 2014 Red Hat, Inc.
|
2014-07-24 08:53:33 -04:00
|
|
|
*/
|
|
|
|
|
|
2016-02-12 14:44:52 +01:00
|
|
|
#include "nm-default.h"
|
2016-02-19 14:57:48 +01:00
|
|
|
|
2016-02-12 14:44:52 +01:00
|
|
|
#include "nm-setting-vlan.h"
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-core
"libnm-core" implements common functionality for "NetworkManager" and
"libnm".
Note that clients like "nmcli" cannot access the internal API provided
by "libnm-core". So, if nmcli wants to do something that is also done by
"libnm-core", , "libnm", or "NetworkManager", the code would have to be
duplicated.
Instead, such code can be in "libnm-libnm-core-{intern|aux}.la".
Note that:
0) "libnm-libnm-core-intern.la" is used by libnm-core itsself.
On the other hand, "libnm-libnm-core-aux.la" is not used by
libnm-core, but provides utilities on top of it.
1) they both extend "libnm-core" with utlities that are not public
API of libnm itself. Maybe part of the code should one day become
public API of libnm. On the other hand, this is code for which
we may not want to commit to a stable interface or which we
don't want to provide as part of the API.
2) "libnm-libnm-core-intern.la" is statically linked by "libnm-core"
and thus directly available to "libnm" and "NetworkManager".
On the other hand, "libnm-libnm-core-aux.la" may be used by "libnm"
and "NetworkManager".
Both libraries may be statically linked by libnm clients (like
nmcli).
3) it must only use glib, libnm-glib-aux.la, and the public API
of libnm-core.
This is important: it must not use "libnm-core/nm-core-internal.h"
nor "libnm-core/nm-utils-private.h" so the static library is usable
by nmcli which couldn't access these.
Note that "shared/nm-meta-setting.c" is an entirely different case,
because it behaves differently depending on whether linking against
"libnm-core" or the client programs. As such, this file must be compiled
twice.
(cherry picked from commit af07ed01c04867e281cc3982a7ab0d244d4f8e2e)
2019-04-15 09:26:53 +02:00
|
|
|
#include "nm-libnm-core-intern/nm-libnm-core-utils.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
#include "nm-utils.h"
|
2015-10-30 11:09:41 +01:00
|
|
|
#include "nm-core-types-internal.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
#include "nm-setting-connection.h"
|
|
|
|
|
#include "nm-setting-private.h"
|
2014-10-21 22:09:52 -04:00
|
|
|
#include "nm-setting-wired.h"
|
2014-10-21 22:30:31 -04:00
|
|
|
#include "nm-connection-private.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:nm-setting-vlan
|
|
|
|
|
* @short_description: Describes connection properties for VLAN interfaces
|
|
|
|
|
*
|
|
|
|
|
* The #NMSettingVlan object is a #NMSetting subclass that describes properties
|
|
|
|
|
* necessary for connection to VLAN interfaces.
|
|
|
|
|
**/
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
NM_GOBJECT_PROPERTIES_DEFINE (NMSettingVlan,
|
|
|
|
|
PROP_PARENT,
|
|
|
|
|
PROP_ID,
|
|
|
|
|
PROP_FLAGS,
|
|
|
|
|
PROP_INGRESS_PRIORITY_MAP,
|
|
|
|
|
PROP_EGRESS_PRIORITY_MAP,
|
|
|
|
|
);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
char *parent;
|
|
|
|
|
guint32 id;
|
|
|
|
|
guint32 flags;
|
|
|
|
|
GSList *ingress_priority_map;
|
|
|
|
|
GSList *egress_priority_map;
|
|
|
|
|
} NMSettingVlanPrivate;
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
G_DEFINE_TYPE (NMSettingVlan, nm_setting_vlan, NM_TYPE_SETTING)
|
|
|
|
|
|
|
|
|
|
#define NM_SETTING_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_VLAN, NMSettingVlanPrivate))
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
#define MAX_SKB_PRIO G_MAXUINT32
|
|
|
|
|
#define MAX_8021P_PRIO 7 /* Max 802.1p priority */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_get_parent:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingVlan:parent property of the setting
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_vlan_get_parent (NMSettingVlan *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), NULL);
|
|
|
|
|
return NM_SETTING_VLAN_GET_PRIVATE (setting)->parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_get_id:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingVlan:id property of the setting
|
|
|
|
|
**/
|
|
|
|
|
guint32
|
|
|
|
|
nm_setting_vlan_get_id (NMSettingVlan *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), 0);
|
|
|
|
|
return NM_SETTING_VLAN_GET_PRIVATE (setting)->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_get_flags:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingVlan:flags property of the setting
|
|
|
|
|
**/
|
|
|
|
|
guint32
|
|
|
|
|
nm_setting_vlan_get_flags (NMSettingVlan *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), 0);
|
|
|
|
|
return NM_SETTING_VLAN_GET_PRIVATE (setting)->flags;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-16 13:43:17 +01:00
|
|
|
static NMVlanQosMapping *
|
|
|
|
|
priority_map_new (guint32 from, guint32 to)
|
|
|
|
|
{
|
|
|
|
|
NMVlanQosMapping *mapping;
|
|
|
|
|
|
|
|
|
|
mapping = g_new (NMVlanQosMapping, 1);
|
|
|
|
|
*mapping = (NMVlanQosMapping) {
|
|
|
|
|
.from = from,
|
|
|
|
|
.to = to,
|
|
|
|
|
};
|
|
|
|
|
return mapping;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NMVlanQosMapping *
|
|
|
|
|
priority_map_new_from_str (NMVlanPriorityMap map, const char *str)
|
|
|
|
|
{
|
|
|
|
|
guint32 from, to;
|
|
|
|
|
|
2019-03-17 12:21:00 +01:00
|
|
|
if (!nm_utils_vlan_priority_map_parse_str (map, str, FALSE, &from, &to, NULL))
|
2019-03-16 13:43:17 +01:00
|
|
|
return NULL;
|
|
|
|
|
return priority_map_new (from, to);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2015-10-30 11:09:41 +01:00
|
|
|
priority_map_free (NMVlanQosMapping *map)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2019-03-16 13:43:17 +01:00
|
|
|
nm_assert (map);
|
2014-07-24 08:53:33 -04:00
|
|
|
g_free (map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GSList *
|
|
|
|
|
get_map (NMSettingVlan *self, NMVlanPriorityMap map)
|
|
|
|
|
{
|
|
|
|
|
if (map == NM_VLAN_INGRESS_MAP)
|
|
|
|
|
return NM_SETTING_VLAN_GET_PRIVATE (self)->ingress_priority_map;
|
|
|
|
|
else if (map == NM_VLAN_EGRESS_MAP)
|
|
|
|
|
return NM_SETTING_VLAN_GET_PRIVATE (self)->egress_priority_map;
|
2019-03-16 14:03:26 +01:00
|
|
|
nm_assert_not_reached ();
|
2014-07-24 08:53:33 -04:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
all: don't use gchar/gshort/gint/glong but C types
We commonly don't use the glib typedefs for char/short/int/long,
but their C types directly.
$ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
587
$ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
21114
One could argue that using the glib typedefs is preferable in
public API (of our glib based libnm library) or where it clearly
is related to glib, like during
g_object_set (obj, PROPERTY, (gint) value, NULL);
However, that argument does not seem strong, because in practice we don't
follow that argument today, and seldomly use the glib typedefs.
Also, the style guide for this would be hard to formalize, because
"using them where clearly related to a glib" is a very loose suggestion.
Also note that glib typedefs will always just be typedefs of the
underlying C types. There is no danger of glib changing the meaning
of these typedefs (because that would be a major API break of glib).
A simple style guide is instead: don't use these typedefs.
No manual actions, I only ran the bash script:
FILES=($(git ls-files '*.[hc]'))
sed -i \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \
-e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
"${FILES[@]}"
2018-07-11 07:40:19 +02:00
|
|
|
static int
|
2015-10-30 12:07:37 +01:00
|
|
|
prio_map_compare (gconstpointer p_a, gconstpointer p_b)
|
2015-10-12 16:06:05 +02:00
|
|
|
{
|
2015-10-30 12:07:37 +01:00
|
|
|
const NMVlanQosMapping *a = p_a;
|
|
|
|
|
const NMVlanQosMapping *b = p_b;
|
|
|
|
|
|
2015-10-12 16:06:05 +02:00
|
|
|
return a->from < b->from
|
|
|
|
|
? -1
|
|
|
|
|
: (a->from > b->from
|
|
|
|
|
? 1
|
|
|
|
|
: (a->to < b->to ? -1 : (a->to > b->to ? 1 : 0)));
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
|
|
|
|
set_map (NMSettingVlan *self, NMVlanPriorityMap map, GSList *list)
|
|
|
|
|
{
|
2015-10-30 12:07:37 +01:00
|
|
|
/* Assert that the list is sorted */
|
|
|
|
|
#if NM_MORE_ASSERTS >= 2
|
|
|
|
|
{
|
|
|
|
|
GSList *iter, *last;
|
|
|
|
|
|
|
|
|
|
last = list;
|
|
|
|
|
iter = list ? list->next : NULL;
|
|
|
|
|
while (iter) {
|
|
|
|
|
const NMVlanQosMapping *l = last->data;
|
|
|
|
|
const NMVlanQosMapping *m = iter->data;
|
|
|
|
|
|
|
|
|
|
nm_assert (prio_map_compare (last->data, iter->data) < 0);
|
|
|
|
|
|
|
|
|
|
/* Also reject duplicates (based on "from") */
|
|
|
|
|
nm_assert (l->from < m->from);
|
|
|
|
|
|
|
|
|
|
last = iter;
|
|
|
|
|
iter = iter->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2015-10-12 16:06:05 +02:00
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
if (map == NM_VLAN_INGRESS_MAP) {
|
|
|
|
|
NM_SETTING_VLAN_GET_PRIVATE (self)->ingress_priority_map = list;
|
2019-01-11 08:28:26 +01:00
|
|
|
_notify (self, PROP_INGRESS_PRIORITY_MAP);
|
2014-07-24 08:53:33 -04:00
|
|
|
} else if (map == NM_VLAN_EGRESS_MAP) {
|
|
|
|
|
NM_SETTING_VLAN_GET_PRIVATE (self)->egress_priority_map = list;
|
2019-01-11 08:28:26 +01:00
|
|
|
_notify (self, PROP_EGRESS_PRIORITY_MAP);
|
2014-07-24 08:53:33 -04:00
|
|
|
} else
|
2019-03-16 14:03:26 +01:00
|
|
|
nm_assert_not_reached ();
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2015-10-12 15:33:43 +02:00
|
|
|
static gboolean
|
|
|
|
|
check_replace_duplicate_priority (GSList *list, guint32 from, guint32 to)
|
|
|
|
|
{
|
|
|
|
|
GSList *iter;
|
2015-10-30 11:09:41 +01:00
|
|
|
NMVlanQosMapping *p;
|
2015-10-12 15:33:43 +02:00
|
|
|
|
|
|
|
|
for (iter = list; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
p = iter->data;
|
|
|
|
|
if (p->from == from) {
|
|
|
|
|
p->to = to;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_add_priority_str:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
* @map: the type of priority map
|
|
|
|
|
* @str: the string which contains a priority map, like "3:7"
|
|
|
|
|
*
|
|
|
|
|
* Adds a priority map entry into either the #NMSettingVlan:ingress_priority_map
|
|
|
|
|
* or the #NMSettingVlan:egress_priority_map properties. The priority map maps
|
|
|
|
|
* the Linux SKB priorities to 802.1p priorities.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the entry was successfully added to the list, or it
|
2019-08-02 08:46:38 +02:00
|
|
|
* overwrote the old value, %FALSE if @str is not a valid mapping.
|
2014-07-24 08:53:33 -04:00
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_vlan_add_priority_str (NMSettingVlan *setting,
|
|
|
|
|
NMVlanPriorityMap map,
|
|
|
|
|
const char *str)
|
|
|
|
|
{
|
2015-10-12 15:33:43 +02:00
|
|
|
GSList *list = NULL;
|
2015-10-30 11:09:41 +01:00
|
|
|
NMVlanQosMapping *item = NULL;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
|
|
|
|
|
g_return_val_if_fail (str && str[0], FALSE);
|
|
|
|
|
|
|
|
|
|
item = priority_map_new_from_str (map, str);
|
libnm-core: mute coverity for RESOURCE_LEAK (CWE-772) in g_return_val_if_fail()
Error: RESOURCE_LEAK (CWE-772): [#def10]
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:225: alloc_fn: Storage is returned from allocation function "priority_map_new_from_str".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:154:4: alloc_fn: Storage is returned from allocation function "g_malloc0".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:154:4: var_assign: Assigning: "p" = "g_malloc0(8UL)".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:164:2: return_alloc: Returning allocated memory "p".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:225: var_assign: Assigning: "item" = storage returned from "priority_map_new_from_str(map, str)".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:226: leaked_storage: Variable "item" going out of scope leaks the storage it points to.
Error: RESOURCE_LEAK (CWE-772): [#def11]
NetworkManager-0.9.11.0/libnm-core/nm-utils.c:2056: alloc_fn: Storage is returned from allocation function "crypto_make_des_aes_key".
NetworkManager-0.9.11.0/libnm-core/crypto.c:405:2: alloc_fn: Storage is returned from allocation function "g_malloc0".
NetworkManager-0.9.11.0/libnm-core/crypto.c:405:2: var_assign: Assigning: "key" = "g_malloc0(digest_len + 1U)".
NetworkManager-0.9.11.0/libnm-core/crypto.c:407:2: noescape: Resource "key" is not freed or pointed-to in function "crypto_md5_hash".
NetworkManager-0.9.11.0/libnm-core/crypto.c:769:24: noescape: "crypto_md5_hash(char const *, gssize, char const *, gssize, char *, gsize)" does not free or save its pointer parameter "buffer".
NetworkManager-0.9.11.0/libnm-core/crypto.c:415:2: return_alloc: Returning allocated memory "key".
NetworkManager-0.9.11.0/libnm-core/nm-utils.c:2056: var_assign: Assigning: "key" = storage returned from "crypto_make_des_aes_key("DES-EDE3-CBC", &salt[0], salt_len, in_password, &key_len, NULL)".
NetworkManager-0.9.11.0/libnm-core/nm-utils.c:2057: leaked_storage: Variable "key" going out of scope leaks the storage it points to.
2014-12-12 14:31:27 +01:00
|
|
|
if (!item)
|
2019-08-02 08:46:38 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
list = get_map (setting, map);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/* Duplicates get replaced */
|
2015-10-12 15:33:43 +02:00
|
|
|
if (check_replace_duplicate_priority (list, item->from, item->to)) {
|
|
|
|
|
g_free (item);
|
|
|
|
|
if (map == NM_VLAN_INGRESS_MAP)
|
2019-01-11 08:28:26 +01:00
|
|
|
_notify (setting, PROP_INGRESS_PRIORITY_MAP);
|
2015-10-12 15:33:43 +02:00
|
|
|
else
|
2019-01-11 08:28:26 +01:00
|
|
|
_notify (setting, PROP_EGRESS_PRIORITY_MAP);
|
2015-10-12 15:33:43 +02:00
|
|
|
return TRUE;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2015-10-30 12:07:37 +01:00
|
|
|
set_map (setting, map, g_slist_insert_sorted (list, item, prio_map_compare));
|
2014-07-24 08:53:33 -04:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_get_num_priorities:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
* @map: the type of priority map
|
|
|
|
|
*
|
2017-05-05 14:11:05 +02:00
|
|
|
* Returns the number of entries in the
|
2014-07-24 08:53:33 -04:00
|
|
|
* #NMSettingVlan:ingress_priority_map or #NMSettingVlan:egress_priority_map
|
|
|
|
|
* properties of this setting.
|
|
|
|
|
*
|
2019-08-02 08:46:38 +02:00
|
|
|
* Returns: return the number of ingress/egress priority entries.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
gint32
|
|
|
|
|
nm_setting_vlan_get_num_priorities (NMSettingVlan *setting, NMVlanPriorityMap map)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), -1);
|
|
|
|
|
g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, -1);
|
|
|
|
|
|
|
|
|
|
return g_slist_length (get_map (setting, map));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_get_priority:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
* @map: the type of priority map
|
|
|
|
|
* @idx: the zero-based index of the ingress/egress priority map entry
|
2019-08-02 08:46:38 +02:00
|
|
|
* @out_from: (out) (allow-none): on return the value of the priority map's 'from' item
|
|
|
|
|
* @out_to: (out) (allow-none): on return the value of priority map's 'to' item
|
2014-07-24 08:53:33 -04:00
|
|
|
*
|
|
|
|
|
* Retrieve one of the entries of the #NMSettingVlan:ingress_priority_map
|
|
|
|
|
* or #NMSettingVlan:egress_priority_map properties of this setting.
|
|
|
|
|
*
|
2019-08-02 08:46:38 +02:00
|
|
|
* Returns: returns %TRUE if @idx is in range. Otherwise %FALSE.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_vlan_get_priority (NMSettingVlan *setting,
|
|
|
|
|
NMVlanPriorityMap map,
|
|
|
|
|
guint32 idx,
|
|
|
|
|
guint32 *out_from,
|
|
|
|
|
guint32 *out_to)
|
|
|
|
|
{
|
2019-08-02 08:46:38 +02:00
|
|
|
NMVlanQosMapping *item;
|
|
|
|
|
GSList *list;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
|
2019-08-02 08:46:38 +02:00
|
|
|
g_return_val_if_fail (NM_IN_SET (map, NM_VLAN_INGRESS_MAP, NM_VLAN_EGRESS_MAP), FALSE);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
list = get_map (setting, map);
|
|
|
|
|
item = g_slist_nth_data (list, idx);
|
2019-08-02 08:46:38 +02:00
|
|
|
|
|
|
|
|
if (!item) {
|
|
|
|
|
NM_SET_OUT (out_from, 0);
|
|
|
|
|
NM_SET_OUT (out_to, 0);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NM_SET_OUT (out_from, item->from);
|
|
|
|
|
NM_SET_OUT (out_to, item->to);
|
2014-07-24 08:53:33 -04:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_add_priority:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
* @map: the type of priority map
|
|
|
|
|
* @from: the priority to map to @to
|
|
|
|
|
* @to: the priority to map @from to
|
|
|
|
|
*
|
|
|
|
|
* Adds a priority mapping to the #NMSettingVlan:ingress_priority_map or
|
|
|
|
|
* #NMSettingVlan:egress_priority_map properties of the setting. If @from is
|
|
|
|
|
* already in the given priority map, this function will overwrite the
|
|
|
|
|
* existing entry with the new @to.
|
|
|
|
|
*
|
|
|
|
|
* If @map is #NM_VLAN_INGRESS_MAP then @from is the incoming 802.1q VLAN
|
|
|
|
|
* Priority Code Point (PCP) value, and @to is the Linux SKB priority value.
|
|
|
|
|
*
|
|
|
|
|
* If @map is #NM_VLAN_EGRESS_MAP then @from is the Linux SKB priority value and
|
|
|
|
|
* @to is the outgoing 802.1q VLAN Priority Code Point (PCP) value.
|
|
|
|
|
*
|
2019-08-02 08:46:38 +02:00
|
|
|
* Returns: %TRUE.
|
2014-07-24 08:53:33 -04:00
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_vlan_add_priority (NMSettingVlan *setting,
|
|
|
|
|
NMVlanPriorityMap map,
|
|
|
|
|
guint32 from,
|
|
|
|
|
guint32 to)
|
|
|
|
|
{
|
2015-10-12 15:33:43 +02:00
|
|
|
GSList *list = NULL;
|
2015-10-30 11:09:41 +01:00
|
|
|
NMVlanQosMapping *item;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
|
|
|
|
|
|
|
|
|
|
list = get_map (setting, map);
|
2015-10-12 15:33:43 +02:00
|
|
|
if (check_replace_duplicate_priority (list, from, to)) {
|
|
|
|
|
if (map == NM_VLAN_INGRESS_MAP)
|
2019-01-11 08:28:26 +01:00
|
|
|
_notify (setting, PROP_INGRESS_PRIORITY_MAP);
|
2015-10-12 15:33:43 +02:00
|
|
|
else
|
2019-01-11 08:28:26 +01:00
|
|
|
_notify (setting, PROP_EGRESS_PRIORITY_MAP);
|
2015-10-12 15:33:43 +02:00
|
|
|
return TRUE;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2015-10-30 11:09:41 +01:00
|
|
|
item = g_malloc0 (sizeof (NMVlanQosMapping));
|
2014-07-24 08:53:33 -04:00
|
|
|
item->from = from;
|
|
|
|
|
item->to = to;
|
2015-10-30 12:07:37 +01:00
|
|
|
set_map (setting, map, g_slist_insert_sorted (list, item, prio_map_compare));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-30 11:02:44 +01:00
|
|
|
gboolean
|
|
|
|
|
_nm_setting_vlan_set_priorities (NMSettingVlan *setting,
|
|
|
|
|
NMVlanPriorityMap map,
|
|
|
|
|
const NMVlanQosMapping *qos_map,
|
|
|
|
|
guint n_qos_map)
|
|
|
|
|
{
|
|
|
|
|
gboolean has_changes = FALSE;
|
|
|
|
|
GSList *map_prev, *map_new;
|
|
|
|
|
guint i;
|
|
|
|
|
gint64 from_last;
|
|
|
|
|
|
|
|
|
|
map_prev = get_map (setting, map);
|
|
|
|
|
|
|
|
|
|
if (n_qos_map != g_slist_length (map_prev))
|
|
|
|
|
has_changes = TRUE;
|
|
|
|
|
else {
|
|
|
|
|
const GSList *iter;
|
|
|
|
|
|
|
|
|
|
iter = map_prev;
|
|
|
|
|
for (i = 0; i < n_qos_map; i++, iter = iter->next) {
|
|
|
|
|
const NMVlanQosMapping *m = iter->data;
|
|
|
|
|
|
|
|
|
|
if ( m->from != qos_map[i].from
|
|
|
|
|
|| m->to != qos_map[i].to) {
|
|
|
|
|
has_changes = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!has_changes)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
map_new = NULL;
|
|
|
|
|
from_last = G_MAXINT64;
|
|
|
|
|
for (i = n_qos_map; i > 0;) {
|
|
|
|
|
const NMVlanQosMapping *m = &qos_map[--i];
|
|
|
|
|
NMVlanQosMapping *item;
|
|
|
|
|
|
|
|
|
|
/* We require the array to be presorted. */
|
|
|
|
|
if (m->from >= from_last)
|
|
|
|
|
g_return_val_if_reached (FALSE);
|
|
|
|
|
from_last = m->from;
|
|
|
|
|
|
|
|
|
|
item = g_malloc0 (sizeof (NMVlanQosMapping));
|
|
|
|
|
item->from = m->from;
|
|
|
|
|
item->to = m->to;
|
|
|
|
|
map_new = g_slist_prepend (map_new, item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_slist_free_full (map_prev, g_free);
|
|
|
|
|
set_map (setting, map, map_new);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
_nm_setting_vlan_get_priorities (NMSettingVlan *setting,
|
|
|
|
|
NMVlanPriorityMap map,
|
|
|
|
|
NMVlanQosMapping **out_qos_map,
|
|
|
|
|
guint *out_n_qos_map)
|
|
|
|
|
{
|
|
|
|
|
GSList *list;
|
|
|
|
|
NMVlanQosMapping *qos_map = NULL;
|
|
|
|
|
guint n_qos_map, i;
|
|
|
|
|
|
|
|
|
|
list = get_map (setting, map);
|
|
|
|
|
|
|
|
|
|
n_qos_map = g_slist_length (list);
|
|
|
|
|
|
|
|
|
|
if (n_qos_map > 0) {
|
|
|
|
|
qos_map = g_new (NMVlanQosMapping, n_qos_map);
|
|
|
|
|
|
|
|
|
|
for (i = 0; list; i++, list = list->next) {
|
|
|
|
|
nm_assert (i < n_qos_map);
|
|
|
|
|
qos_map[i] = *((const NMVlanQosMapping *) list->data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*out_qos_map = qos_map;
|
|
|
|
|
*out_n_qos_map = n_qos_map;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_remove_priority:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
* @map: the type of priority map
|
|
|
|
|
* @idx: the zero-based index of the priority map to remove
|
|
|
|
|
*
|
|
|
|
|
* Removes the priority map at index @idx from the
|
|
|
|
|
* #NMSettingVlan:ingress_priority_map or #NMSettingVlan:egress_priority_map
|
|
|
|
|
* properties.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
nm_setting_vlan_remove_priority (NMSettingVlan *setting,
|
|
|
|
|
NMVlanPriorityMap map,
|
|
|
|
|
guint32 idx)
|
|
|
|
|
{
|
|
|
|
|
GSList *list = NULL, *item = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_VLAN (setting));
|
|
|
|
|
g_return_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP);
|
|
|
|
|
|
|
|
|
|
list = get_map (setting, map);
|
|
|
|
|
g_return_if_fail (idx < g_slist_length (list));
|
|
|
|
|
|
|
|
|
|
item = g_slist_nth (list, idx);
|
2015-10-30 11:09:41 +01:00
|
|
|
priority_map_free ((NMVlanQosMapping *) (item->data));
|
2014-07-24 08:53:33 -04:00
|
|
|
set_map (setting, map, g_slist_delete_link (list, item));
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-16 14:03:26 +01:00
|
|
|
static gboolean
|
|
|
|
|
priority_map_remove_by_value (NMSettingVlan *setting,
|
|
|
|
|
NMVlanPriorityMap map,
|
|
|
|
|
guint32 from,
|
|
|
|
|
guint32 to,
|
|
|
|
|
gboolean wildcard_to)
|
|
|
|
|
{
|
|
|
|
|
GSList *list = NULL, *iter = NULL;
|
|
|
|
|
NMVlanQosMapping *item;
|
|
|
|
|
|
|
|
|
|
nm_assert (NM_IS_SETTING_VLAN (setting));
|
|
|
|
|
nm_assert (NM_IN_SET (map, NM_VLAN_INGRESS_MAP, NM_VLAN_EGRESS_MAP));
|
|
|
|
|
|
|
|
|
|
list = get_map (setting, map);
|
|
|
|
|
for (iter = list; iter; iter = g_slist_next (iter)) {
|
|
|
|
|
item = iter->data;
|
|
|
|
|
|
|
|
|
|
if (item->from != from)
|
|
|
|
|
continue;
|
|
|
|
|
if ( !wildcard_to
|
|
|
|
|
&& item->to != to)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
priority_map_free ((NMVlanQosMapping *) (iter->data));
|
|
|
|
|
set_map (setting, map, g_slist_delete_link (list, iter));
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_remove_priority_by_value:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
* @map: the type of priority map
|
|
|
|
|
* @from: the priority to map to @to
|
|
|
|
|
* @to: the priority to map @from to
|
|
|
|
|
*
|
|
|
|
|
* Removes the priority map @form:@to from the #NMSettingVlan:ingress_priority_map
|
|
|
|
|
* or #NMSettingVlan:egress_priority_map (according to @map argument)
|
|
|
|
|
* properties.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_vlan_remove_priority_by_value (NMSettingVlan *setting,
|
|
|
|
|
NMVlanPriorityMap map,
|
|
|
|
|
guint32 from,
|
|
|
|
|
guint32 to)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
|
|
|
|
|
|
2019-03-16 14:03:26 +01:00
|
|
|
return priority_map_remove_by_value (setting, map, from, to, FALSE);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_remove_priority_str_by_value:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
* @map: the type of priority map
|
|
|
|
|
* @str: the string which contains a priority map, like "3:7"
|
|
|
|
|
*
|
|
|
|
|
* Removes the priority map @str from the #NMSettingVlan:ingress_priority_map
|
|
|
|
|
* or #NMSettingVlan:egress_priority_map (according to @map argument)
|
|
|
|
|
* properties.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_vlan_remove_priority_str_by_value (NMSettingVlan *setting,
|
|
|
|
|
NMVlanPriorityMap map,
|
|
|
|
|
const char *str)
|
|
|
|
|
{
|
2019-03-16 14:03:26 +01:00
|
|
|
gboolean is_wildcard_to;
|
|
|
|
|
guint32 from, to;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_VLAN (setting), FALSE);
|
|
|
|
|
g_return_val_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP, FALSE);
|
|
|
|
|
|
2019-03-16 14:03:26 +01:00
|
|
|
if (!nm_utils_vlan_priority_map_parse_str (map, str, TRUE, &from, &to, &is_wildcard_to))
|
2014-07-24 08:53:33 -04:00
|
|
|
return FALSE;
|
2019-03-16 14:03:26 +01:00
|
|
|
return priority_map_remove_by_value (setting, map, from, to, is_wildcard_to);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_clear_priorities:
|
|
|
|
|
* @setting: the #NMSettingVlan
|
|
|
|
|
* @map: the type of priority map
|
|
|
|
|
*
|
2017-05-05 14:11:05 +02:00
|
|
|
* Clear all the entries from #NMSettingVlan:ingress_priority_map or
|
2014-07-24 08:53:33 -04:00
|
|
|
* #NMSettingVlan:egress_priority_map properties.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
nm_setting_vlan_clear_priorities (NMSettingVlan *setting, NMVlanPriorityMap map)
|
|
|
|
|
{
|
|
|
|
|
GSList *list = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_VLAN (setting));
|
|
|
|
|
g_return_if_fail (map == NM_VLAN_INGRESS_MAP || map == NM_VLAN_EGRESS_MAP);
|
|
|
|
|
|
|
|
|
|
list = get_map (setting, map);
|
|
|
|
|
g_slist_free_full (list, g_free);
|
|
|
|
|
set_map (setting, map, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2017-02-28 15:24:58 +01:00
|
|
|
static int
|
2014-10-21 22:30:31 -04:00
|
|
|
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting);
|
2014-10-21 22:30:31 -04:00
|
|
|
NMSettingConnection *s_con;
|
|
|
|
|
NMSettingWired *s_wired;
|
|
|
|
|
|
|
|
|
|
if (connection) {
|
|
|
|
|
s_con = nm_connection_get_setting_connection (connection);
|
|
|
|
|
s_wired = nm_connection_get_setting_wired (connection);
|
|
|
|
|
} else {
|
|
|
|
|
s_con = NULL;
|
|
|
|
|
s_wired = NULL;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->parent) {
|
|
|
|
|
if (nm_utils_is_uuid (priv->parent)) {
|
|
|
|
|
/* If we have an NMSettingConnection:master with slave-type="vlan",
|
|
|
|
|
* then it must be the same UUID.
|
|
|
|
|
*/
|
|
|
|
|
if (s_con) {
|
|
|
|
|
const char *master = NULL, *slave_type = NULL;
|
|
|
|
|
|
|
|
|
|
slave_type = nm_setting_connection_get_slave_type (s_con);
|
|
|
|
|
if (!g_strcmp0 (slave_type, NM_SETTING_VLAN_SETTING_NAME))
|
|
|
|
|
master = nm_setting_connection_get_master (s_con);
|
|
|
|
|
|
|
|
|
|
if (master && g_strcmp0 (priv->parent, master) != 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' value doesn't match '%s=%s'"),
|
|
|
|
|
priv->parent, NM_SETTING_CONNECTION_MASTER, master);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_PARENT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-23 12:51:26 +01:00
|
|
|
} else if (!nm_utils_is_valid_iface_name (priv->parent, NULL)) {
|
2014-07-24 08:53:33 -04:00
|
|
|
/* parent must be either a UUID or an interface name */
|
|
|
|
|
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 neither an UUID nor an interface name"),
|
|
|
|
|
priv->parent);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_PARENT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* If parent is NULL, the parent must be specified via
|
|
|
|
|
* NMSettingWired:mac-address.
|
|
|
|
|
*/
|
2014-10-21 22:30:31 -04:00
|
|
|
if ( connection
|
2014-08-13 02:38:09 +02:00
|
|
|
&& (!s_wired || !nm_setting_wired_get_mac_address (s_wired))) {
|
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_MISSING_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("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_VLAN_SETTING_NAME, NM_SETTING_VLAN_PARENT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-22 11:23:02 +01:00
|
|
|
if (priv->id >= 4095) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("the vlan id must be in range 0-4094 but is %u"),
|
|
|
|
|
priv->id);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_ID);
|
2017-05-30 18:12:23 +02:00
|
|
|
return FALSE;
|
2016-01-22 11:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2015-10-13 10:05:19 +02:00
|
|
|
if (priv->flags & ~NM_VLAN_FLAGS_ALL) {
|
2014-07-24 08:53:33 -04:00
|
|
|
g_set_error_literal (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
|
|
|
_("flags are invalid"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_FLAGS);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-28 15:24:58 +01:00
|
|
|
if (connection && !s_wired) {
|
|
|
|
|
/* technically, a VLAN setting does not require an ethernet setting. However,
|
|
|
|
|
* the ifcfg-rh reader always adds a ethernet setting when reading a vlan setting.
|
|
|
|
|
* Thus, in order to be consistent, always add one via normalization. */
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
|
|
|
|
|
_("vlan setting should have a ethernet setting as well"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_FLAGS);
|
|
|
|
|
return NM_SETTING_VERIFY_NORMALIZABLE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-04 19:57:20 -04:00
|
|
|
return TRUE;
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2015-10-08 09:52:48 +02:00
|
|
|
static GVariant *
|
2019-04-24 17:41:32 +02:00
|
|
|
_override_flags_get (const NMSettInfoSetting *sett_info,
|
|
|
|
|
guint property_idx,
|
|
|
|
|
NMConnection *connection,
|
|
|
|
|
NMSetting *setting,
|
2019-06-27 09:07:16 +02:00
|
|
|
NMConnectionSerializationFlags flags,
|
|
|
|
|
const NMConnectionSerializationOptions *options)
|
2015-10-08 09:52:48 +02:00
|
|
|
{
|
|
|
|
|
return g_variant_new_uint32 (nm_setting_vlan_get_flags ((NMSettingVlan *) setting));
|
|
|
|
|
}
|
|
|
|
|
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
static gboolean
|
2015-10-08 10:02:48 +02:00
|
|
|
_override_flags_not_set (NMSetting *setting,
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
GVariant *connection_dict,
|
|
|
|
|
const char *property,
|
|
|
|
|
NMSettingParseFlags parse_flags,
|
|
|
|
|
GError **error)
|
2015-10-08 10:02:48 +02:00
|
|
|
{
|
|
|
|
|
/* we changed the default value for FLAGS. When an older client
|
|
|
|
|
* doesn't serialize the property, we assume it is the old default. */
|
|
|
|
|
g_object_set (G_OBJECT (setting),
|
|
|
|
|
NM_SETTING_VLAN_FLAGS, (NMVlanFlags) 0,
|
|
|
|
|
NULL);
|
libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).
In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.
Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.
Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.
For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.
This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-18 13:42:50 +01:00
|
|
|
return TRUE;
|
2015-10-08 10:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static GSList *
|
2014-08-21 13:19:53 -04:00
|
|
|
priority_strv_to_maplist (NMVlanPriorityMap map, char **strv)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2014-08-21 13:19:53 -04:00
|
|
|
GSList *list = NULL;
|
2019-03-16 14:03:26 +01:00
|
|
|
gsize i;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2015-09-01 16:06:54 +02:00
|
|
|
for (i = 0; strv && strv[i]; i++) {
|
2019-03-16 14:03:26 +01:00
|
|
|
guint32 from, to;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2019-03-16 14:03:26 +01:00
|
|
|
if (!nm_utils_vlan_priority_map_parse_str (map, strv[i], FALSE, &from, &to, NULL))
|
|
|
|
|
continue;
|
|
|
|
|
if (check_replace_duplicate_priority (list, from, to))
|
|
|
|
|
continue;
|
|
|
|
|
list = g_slist_prepend (list, priority_map_new (from, to));
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
2015-10-30 12:07:37 +01:00
|
|
|
return g_slist_sort (list, prio_map_compare);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2014-08-21 13:19:53 -04:00
|
|
|
static char **
|
|
|
|
|
priority_maplist_to_strv (GSList *list)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
2014-08-21 13:19:53 -04:00
|
|
|
GSList *iter;
|
|
|
|
|
GPtrArray *strv;
|
|
|
|
|
|
|
|
|
|
strv = g_ptr_array_new ();
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
for (iter = list; iter; iter = g_slist_next (iter)) {
|
2015-10-30 11:09:41 +01:00
|
|
|
NMVlanQosMapping *item = iter->data;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2014-08-21 13:19:53 -04:00
|
|
|
g_ptr_array_add (strv, g_strdup_printf ("%d:%d", item->from, item->to));
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
2014-08-21 13:19:53 -04:00
|
|
|
g_ptr_array_add (strv, NULL);
|
|
|
|
|
|
|
|
|
|
return (char **) g_ptr_array_free (strv, FALSE);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMSettingVlan *setting = NM_SETTING_VLAN (object);
|
|
|
|
|
NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_PARENT:
|
|
|
|
|
g_value_set_string (value, priv->parent);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ID:
|
|
|
|
|
g_value_set_uint (value, priv->id);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_FLAGS:
|
2014-06-26 16:47:46 -04:00
|
|
|
g_value_set_flags (value, priv->flags);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_INGRESS_PRIORITY_MAP:
|
2014-08-21 13:19:53 -04:00
|
|
|
g_value_take_boxed (value, priority_maplist_to_strv (priv->ingress_priority_map));
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_EGRESS_PRIORITY_MAP:
|
2014-08-21 13:19:53 -04:00
|
|
|
g_value_take_boxed (value, priority_maplist_to_strv (priv->egress_priority_map));
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMSettingVlan *setting = NM_SETTING_VLAN (object);
|
|
|
|
|
NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_PARENT:
|
|
|
|
|
g_free (priv->parent);
|
|
|
|
|
priv->parent = g_value_dup_string (value);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ID:
|
|
|
|
|
priv->id = g_value_get_uint (value);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_FLAGS:
|
|
|
|
|
priv->flags = g_value_get_flags (value);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_INGRESS_PRIORITY_MAP:
|
|
|
|
|
g_slist_free_full (priv->ingress_priority_map, g_free);
|
|
|
|
|
priv->ingress_priority_map = priority_strv_to_maplist (NM_VLAN_INGRESS_MAP, g_value_get_boxed (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_EGRESS_PRIORITY_MAP:
|
|
|
|
|
g_slist_free_full (priv->egress_priority_map, g_free);
|
|
|
|
|
priv->egress_priority_map = priority_strv_to_maplist (NM_VLAN_EGRESS_MAP, g_value_get_boxed (value));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_setting_vlan_init (NMSettingVlan *setting)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_vlan_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #NMSettingVlan object with default values.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new empty #NMSettingVlan object
|
|
|
|
|
**/
|
|
|
|
|
NMSetting *
|
|
|
|
|
nm_setting_vlan_new (void)
|
|
|
|
|
{
|
|
|
|
|
return (NMSetting *) g_object_new (NM_TYPE_SETTING_VLAN, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMSettingVlan *setting = NM_SETTING_VLAN (object);
|
|
|
|
|
NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_free (priv->parent);
|
|
|
|
|
g_slist_free_full (priv->ingress_priority_map, g_free);
|
|
|
|
|
g_slist_free_full (priv->egress_priority_map, g_free);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_setting_vlan_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_vlan_class_init (NMSettingVlanClass *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 (NMSettingVlanPrivate));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
object_class->get_property = get_property;
|
2019-01-11 08:32:54 +01:00
|
|
|
object_class->set_property = set_property;
|
2014-07-24 08:53:33 -04: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;
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingVlan:parent:
|
|
|
|
|
*
|
|
|
|
|
* If given, specifies the parent interface name or parent connection UUID
|
|
|
|
|
* from which this VLAN interface should be created. If this property is
|
|
|
|
|
* not specified, the connection must contain an #NMSettingWired setting
|
|
|
|
|
* with a #NMSettingWired:mac-address property.
|
|
|
|
|
**/
|
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: parent
|
|
|
|
|
* variable: DEVICE or PHYSDEV
|
|
|
|
|
* description: Parent interface of the VLAN.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_PARENT] =
|
|
|
|
|
g_param_spec_string (NM_SETTING_VLAN_PARENT, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingVlan:id:
|
|
|
|
|
*
|
|
|
|
|
* The VLAN identifier that the interface created by this connection should
|
2016-01-22 11:23:02 +01:00
|
|
|
* be assigned. The valid range is from 0 to 4094, without the reserved id 4095.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
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: id
|
|
|
|
|
* variable: VLAN_ID or DEVICE
|
|
|
|
|
* description: VLAN identifier.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_ID] =
|
|
|
|
|
g_param_spec_uint (NM_SETTING_VLAN_ID, "", "",
|
|
|
|
|
0, 4095, 0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingVlan:flags:
|
|
|
|
|
*
|
|
|
|
|
* One or more flags which control the behavior and features of the VLAN
|
|
|
|
|
* interface. Flags include %NM_VLAN_FLAG_REORDER_HEADERS (reordering of
|
|
|
|
|
* output packet headers), %NM_VLAN_FLAG_GVRP (use of the GVRP protocol),
|
|
|
|
|
* and %NM_VLAN_FLAG_LOOSE_BINDING (loose binding of the interface to its
|
2015-10-13 10:05:19 +02:00
|
|
|
* master device's operating state). %NM_VLAN_FLAG_MVRP (use of the MVRP
|
|
|
|
|
* protocol).
|
2015-10-08 10:02:48 +02:00
|
|
|
*
|
|
|
|
|
* The default value of this property is NM_VLAN_FLAG_REORDER_HEADERS,
|
|
|
|
|
* but it used to be 0. To preserve backward compatibility, the default-value
|
|
|
|
|
* in the D-Bus API continues to be 0 and a missing property on D-Bus
|
|
|
|
|
* is still considered as 0.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
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: flags
|
2016-02-26 15:29:19 +01:00
|
|
|
* variable: GVRP, MVRP, VLAN_FLAGS
|
|
|
|
|
* values: "yes or "no" for GVRP and MVRP; "LOOSE_BINDING" and "NO_REORDER_HDR" for VLAN_FLAGS
|
2015-07-17 09:20:29 +02:00
|
|
|
* description: VLAN flags.
|
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
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_FLAGS] =
|
|
|
|
|
g_param_spec_flags (NM_SETTING_VLAN_FLAGS, "", "",
|
|
|
|
|
NM_TYPE_VLAN_FLAGS,
|
|
|
|
|
NM_VLAN_FLAG_REORDER_HEADERS,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
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_FLAGS],
|
|
|
|
|
NM_SETT_INFO_PROPERT_TYPE (
|
|
|
|
|
.dbus_type = G_VARIANT_TYPE_UINT32,
|
|
|
|
|
.to_dbus_fcn = _override_flags_get,
|
|
|
|
|
.missing_from_dbus_fcn = _override_flags_not_set,
|
|
|
|
|
));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingVlan:ingress-priority-map:
|
|
|
|
|
*
|
|
|
|
|
* For incoming packets, a list of mappings from 802.1p priorities to Linux
|
|
|
|
|
* SKB priorities. The mapping is given in the format "from:to" where both
|
|
|
|
|
* "from" and "to" are unsigned integers, ie "7:3".
|
|
|
|
|
**/
|
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---
|
2015-08-31 08:44:10 +02:00
|
|
|
* property: ingress-priority-map
|
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
|
|
|
* variable: VLAN_INGRESS_PRIORITY_MAP
|
|
|
|
|
* description: Ingress priority mapping.
|
|
|
|
|
* example: VLAN_INGRESS_PRIORITY_MAP=4:2,3:5
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_INGRESS_PRIORITY_MAP] =
|
|
|
|
|
g_param_spec_boxed (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, "", "",
|
|
|
|
|
G_TYPE_STRV,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingVlan:egress-priority-map:
|
|
|
|
|
*
|
|
|
|
|
* For outgoing packets, a list of mappings from Linux SKB priorities to
|
|
|
|
|
* 802.1p priorities. The mapping is given in the format "from:to" where
|
|
|
|
|
* both "from" and "to" are unsigned integers, ie "7:3".
|
|
|
|
|
**/
|
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---
|
2015-08-31 08:44:10 +02:00
|
|
|
* property: egress-priority-map
|
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
|
|
|
* variable: VLAN_EGRESS_PRIORITY_MAP
|
|
|
|
|
* description: Egress priority mapping.
|
|
|
|
|
* example: VLAN_EGRESS_PRIORITY_MAP=5:4,4:1,3:7
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_EGRESS_PRIORITY_MAP] =
|
|
|
|
|
g_param_spec_boxed (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, "", "",
|
|
|
|
|
G_TYPE_STRV,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2014-08-04 19:57:20 -04:00
|
|
|
|
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: interface-name
|
|
|
|
|
* variable: PHYSDEV and VLAN_ID, or DEVICE
|
|
|
|
|
* description: VLAN interface name.
|
|
|
|
|
* If all variables are set, parent device from PHYSDEV takes precedence over DEVICE,
|
|
|
|
|
* but VLAN id from DEVICE takes precedence over VLAN_ID.
|
|
|
|
|
* example: PHYSDEV=eth0, VLAN_ID=12; or DEVICE=eth0.12
|
|
|
|
|
* ---end---
|
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
|
|
|
|
|
* vlan's interface name.
|
|
|
|
|
* ---end---
|
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
|
|
|
*/
|
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_VLAN,
|
|
|
|
|
NULL, properties_override);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|