2020-12-23 22:21:36 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2015-09-01 14:06:00 +02:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2015 Red Hat, Inc.
|
2015-09-01 14:06:00 +02:00
|
|
|
*/
|
|
|
|
|
|
2021-02-04 16:04:15 +01:00
|
|
|
#include "libnm-core/nm-default-libnm-core.h"
|
2016-02-19 14:57:48 +01:00
|
|
|
|
2016-02-12 14:44:52 +01:00
|
|
|
#include "nm-setting-ip-tunnel.h"
|
|
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
#include "nm-setting-private.h"
|
|
|
|
|
#include "nm-utils.h"
|
|
|
|
|
|
|
|
|
|
/**
|
2015-12-18 11:16:22 +01:00
|
|
|
* SECTION:nm-setting-ip-tunnel
|
2015-09-01 14:06:00 +02:00
|
|
|
* @short_description: Describes connection properties for IP tunnel devices
|
|
|
|
|
**/
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
2015-09-01 14:06:00 +02:00
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT,
|
|
|
|
|
PROP_MODE,
|
|
|
|
|
PROP_LOCAL,
|
|
|
|
|
PROP_REMOTE,
|
|
|
|
|
PROP_TTL,
|
|
|
|
|
PROP_TOS,
|
|
|
|
|
PROP_PATH_MTU_DISCOVERY,
|
|
|
|
|
PROP_INPUT_KEY,
|
|
|
|
|
PROP_OUTPUT_KEY,
|
|
|
|
|
PROP_ENCAPSULATION_LIMIT,
|
|
|
|
|
PROP_FLOW_LABEL,
|
|
|
|
|
PROP_MTU,
|
|
|
|
|
PROP_FLAGS, );
|
2015-09-01 14:06:00 +02:00
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
char * parent;
|
|
|
|
|
char * local;
|
|
|
|
|
char * remote;
|
|
|
|
|
char * input_key;
|
|
|
|
|
char * output_key;
|
2019-12-12 11:51:21 +01:00
|
|
|
guint ttl;
|
|
|
|
|
guint tos;
|
2015-09-01 14:06:00 +02:00
|
|
|
guint encapsulation_limit;
|
|
|
|
|
guint flow_label;
|
2019-12-12 11:51:21 +01:00
|
|
|
NMIPTunnelMode mode;
|
2019-04-05 12:29:40 +02:00
|
|
|
guint32 mtu;
|
2017-12-22 10:24:25 +01:00
|
|
|
guint32 flags;
|
2019-12-12 11:51:21 +01:00
|
|
|
bool path_mtu_discovery : 1;
|
2015-09-01 14:06:00 +02:00
|
|
|
} NMSettingIPTunnelPrivate;
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
G_DEFINE_TYPE(NMSettingIPTunnel, nm_setting_ip_tunnel, NM_TYPE_SETTING)
|
|
|
|
|
|
|
|
|
|
#define NM_SETTING_IP_TUNNEL_GET_PRIVATE(o) \
|
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE((o), NM_TYPE_SETTING_IP_TUNNEL, NMSettingIPTunnelPrivate))
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2015-09-01 14:06:00 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_parent:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:parent property of the setting
|
|
|
|
|
*
|
|
|
|
|
* Returns: the parent device
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_ip_tunnel_get_parent(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), NULL);
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_mode:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:mode property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the tunnel mode
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
NMIPTunnelMode
|
|
|
|
|
nm_setting_ip_tunnel_get_mode(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_local:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:local property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the local endpoint
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_ip_tunnel_get_local(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->local;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_remote:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:remote property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the remote endpoint
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_ip_tunnel_get_remote(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->remote;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_ttl:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:ttl property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the Time-to-live value
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
guint
|
|
|
|
|
nm_setting_ip_tunnel_get_ttl(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->ttl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_tos:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:tos property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the TOS value
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
nm_setting_ip_tunnel_get_tos(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->tos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_path_mtu_discovery:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:path-mtu-discovery property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether path MTU discovery is enabled
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_ip_tunnel_get_path_mtu_discovery(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), TRUE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->path_mtu_discovery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_input_key:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:input-key property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the input key
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_ip_tunnel_get_input_key(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->input_key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_output_key:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:output-key property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the output key
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
const char *
|
|
|
|
|
nm_setting_ip_tunnel_get_output_key(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->output_key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_encapsulation_limit:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:encapsulation-limit property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the encapsulation limit value
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
nm_setting_ip_tunnel_get_encapsulation_limit(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->encapsulation_limit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_flow_label:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:flow-label property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the flow label value
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
nm_setting_ip_tunnel_get_flow_label(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->flow_label;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-16 11:31:58 +01:00
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_get_mtu:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:mtu property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the MTU
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
nm_setting_ip_tunnel_get_mtu(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->mtu;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-22 10:24:25 +01:00
|
|
|
/*
|
|
|
|
|
* nm_setting_ip_tunnel_get_flags:
|
|
|
|
|
* @setting: the #NMSettingIPTunnel
|
|
|
|
|
*
|
|
|
|
|
* Returns the #NMSettingIPTunnel:flags property of the setting.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the tunnel flags
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
|
|
|
|
NMIPTunnelFlags
|
|
|
|
|
nm_setting_ip_tunnel_get_flags(NMSettingIPTunnel *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail(NM_IS_SETTING_IP_TUNNEL(setting), NM_IP_TUNNEL_FLAG_NONE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting)->flags;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 18:22:50 +02:00
|
|
|
/*****************************************************************************/
|
2015-09-01 14:06:00 +02:00
|
|
|
|
2020-05-13 10:09:43 +02:00
|
|
|
gboolean
|
|
|
|
|
_nm_ip_tunnel_mode_is_layer2(NMIPTunnelMode mode)
|
|
|
|
|
{
|
|
|
|
|
return NM_IN_SET(mode, NM_IP_TUNNEL_MODE_GRETAP, NM_IP_TUNNEL_MODE_IP6GRETAP);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
static gboolean
|
|
|
|
|
verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting);
|
2016-11-08 09:42:31 +01:00
|
|
|
int family = AF_UNSPEC;
|
2017-12-22 10:24:25 +01:00
|
|
|
guint32 flags;
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
switch (priv->mode) {
|
|
|
|
|
case NM_IP_TUNNEL_MODE_IPIP:
|
|
|
|
|
case NM_IP_TUNNEL_MODE_SIT:
|
|
|
|
|
case NM_IP_TUNNEL_MODE_ISATAP:
|
|
|
|
|
case NM_IP_TUNNEL_MODE_GRE:
|
|
|
|
|
case NM_IP_TUNNEL_MODE_VTI:
|
2018-06-26 10:47:36 +02:00
|
|
|
case NM_IP_TUNNEL_MODE_GRETAP:
|
2015-09-01 14:06:00 +02:00
|
|
|
family = AF_INET;
|
|
|
|
|
break;
|
|
|
|
|
case NM_IP_TUNNEL_MODE_IP6IP6:
|
|
|
|
|
case NM_IP_TUNNEL_MODE_IPIP6:
|
|
|
|
|
case NM_IP_TUNNEL_MODE_IP6GRE:
|
|
|
|
|
case NM_IP_TUNNEL_MODE_VTI6:
|
2018-06-26 15:05:15 +02:00
|
|
|
case NM_IP_TUNNEL_MODE_IP6GRETAP:
|
2015-09-01 14:06:00 +02:00
|
|
|
family = AF_INET6;
|
|
|
|
|
break;
|
2016-11-08 09:42:31 +01:00
|
|
|
case NM_IP_TUNNEL_MODE_UNKNOWN:
|
|
|
|
|
break;
|
2015-09-01 14:06:00 +02:00
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
if (family == AF_UNSPEC) {
|
|
|
|
|
g_set_error(error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("'%d' is not a valid tunnel mode"),
|
|
|
|
|
(int) priv->mode);
|
|
|
|
|
g_prefix_error(error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_IP_TUNNEL_SETTING_NAME,
|
|
|
|
|
NM_SETTING_IP_TUNNEL_MODE);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2020-02-12 18:01:13 +01:00
|
|
|
if (priv->parent && !nm_utils_ifname_valid_kernel(priv->parent, NULL)
|
2015-09-01 14:06:00 +02:00
|
|
|
&& !nm_utils_is_uuid(priv->parent)) {
|
|
|
|
|
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_IP_TUNNEL_SETTING_NAME,
|
|
|
|
|
NM_SETTING_IP_TUNNEL_PARENT);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2020-01-09 12:17:41 +01:00
|
|
|
if (priv->local && !nm_utils_ipaddr_is_valid(family, priv->local)) {
|
2015-09-01 14:06:00 +02:00
|
|
|
g_set_error(error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("'%s' is not a valid IPv%c address"),
|
|
|
|
|
priv->local,
|
|
|
|
|
family == AF_INET ? '4' : '6');
|
|
|
|
|
g_prefix_error(error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_IP_TUNNEL_SETTING_NAME,
|
|
|
|
|
NM_SETTING_IP_TUNNEL_LOCAL);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2016-11-04 14:00:44 +01:00
|
|
|
if (!priv->remote) {
|
|
|
|
|
g_set_error_literal(error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("property is missing"));
|
|
|
|
|
g_prefix_error(error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_IP_TUNNEL_SETTING_NAME,
|
|
|
|
|
NM_SETTING_IP_TUNNEL_REMOTE);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2020-01-09 12:17:41 +01:00
|
|
|
if (!nm_utils_ipaddr_is_valid(family, priv->remote)) {
|
2015-09-01 14:06:00 +02:00
|
|
|
g_set_error(error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("'%s' is not a valid IPv%c address"),
|
|
|
|
|
priv->remote,
|
|
|
|
|
family == AF_INET ? '4' : '6');
|
|
|
|
|
g_prefix_error(error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_IP_TUNNEL_SETTING_NAME,
|
|
|
|
|
NM_SETTING_IP_TUNNEL_REMOTE);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
if ((priv->input_key && priv->input_key[0]) || (priv->output_key && priv->output_key[0])) {
|
2018-06-26 10:47:36 +02:00
|
|
|
if (!NM_IN_SET(priv->mode,
|
|
|
|
|
NM_IP_TUNNEL_MODE_GRE,
|
|
|
|
|
NM_IP_TUNNEL_MODE_GRETAP,
|
2018-06-26 15:05:15 +02:00
|
|
|
NM_IP_TUNNEL_MODE_IP6GRE,
|
|
|
|
|
NM_IP_TUNNEL_MODE_IP6GRETAP)) {
|
2015-09-01 14:06:00 +02:00
|
|
|
g_set_error_literal(error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("tunnel keys can only be specified for GRE tunnels"));
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
if (priv->input_key && priv->input_key[0]) {
|
|
|
|
|
gint64 val;
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
val = _nm_utils_ascii_str_to_int64(priv->input_key, 10, 0, G_MAXUINT32, -1);
|
|
|
|
|
if (val == -1) {
|
|
|
|
|
g_set_error(error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("'%s' is not a valid tunnel key"),
|
|
|
|
|
priv->input_key);
|
|
|
|
|
g_prefix_error(error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_IP_TUNNEL_SETTING_NAME,
|
|
|
|
|
NM_SETTING_IP_TUNNEL_INPUT_KEY);
|
2018-06-27 11:23:57 +02:00
|
|
|
return FALSE;
|
2015-09-01 14:06:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
if (priv->output_key && priv->output_key[0]) {
|
|
|
|
|
gint64 val;
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
val = _nm_utils_ascii_str_to_int64(priv->output_key, 10, 0, G_MAXUINT32, -1);
|
|
|
|
|
if (val == -1) {
|
|
|
|
|
g_set_error(error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("'%s' is not a valid tunnel key"),
|
|
|
|
|
priv->output_key);
|
|
|
|
|
g_prefix_error(error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_IP_TUNNEL_SETTING_NAME,
|
|
|
|
|
NM_SETTING_IP_TUNNEL_OUTPUT_KEY);
|
2018-06-27 11:23:57 +02:00
|
|
|
return FALSE;
|
2015-09-01 14:06:00 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
if (!priv->path_mtu_discovery && priv->ttl != 0) {
|
|
|
|
|
g_set_error_literal(error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("a fixed TTL is allowed only when path MTU discovery is enabled"));
|
|
|
|
|
g_prefix_error(error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_IP_TUNNEL_SETTING_NAME,
|
|
|
|
|
NM_SETTING_IP_TUNNEL_TTL);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2017-12-22 10:24:25 +01:00
|
|
|
flags = priv->flags;
|
|
|
|
|
if (NM_IN_SET(priv->mode, NM_IP_TUNNEL_MODE_IPIP6, NM_IP_TUNNEL_MODE_IP6IP6))
|
|
|
|
|
flags &= (guint32)(~_NM_IP_TUNNEL_FLAG_ALL_IP6TNL);
|
|
|
|
|
if (flags) {
|
|
|
|
|
g_set_error(error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("some flags are invalid for the select mode: %s"),
|
|
|
|
|
nm_utils_enum_to_str(nm_ip_tunnel_flags_get_type(), flags));
|
|
|
|
|
g_prefix_error(error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_IP_TUNNEL_SETTING_NAME,
|
|
|
|
|
NM_SETTING_IP_TUNNEL_FLAGS);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2020-05-13 10:09:43 +02:00
|
|
|
if (nm_connection_get_setting_wired(connection) && !_nm_ip_tunnel_mode_is_layer2(priv->mode)) {
|
2018-06-26 10:48:03 +02:00
|
|
|
g_set_error(error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("wired setting not allowed for mode %s"),
|
|
|
|
|
nm_utils_enum_to_str(nm_ip_tunnel_mode_get_type(), priv->mode));
|
|
|
|
|
g_prefix_error(error,
|
|
|
|
|
"%s.%s: ",
|
|
|
|
|
NM_SETTING_IP_TUNNEL_SETTING_NAME,
|
|
|
|
|
NM_SETTING_IP_TUNNEL_MODE);
|
|
|
|
|
return NM_SETTING_VERIFY_NORMALIZABLE_ERROR;
|
|
|
|
|
}
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
2015-09-01 14:06:00 +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-01 14:06:00 +02:00
|
|
|
{
|
|
|
|
|
NMSettingIPTunnel * setting = NM_SETTING_IP_TUNNEL(object);
|
|
|
|
|
NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_PARENT:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_string(value, priv->parent);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_MODE:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint(value, priv->mode);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_LOCAL:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_string(value, priv->local);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_REMOTE:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_string(value, priv->remote);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_TTL:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint(value, priv->ttl);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_TOS:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint(value, priv->tos);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_PATH_MTU_DISCOVERY:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_boolean(value, priv->path_mtu_discovery);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_INPUT_KEY:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_string(value, priv->input_key);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_OUTPUT_KEY:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_string(value, priv->output_key);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_ENCAPSULATION_LIMIT:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint(value, priv->encapsulation_limit);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_FLOW_LABEL:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint(value, priv->flow_label);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
2015-12-16 11:31:58 +01:00
|
|
|
case PROP_MTU:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint(value, priv->mtu);
|
2015-12-16 11:31:58 +01:00
|
|
|
break;
|
2017-12-22 10:24:25 +01:00
|
|
|
case PROP_FLAGS:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint(value, priv->flags);
|
2017-12-22 10:24:25 +01:00
|
|
|
break;
|
2015-09-01 14:06:00 +02:00
|
|
|
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-01 14:06:00 +02:00
|
|
|
{
|
|
|
|
|
NMSettingIPTunnel * setting = NM_SETTING_IP_TUNNEL(object);
|
|
|
|
|
NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
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-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_MODE:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->mode = g_value_get_uint(value);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_LOCAL:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_free(priv->local);
|
|
|
|
|
priv->local = g_value_dup_string(value);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_REMOTE:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_free(priv->remote);
|
|
|
|
|
priv->remote = g_value_dup_string(value);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_TTL:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->ttl = g_value_get_uint(value);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_TOS:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->tos = g_value_get_uint(value);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_PATH_MTU_DISCOVERY:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->path_mtu_discovery = g_value_get_boolean(value);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_INPUT_KEY:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_free(priv->input_key);
|
|
|
|
|
priv->input_key = g_value_dup_string(value);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_OUTPUT_KEY:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_free(priv->output_key);
|
|
|
|
|
priv->output_key = g_value_dup_string(value);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_ENCAPSULATION_LIMIT:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->encapsulation_limit = g_value_get_uint(value);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
|
|
|
|
case PROP_FLOW_LABEL:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->flow_label = g_value_get_uint(value);
|
2015-09-01 14:06:00 +02:00
|
|
|
break;
|
2015-12-16 11:31:58 +01:00
|
|
|
case PROP_MTU:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->mtu = g_value_get_uint(value);
|
2015-12-16 11:31:58 +01:00
|
|
|
break;
|
2017-12-22 10:24:25 +01:00
|
|
|
case PROP_FLAGS:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->flags = g_value_get_uint(value);
|
2017-12-22 10:24:25 +01:00
|
|
|
break;
|
2015-09-01 14:06:00 +02:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
2019-12-12 11:52:11 +01:00
|
|
|
nm_setting_ip_tunnel_init(NMSettingIPTunnel *self)
|
2019-01-11 08:32:54 +01:00
|
|
|
{
|
2019-12-12 11:52:11 +01:00
|
|
|
NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(self);
|
|
|
|
|
|
|
|
|
|
priv->path_mtu_discovery = TRUE;
|
2019-01-11 08:32:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ip_tunnel_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #NMSettingIPTunnel object with default values.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new empty #NMSettingIPTunnel object
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
NMSetting *
|
|
|
|
|
nm_setting_ip_tunnel_new(void)
|
|
|
|
|
{
|
2020-11-12 15:57:06 +01:00
|
|
|
return g_object_new(NM_TYPE_SETTING_IP_TUNNEL, NULL);
|
2019-01-11 08:32:54 +01:00
|
|
|
}
|
|
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
static void
|
|
|
|
|
finalize(GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMSettingIPTunnel * setting = NM_SETTING_IP_TUNNEL(object);
|
|
|
|
|
NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting);
|
|
|
|
|
|
2016-03-09 23:16:20 +01:00
|
|
|
g_free(priv->parent);
|
2015-09-01 14:06:00 +02:00
|
|
|
g_free(priv->local);
|
|
|
|
|
g_free(priv->remote);
|
|
|
|
|
g_free(priv->input_key);
|
|
|
|
|
g_free(priv->output_key);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS(nm_setting_ip_tunnel_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_ip_tunnel_class_init(NMSettingIPTunnelClass *klass)
|
2015-09-01 14:06:00 +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-01 14:06:00 +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(NMSettingIPTunnelPrivate));
|
2015-09-01 14:06:00 +02:00
|
|
|
|
|
|
|
|
object_class->get_property = get_property;
|
2019-01-11 08:32:54 +01:00
|
|
|
object_class->set_property = set_property;
|
2015-09-01 14:06:00 +02:00
|
|
|
object_class->finalize = finalize;
|
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
|
|
|
|
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-01 14:06:00 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:parent:
|
|
|
|
|
*
|
|
|
|
|
* If given, specifies the parent interface name or parent connection UUID
|
|
|
|
|
* the new device will be bound to so that tunneled packets will only be
|
|
|
|
|
* routed via that interface.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_PARENT] = g_param_spec_string(
|
|
|
|
|
NM_SETTING_IP_TUNNEL_PARENT,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:mode:
|
|
|
|
|
*
|
|
|
|
|
* The tunneling mode, for example %NM_IP_TUNNEL_MODE_IPIP or
|
|
|
|
|
* %NM_IP_TUNNEL_MODE_GRE.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_MODE] =
|
|
|
|
|
g_param_spec_uint(NM_SETTING_IP_TUNNEL_MODE,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
0,
|
|
|
|
|
G_MAXUINT,
|
|
|
|
|
0,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:local:
|
|
|
|
|
*
|
|
|
|
|
* The local endpoint of the tunnel; the value can be empty, otherwise it
|
|
|
|
|
* must contain an IPv4 or IPv6 address.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_LOCAL] = g_param_spec_string(NM_SETTING_IP_TUNNEL_LOCAL,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE
|
|
|
|
|
| G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:remote:
|
|
|
|
|
*
|
|
|
|
|
* The remote endpoint of the tunnel; the value must contain an IPv4 or IPv6
|
|
|
|
|
* address.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_REMOTE] = g_param_spec_string(
|
|
|
|
|
NM_SETTING_IP_TUNNEL_REMOTE,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:ttl
|
|
|
|
|
*
|
|
|
|
|
* The TTL to assign to tunneled packets. 0 is a special value meaning that
|
|
|
|
|
* packets inherit the TTL value.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_TTL] =
|
|
|
|
|
g_param_spec_uint(NM_SETTING_IP_TUNNEL_TTL,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
0,
|
|
|
|
|
255,
|
|
|
|
|
0,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:tos
|
|
|
|
|
*
|
|
|
|
|
* The type of service (IPv4) or traffic class (IPv6) field to be set on
|
|
|
|
|
* tunneled packets.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_TOS] =
|
|
|
|
|
g_param_spec_uint(NM_SETTING_IP_TUNNEL_TOS,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
0,
|
|
|
|
|
255,
|
|
|
|
|
0,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:path-mtu-discovery
|
|
|
|
|
*
|
|
|
|
|
* Whether to enable Path MTU Discovery on this tunnel.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_PATH_MTU_DISCOVERY] = g_param_spec_boolean(
|
|
|
|
|
NM_SETTING_IP_TUNNEL_PATH_MTU_DISCOVERY,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:input-key:
|
|
|
|
|
*
|
|
|
|
|
* The key used for tunnel input packets; the property is valid only for
|
|
|
|
|
* certain tunnel modes (GRE, IP6GRE). If empty, no key is used.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_INPUT_KEY] = g_param_spec_string(
|
|
|
|
|
NM_SETTING_IP_TUNNEL_INPUT_KEY,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:output-key:
|
|
|
|
|
*
|
|
|
|
|
* The key used for tunnel output packets; the property is valid only for
|
|
|
|
|
* certain tunnel modes (GRE, IP6GRE). If empty, no key is used.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_OUTPUT_KEY] = g_param_spec_string(
|
|
|
|
|
NM_SETTING_IP_TUNNEL_OUTPUT_KEY,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:encapsulation-limit:
|
|
|
|
|
*
|
|
|
|
|
* How many additional levels of encapsulation are permitted to be prepended
|
|
|
|
|
* to packets. This property applies only to IPv6 tunnels.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_ENCAPSULATION_LIMIT] =
|
|
|
|
|
g_param_spec_uint(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
0,
|
|
|
|
|
255,
|
|
|
|
|
0,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-09-01 14:06:00 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:flow-label:
|
|
|
|
|
*
|
|
|
|
|
* The flow label to assign to tunnel packets. This property applies only to
|
|
|
|
|
* IPv6 tunnels.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_FLOW_LABEL] =
|
|
|
|
|
g_param_spec_uint(NM_SETTING_IP_TUNNEL_FLOW_LABEL,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
0,
|
|
|
|
|
(1 << 20) - 1,
|
|
|
|
|
0,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2015-12-16 11:31:58 +01:00
|
|
|
/**
|
2017-10-16 23:27:04 +02:00
|
|
|
* NMSettingIPTunnel:mtu:
|
2015-12-16 11:31:58 +01:00
|
|
|
*
|
|
|
|
|
* If non-zero, only transmit packets of the specified size or smaller,
|
|
|
|
|
* breaking larger packets up into multiple fragments.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_IP_TUNNEL_MTU,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
2019-04-05 12:29:40 +02:00
|
|
|
0,
|
|
|
|
|
G_MAXUINT32,
|
|
|
|
|
0,
|
2019-01-11 08:28:26 +01:00
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE
|
|
|
|
|
| G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2017-12-22 10:24:25 +01:00
|
|
|
/**
|
|
|
|
|
* NMSettingIPTunnel:flags:
|
|
|
|
|
*
|
2020-07-01 17:20:40 -04:00
|
|
|
* Tunnel flags. Currently, the following values are supported:
|
2017-12-22 10:24:25 +01:00
|
|
|
* %NM_IP_TUNNEL_FLAG_IP6_IGN_ENCAP_LIMIT, %NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_TCLASS,
|
|
|
|
|
* %NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_FLOWLABEL, %NM_IP_TUNNEL_FLAG_IP6_MIP6_DEV,
|
|
|
|
|
* %NM_IP_TUNNEL_FLAG_IP6_RCV_DSCP_COPY, %NM_IP_TUNNEL_FLAG_IP6_USE_ORIG_FWMARK.
|
|
|
|
|
* They are valid only for IPv6 tunnels.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.12
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_FLAGS] = g_param_spec_uint(NM_SETTING_IP_TUNNEL_FLAGS,
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
0,
|
|
|
|
|
G_MAXUINT32,
|
|
|
|
|
0,
|
|
|
|
|
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE
|
|
|
|
|
| G_PARAM_STATIC_STRINGS);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
2019-01-11 08:28:26 +01:00
|
|
|
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
2020-09-28 16:03:33 +02:00
|
|
|
|
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_IP_TUNNEL);
|
2015-09-01 14:06:00 +02:00
|
|
|
}
|