From 2aaf88375e9d608a8ce3e54ddca420644c437f7b Mon Sep 17 00:00:00 2001 From: Rahul Rajesh Date: Thu, 29 Jan 2026 17:49:02 -0500 Subject: [PATCH] geneve: add connection profile settings Added support for the following properties in connection profile: id (VNI), remote IPv4/IPv6, ttl, tos, df, destination port. See IP-LINK(8) manual page with command `man 8 ip-link` for more details on the properties. See also previous commit for nm supported attributes. id and remote are mandatory attributes: ``` $ nmcli connection add type geneve save no Error: 'id' argument is required. $ nmcli connection add type geneve id 42 save no Error: 'remote' argument is required. ``` --- docs/libnm/libnm-docs.xml | 1 + po/POTFILES.in | 1 + src/libnm-client-impl/libnm.ver | 10 + src/libnm-client-public/NetworkManager.h | 1 + src/libnm-client-public/nm-autoptr.h | 1 + ...gen-metadata-nm-settings-libnm-core.xml.in | 28 ++ src/libnm-core-impl/meson.build | 1 + src/libnm-core-impl/nm-connection.c | 16 + .../nm-meta-setting-base-impl.c | 9 + src/libnm-core-impl/nm-setting-geneve.c | 354 ++++++++++++++++++ src/libnm-core-intern/nm-core-internal.h | 1 + .../nm-meta-setting-base-impl.h | 1 + src/libnm-core-public/meson.build | 1 + src/libnm-core-public/nm-connection.h | 6 +- src/libnm-core-public/nm-core-types.h | 1 + src/libnm-core-public/nm-setting-geneve.h | 74 ++++ .../nm-meta-setting-base-impl.c | 9 + .../nm-meta-setting-base-impl.h | 1 + src/libnmc-setting/nm-meta-setting-desc.c | 60 +++ src/libnmc-setting/settings-docs.h.in | 6 + src/nmcli/connections.c | 18 +- .../gen-metadata-nm-settings-nmcli.xml.in | 32 +- vapi/NM-1.0.metadata | 1 + 23 files changed, 623 insertions(+), 10 deletions(-) create mode 100644 src/libnm-core-impl/nm-setting-geneve.c create mode 100644 src/libnm-core-public/nm-setting-geneve.h diff --git a/docs/libnm/libnm-docs.xml b/docs/libnm/libnm-docs.xml index 39f62417d1..a957f469c8 100644 --- a/docs/libnm/libnm-docs.xml +++ b/docs/libnm/libnm-docs.xml @@ -317,6 +317,7 @@ print ("NetworkManager version " + client.get_version())]]> + diff --git a/po/POTFILES.in b/po/POTFILES.in index 20bd8f253a..0bf3ca1c25 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -90,6 +90,7 @@ src/libnm-core-impl/nm-setting-connection.c src/libnm-core-impl/nm-setting-dcb.c src/libnm-core-impl/nm-setting-ethtool.c src/libnm-core-impl/nm-setting-generic.c +src/libnm-core-impl/nm-setting-geneve.c src/libnm-core-impl/nm-setting-gsm.c src/libnm-core-impl/nm-setting-hsr.c src/libnm-core-impl/nm-setting-infiniband.c diff --git a/src/libnm-client-impl/libnm.ver b/src/libnm-client-impl/libnm.ver index 5678a90d09..3d2bc79304 100644 --- a/src/libnm-client-impl/libnm.ver +++ b/src/libnm-client-impl/libnm.ver @@ -2106,8 +2106,18 @@ global: libnm_1_58_0 { global: + nm_connection_get_setting_geneve; nm_ip_config_get_clat_address; nm_ip_config_get_clat_pref64; + nm_setting_geneve_df_get_type; + nm_setting_geneve_get_destination_port; + nm_setting_geneve_get_df; + nm_setting_geneve_get_id; + nm_setting_geneve_get_remote; + nm_setting_geneve_get_tos; + nm_setting_geneve_get_ttl; + nm_setting_geneve_get_type; + nm_setting_geneve_new; nm_setting_ip4_config_clat_get_type; nm_setting_ip4_config_get_clat; nm_utils_wifi_6ghz_freqs; diff --git a/src/libnm-client-public/NetworkManager.h b/src/libnm-client-public/NetworkManager.h index 9e9a4eb839..2d1c56521e 100644 --- a/src/libnm-client-public/NetworkManager.h +++ b/src/libnm-client-public/NetworkManager.h @@ -37,6 +37,7 @@ #include "nm-setting-dummy.h" #include "nm-setting-ethtool.h" #include "nm-setting-generic.h" +#include "nm-setting-geneve.h" #include "nm-setting-gsm.h" #include "nm-setting-hostname.h" #include "nm-setting-hsr.h" diff --git a/src/libnm-client-public/nm-autoptr.h b/src/libnm-client-public/nm-autoptr.h index f4321ad3a6..f21f2970c8 100644 --- a/src/libnm-client-public/nm-autoptr.h +++ b/src/libnm-client-public/nm-autoptr.h @@ -80,6 +80,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingDcb, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingDummy, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingEthtool, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingGeneric, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingGeneve, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingGsm, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingHostname, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(NMSettingHsr, g_object_unref) diff --git a/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in b/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in index 0131ba76bf..7308db4d64 100644 --- a/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in +++ b/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in @@ -1378,6 +1378,34 @@ gprop-type="gchararray" /> + + + + + + + + diff --git a/src/libnm-core-impl/meson.build b/src/libnm-core-impl/meson.build index 610e22792e..1eee3184e5 100644 --- a/src/libnm-core-impl/meson.build +++ b/src/libnm-core-impl/meson.build @@ -17,6 +17,7 @@ libnm_core_settings_sources = files( 'nm-setting-dummy.c', 'nm-setting-ethtool.c', 'nm-setting-generic.c', + 'nm-setting-geneve.c', 'nm-setting-gsm.c', 'nm-setting-hostname.c', 'nm-setting-hsr.c', diff --git a/src/libnm-core-impl/nm-connection.c b/src/libnm-core-impl/nm-connection.c index 0fbadfb85c..d7e19627df 100644 --- a/src/libnm-core-impl/nm-connection.c +++ b/src/libnm-core-impl/nm-connection.c @@ -3526,6 +3526,22 @@ nm_connection_get_setting_generic(NMConnection *connection) return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_GENERIC); } +/** + * nm_connection_get_setting_geneve: + * @connection: the #NMConnection + * + * A shortcut to return any #NMSettingGeneve the connection might contain. + * + * Returns: (transfer none): an #NMSettingGeneve if the connection contains one, otherwise NULL + * + * Since: 1.58 + **/ +NMSettingGeneve * +nm_connection_get_setting_geneve(NMConnection *connection) +{ + return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_GENEVE); +} + /** * nm_connection_get_setting_gsm: * @connection: the #NMConnection diff --git a/src/libnm-core-impl/nm-meta-setting-base-impl.c b/src/libnm-core-impl/nm-meta-setting-base-impl.c index 52af9ad259..d84490d238 100644 --- a/src/libnm-core-impl/nm-meta-setting-base-impl.c +++ b/src/libnm-core-impl/nm-meta-setting-base-impl.c @@ -27,6 +27,7 @@ #include "nm-setting-dummy.h" #include "nm-setting-ethtool.h" #include "nm-setting-generic.h" +#include "nm-setting-geneve.h" #include "nm-setting-gsm.h" #include "nm-setting-hostname.h" #include "nm-setting-hsr.h" @@ -324,6 +325,13 @@ const NMMetaSettingInfo nm_meta_setting_infos[] = { .setting_name = NM_SETTING_GENERIC_SETTING_NAME, .get_setting_gtype = nm_setting_generic_get_type, }, + [NM_META_SETTING_TYPE_GENEVE] = + { + .meta_type = NM_META_SETTING_TYPE_GENEVE, + .setting_priority = NM_SETTING_PRIORITY_HW_BASE, + .setting_name = NM_SETTING_GENEVE_SETTING_NAME, + .get_setting_gtype = nm_setting_geneve_get_type, + }, [NM_META_SETTING_TYPE_GSM] = { .meta_type = NM_META_SETTING_TYPE_GSM, @@ -655,6 +663,7 @@ const NMMetaSettingType nm_meta_setting_types_by_priority[] = { NM_META_SETTING_TYPE_CDMA, NM_META_SETTING_TYPE_DUMMY, NM_META_SETTING_TYPE_GENERIC, + NM_META_SETTING_TYPE_GENEVE, NM_META_SETTING_TYPE_GSM, NM_META_SETTING_TYPE_HSR, NM_META_SETTING_TYPE_INFINIBAND, diff --git a/src/libnm-core-impl/nm-setting-geneve.c b/src/libnm-core-impl/nm-setting-geneve.c new file mode 100644 index 0000000000..d6426a06ff --- /dev/null +++ b/src/libnm-core-impl/nm-setting-geneve.c @@ -0,0 +1,354 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026 Red Hat, Inc. + */ + +#include "libnm-core-impl/nm-default-libnm-core.h" + +#include "nm-setting-geneve.h" + +#include + +#include "nm-utils.h" +#include "nm-setting-private.h" + +/** + * SECTION:nm-setting-geneve + * @short_description: Describes connection properties for GENEVE interfaces + * + * The #NMSettingGeneve object is a #NMSetting subclass that describes properties + * necessary for connection to GENEVE interfaces. + **/ + +#define DST_PORT_DEFAULT 6081 + +NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_ID, + PROP_REMOTE, + PROP_DESTINATION_PORT, + PROP_TOS, + PROP_TTL, + PROP_DF, ); + +typedef struct { + char *remote; + guint32 id; + guint32 destination_port; + guint32 tos; + gint32 ttl; + int df; +} NMSettingGenevePrivate; + +/** + * NMSettingGeneve: + * + * GENEVE Settings + */ +struct _NMSettingGeneve { + NMSetting parent; + NMSettingGenevePrivate _priv; +}; + +struct _NMSettingGeneveClass { + NMSettingClass parent; +}; + +G_DEFINE_TYPE(NMSettingGeneve, nm_setting_geneve, NM_TYPE_SETTING) + +#define NM_SETTING_GENEVE_GET_PRIVATE(o) \ + _NM_GET_PRIVATE(o, NMSettingGeneve, NM_IS_SETTING_GENEVE, NMSetting) + +/*****************************************************************************/ + +/** + * nm_setting_geneve_get_id: + * @setting: the #NMSettingGeneve + * + * Returns: the #NMSettingGeneve:id property of the setting + * + * Since: 1.58 + **/ +guint +nm_setting_geneve_get_id(NMSettingGeneve *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_GENEVE(setting), 0); + + return NM_SETTING_GENEVE_GET_PRIVATE(setting)->id; +} + +/** + * nm_setting_geneve_get_remote: + * @setting: the #NMSettingGeneve + * + * Returns: the #NMSettingGeneve:remote property of the setting + * + * Since: 1.58 + **/ +const char * +nm_setting_geneve_get_remote(NMSettingGeneve *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_GENEVE(setting), NULL); + + return NM_SETTING_GENEVE_GET_PRIVATE(setting)->remote; +} + +/** + * nm_setting_geneve_get_destination_port: + * @setting: the #NMSettingGeneve + * + * Returns: the #NMSettingGeneve:destination-port property of the setting + * + * Since: 1.58 + **/ +guint +nm_setting_geneve_get_destination_port(NMSettingGeneve *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_GENEVE(setting), DST_PORT_DEFAULT); + + return NM_SETTING_GENEVE_GET_PRIVATE(setting)->destination_port; +} + +/** + * nm_setting_geneve_get_tos: + * @setting: the #NMSettingGeneve + * + * Returns: the #NMSettingGeneve:tos property of the setting + * + * Since: 1.58 + **/ +guint +nm_setting_geneve_get_tos(NMSettingGeneve *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_GENEVE(setting), 0); + + return NM_SETTING_GENEVE_GET_PRIVATE(setting)->tos; +} + +/** + * nm_setting_geneve_get_ttl: + * @setting: the #NMSettingGeneve + * + * Returns: the #NMSettingGeneve:ttl property of the setting + * + * Since: 1.58 + **/ +guint +nm_setting_geneve_get_ttl(NMSettingGeneve *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_GENEVE(setting), 0); + + return NM_SETTING_GENEVE_GET_PRIVATE(setting)->ttl; +} + +/** + * nm_setting_geneve_get_df: + * @setting: the #NMSettingGeneve + * + * Returns: the #NMSettingGeneve:df property of the setting + * + * Since: 1.58 + **/ +NMSettingGeneveDf +nm_setting_geneve_get_df(NMSettingGeneve *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_GENEVE(setting), NM_SETTING_GENEVE_DF_UNSET); + + return NM_SETTING_GENEVE_GET_PRIVATE(setting)->df; +} + +/*****************************************************************************/ + +static gboolean +verify(NMSetting *setting, NMConnection *connection, GError **error) +{ + NMSettingGenevePrivate *priv = NM_SETTING_GENEVE_GET_PRIVATE(setting); + + if (priv->id == 0) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("property is required")); + g_prefix_error(error, "%s.%s: ", NM_SETTING_GENEVE_SETTING_NAME, NM_SETTING_GENEVE_ID); + return FALSE; + } + + if (!priv->remote) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_MISSING_PROPERTY, + _("property is required")); + g_prefix_error(error, "%s.%s: ", NM_SETTING_GENEVE_SETTING_NAME, NM_SETTING_GENEVE_REMOTE); + return FALSE; + } + + if (!nm_inet_parse_bin(AF_UNSPEC, priv->remote, NULL, NULL)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' is not a valid IP address"), + priv->remote); + g_prefix_error(error, "%s.%s: ", NM_SETTING_GENEVE_SETTING_NAME, NM_SETTING_GENEVE_REMOTE); + return FALSE; + } + + return TRUE; +} + +/*****************************************************************************/ + +static void +nm_setting_geneve_init(NMSettingGeneve *self) +{} + +/** + * nm_setting_geneve_new: + * + * Creates a new #NMSettingGeneve object with default values. + * + * Returns: (transfer full): the new empty #NMSettingGeneve object + * + * Since: 1.58 + **/ +NMSetting * +nm_setting_geneve_new(void) +{ + return g_object_new(NM_TYPE_SETTING_GENEVE, NULL); +} + +static void +nm_setting_geneve_class_init(NMSettingGeneveClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GArray *properties_override = _nm_sett_info_property_override_create_array(); + + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; + + setting_class->verify = verify; + + /** + * NMSettingGeneve:id: + * + * Specifies the GENEVE Network Identifier (or GENEVE Segment Identifier) to + * use. + * + * Since: 1.58 + **/ + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_GENEVE_ID, + PROP_ID, + 0, + (1 << 24) - 1, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingGenevePrivate, + id); + + /** + * NMSettingGeneve:remote: + * + * Specifies the unicast destination IP address to use in outgoing packets + * when communicating with the remote GENEVE tunnel endpoint. + * + * Since: 1.58 + **/ + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_GENEVE_REMOTE, + PROP_REMOTE, + NM_SETTING_PARAM_REQUIRED, + NMSettingGenevePrivate, + remote, + .direct_set_string_ip_address_addr_family = + AF_UNSPEC + 1, + .direct_string_allow_empty = TRUE); + + /** + * NMSettingGeneve:destination-port: + * + * Specifies the UDP destination port to communicate to the remote GENEVE + * tunnel endpoint. + * + * Since: 1.58 + **/ + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_GENEVE_DESTINATION_PORT, + PROP_DESTINATION_PORT, + 0, + G_MAXUINT16, + DST_PORT_DEFAULT, + NM_SETTING_PARAM_INFERRABLE, + NMSettingGenevePrivate, + destination_port); + + /** + * NMSettingGeneve:tos: + * + * Specifies the TOS value to use in outgoing packets. + * The special value "inherit" (1) means inherit from outer packet. + * + * Since: 1.58 + **/ + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_GENEVE_TOS, + PROP_TOS, + 0, + 255, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingGenevePrivate, + tos); + + /** + * NMSettingGeneve:ttl: + * + * Specifies the time-to-live value to use in outgoing packets. + * The special value "inherit" (-1) means inherit from outer packet, 0 means auto, 1-255 are fixed values. + * + * Since: 1.58 + **/ + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_GENEVE_TTL, + PROP_TTL, + -1, + 255, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingGenevePrivate, + ttl); + + /** + * NMSettingGeneve:df: + * + * Specifies how the Don't Fragment (DF) flag should be handled in the outer IP + * header of GENEVE tunnel packets. + * + * %NM_SETTING_GENEVE_DF_UNSET (0): Don't set the DF flag, packets may be fragmented. + * %NM_SETTING_GENEVE_DF_SET (1): Always set the DF flag, packets will not be fragmented. + * %NM_SETTING_GENEVE_DF_INHERIT (2): Inherit the DF flag from the inner IP header. + * + * Since: 1.58 + **/ + _nm_setting_property_define_direct_enum(properties_override, + obj_properties, + NM_SETTING_GENEVE_DF, + PROP_DF, + NM_TYPE_SETTING_GENEVE_DF, + NM_SETTING_GENEVE_DF_UNSET, + NM_SETTING_PARAM_INFERRABLE, + NULL, + NMSettingGenevePrivate, + df); + + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_GENEVE, + NULL, + properties_override, + G_STRUCT_OFFSET(NMSettingGeneve, _priv)); +} diff --git a/src/libnm-core-intern/nm-core-internal.h b/src/libnm-core-intern/nm-core-internal.h index f1fc76a563..9a7633281e 100644 --- a/src/libnm-core-intern/nm-core-internal.h +++ b/src/libnm-core-intern/nm-core-internal.h @@ -37,6 +37,7 @@ #include "nm-setting-dcb.h" #include "nm-setting-dummy.h" #include "nm-setting-generic.h" +#include "nm-setting-geneve.h" #include "nm-setting-gsm.h" #include "nm-setting-hsr.h" #include "nm-setting-hostname.h" diff --git a/src/libnm-core-intern/nm-meta-setting-base-impl.h b/src/libnm-core-intern/nm-meta-setting-base-impl.h index d1535e5e1f..8f512d09c6 100644 --- a/src/libnm-core-intern/nm-meta-setting-base-impl.h +++ b/src/libnm-core-intern/nm-meta-setting-base-impl.h @@ -121,6 +121,7 @@ typedef enum _nm_packed { NM_META_SETTING_TYPE_DUMMY, NM_META_SETTING_TYPE_ETHTOOL, NM_META_SETTING_TYPE_GENERIC, + NM_META_SETTING_TYPE_GENEVE, NM_META_SETTING_TYPE_GSM, NM_META_SETTING_TYPE_HOSTNAME, NM_META_SETTING_TYPE_HSR, diff --git a/src/libnm-core-public/meson.build b/src/libnm-core-public/meson.build index 086801d96d..2a4f143f75 100644 --- a/src/libnm-core-public/meson.build +++ b/src/libnm-core-public/meson.build @@ -22,6 +22,7 @@ libnm_core_headers = files( 'nm-setting-dummy.h', 'nm-setting-ethtool.h', 'nm-setting-generic.h', + 'nm-setting-geneve.h', 'nm-setting-gsm.h', 'nm-setting-hsr.h', 'nm-setting-hostname.h', diff --git a/src/libnm-core-public/nm-connection.h b/src/libnm-core-public/nm-connection.h index ff3e0f924a..db73711f69 100644 --- a/src/libnm-core-public/nm-connection.h +++ b/src/libnm-core-public/nm-connection.h @@ -206,8 +206,10 @@ NMSettingCdma *nm_connection_get_setting_cdma(NMConnection *connection); NMSettingConnection *nm_connection_get_setting_connection(NMConnection *connection); NMSettingDcb *nm_connection_get_setting_dcb(NMConnection *connection); NM_AVAILABLE_IN_1_8 -NMSettingDummy *nm_connection_get_setting_dummy(NMConnection *connection); -NMSettingGeneric *nm_connection_get_setting_generic(NMConnection *connection); +NMSettingDummy *nm_connection_get_setting_dummy(NMConnection *connection); +NMSettingGeneric *nm_connection_get_setting_generic(NMConnection *connection); +NM_AVAILABLE_IN_1_58 +NMSettingGeneve *nm_connection_get_setting_geneve(NMConnection *connection); NMSettingGsm *nm_connection_get_setting_gsm(NMConnection *connection); NMSettingInfiniband *nm_connection_get_setting_infiniband(NMConnection *connection); NM_AVAILABLE_IN_1_2 diff --git a/src/libnm-core-public/nm-core-types.h b/src/libnm-core-public/nm-core-types.h index 617d6b7415..81743e31d7 100644 --- a/src/libnm-core-public/nm-core-types.h +++ b/src/libnm-core-public/nm-core-types.h @@ -27,6 +27,7 @@ typedef struct _NMSettingConnection NMSettingConnection; typedef struct _NMSettingDcb NMSettingDcb; typedef struct _NMSettingDummy NMSettingDummy; typedef struct _NMSettingEthtool NMSettingEthtool; +typedef struct _NMSettingGeneve NMSettingGeneve; typedef struct _NMSettingGeneric NMSettingGeneric; typedef struct _NMSettingGsm NMSettingGsm; typedef struct _NMSettingHostname NMSettingHostname; diff --git a/src/libnm-core-public/nm-setting-geneve.h b/src/libnm-core-public/nm-setting-geneve.h new file mode 100644 index 0000000000..bff8fba1b2 --- /dev/null +++ b/src/libnm-core-public/nm-setting-geneve.h @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026 Red Hat, Inc. + */ + +#ifndef __NM_SETTING_GENEVE_H__ +#define __NM_SETTING_GENEVE_H__ + +#if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION) +#error "Only can be included directly." +#endif + +#include "nm-setting.h" + +G_BEGIN_DECLS + +#define NM_TYPE_SETTING_GENEVE (nm_setting_geneve_get_type()) +#define NM_SETTING_GENEVE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_SETTING_GENEVE, NMSettingGeneve)) +#define NM_SETTING_GENEVE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_SETTING_GENEVE, NMSettingGeneveClass)) +#define NM_IS_SETTING_GENEVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_SETTING_GENEVE)) +#define NM_IS_SETTING_GENEVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_SETTING_GENEVE)) +#define NM_SETTING_GENEVE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_SETTING_GENEVE, NMSettingGeneveClass)) + +#define NM_SETTING_GENEVE_SETTING_NAME "geneve" + +#define NM_SETTING_GENEVE_ID "id" +#define NM_SETTING_GENEVE_REMOTE "remote" +#define NM_SETTING_GENEVE_DESTINATION_PORT "destination-port" +#define NM_SETTING_GENEVE_TOS "tos" +#define NM_SETTING_GENEVE_TTL "ttl" +#define NM_SETTING_GENEVE_DF "df" + +/** + * NMSettingGeneveDf: + * @NM_SETTING_GENEVE_DF_UNSET: Don't set the DF flag, packets may be fragmented. + * @NM_SETTING_GENEVE_DF_SET: Always set the DF flag, packets will not be fragmented. + * @NM_SETTING_GENEVE_DF_INHERIT: Inherit the DF flag from the inner IP header. + * + * #NMSettingGeneveDf values indicate how the Don't Fragment (DF) flag should be handled + * in the outer IP header of GENEVE tunnel packets. + * + * Since: 1.58 + */ +typedef enum { + NM_SETTING_GENEVE_DF_UNSET = 0, + NM_SETTING_GENEVE_DF_SET = 1, + NM_SETTING_GENEVE_DF_INHERIT = 2, +} NMSettingGeneveDf; + +typedef struct _NMSettingGeneveClass NMSettingGeneveClass; + +NM_AVAILABLE_IN_1_58 +GType nm_setting_geneve_get_type(void); +NM_AVAILABLE_IN_1_58 +NMSetting *nm_setting_geneve_new(void); +NM_AVAILABLE_IN_1_58 +guint nm_setting_geneve_get_id(NMSettingGeneve *setting); +NM_AVAILABLE_IN_1_58 +const char *nm_setting_geneve_get_remote(NMSettingGeneve *setting); +NM_AVAILABLE_IN_1_58 +guint nm_setting_geneve_get_destination_port(NMSettingGeneve *setting); +NM_AVAILABLE_IN_1_58 +guint nm_setting_geneve_get_tos(NMSettingGeneve *setting); +NM_AVAILABLE_IN_1_58 +guint nm_setting_geneve_get_ttl(NMSettingGeneve *setting); +NM_AVAILABLE_IN_1_58 +NMSettingGeneveDf nm_setting_geneve_get_df(NMSettingGeneve *setting); + +G_END_DECLS + +#endif /* __NM_SETTING_GENEVE_H__ */ diff --git a/src/libnmc-setting/nm-meta-setting-base-impl.c b/src/libnmc-setting/nm-meta-setting-base-impl.c index 52af9ad259..d84490d238 100644 --- a/src/libnmc-setting/nm-meta-setting-base-impl.c +++ b/src/libnmc-setting/nm-meta-setting-base-impl.c @@ -27,6 +27,7 @@ #include "nm-setting-dummy.h" #include "nm-setting-ethtool.h" #include "nm-setting-generic.h" +#include "nm-setting-geneve.h" #include "nm-setting-gsm.h" #include "nm-setting-hostname.h" #include "nm-setting-hsr.h" @@ -324,6 +325,13 @@ const NMMetaSettingInfo nm_meta_setting_infos[] = { .setting_name = NM_SETTING_GENERIC_SETTING_NAME, .get_setting_gtype = nm_setting_generic_get_type, }, + [NM_META_SETTING_TYPE_GENEVE] = + { + .meta_type = NM_META_SETTING_TYPE_GENEVE, + .setting_priority = NM_SETTING_PRIORITY_HW_BASE, + .setting_name = NM_SETTING_GENEVE_SETTING_NAME, + .get_setting_gtype = nm_setting_geneve_get_type, + }, [NM_META_SETTING_TYPE_GSM] = { .meta_type = NM_META_SETTING_TYPE_GSM, @@ -655,6 +663,7 @@ const NMMetaSettingType nm_meta_setting_types_by_priority[] = { NM_META_SETTING_TYPE_CDMA, NM_META_SETTING_TYPE_DUMMY, NM_META_SETTING_TYPE_GENERIC, + NM_META_SETTING_TYPE_GENEVE, NM_META_SETTING_TYPE_GSM, NM_META_SETTING_TYPE_HSR, NM_META_SETTING_TYPE_INFINIBAND, diff --git a/src/libnmc-setting/nm-meta-setting-base-impl.h b/src/libnmc-setting/nm-meta-setting-base-impl.h index d1535e5e1f..8f512d09c6 100644 --- a/src/libnmc-setting/nm-meta-setting-base-impl.h +++ b/src/libnmc-setting/nm-meta-setting-base-impl.h @@ -121,6 +121,7 @@ typedef enum _nm_packed { NM_META_SETTING_TYPE_DUMMY, NM_META_SETTING_TYPE_ETHTOOL, NM_META_SETTING_TYPE_GENERIC, + NM_META_SETTING_TYPE_GENEVE, NM_META_SETTING_TYPE_GSM, NM_META_SETTING_TYPE_HOSTNAME, NM_META_SETTING_TYPE_HSR, diff --git a/src/libnmc-setting/nm-meta-setting-desc.c b/src/libnmc-setting/nm-meta-setting-desc.c index 5ce86e8bcb..6c9a5c0c1b 100644 --- a/src/libnmc-setting/nm-meta-setting-desc.c +++ b/src/libnmc-setting/nm-meta-setting-desc.c @@ -6112,6 +6112,57 @@ static const NMMetaPropertyInfo *const property_infos_GENERIC[] = { NULL }; +#undef _CURRENT_NM_META_SETTING_TYPE +#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_GENEVE +static const NMMetaPropertyInfo *const property_infos_GENEVE[] = { + PROPERTY_INFO_WITH_DESC (NM_SETTING_GENEVE_ID, + .is_cli_option = TRUE, + .property_alias = "id", + .inf_flags = NM_META_PROPERTY_INF_FLAG_REQD, + .prompt = N_("GENEVE ID"), + .property_type = &_pt_gobject_int, + ), + PROPERTY_INFO_WITH_DESC (NM_SETTING_GENEVE_REMOTE, + .is_cli_option = TRUE, + .property_alias = "remote", + .inf_flags = NM_META_PROPERTY_INF_FLAG_REQD, + .prompt = N_("Remote"), + .property_type = &_pt_gobject_string, + ), + PROPERTY_INFO_WITH_DESC (NM_SETTING_GENEVE_DESTINATION_PORT, + .is_cli_option = TRUE, + .property_alias = "destination-port", + .prompt = N_("Destination port"), + .property_type = &_pt_gobject_int, + ), + PROPERTY_INFO_WITH_DESC (NM_SETTING_GENEVE_TOS, + .property_type = &_pt_gobject_int, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_int, + .value_infos = INT_VALUE_INFOS ( + { + .value.u64 = 1, + .nick = "inherit", + }, + ), + ), + ), + PROPERTY_INFO_WITH_DESC (NM_SETTING_GENEVE_TTL, + .property_type = &_pt_gobject_int, + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_int, + .value_infos = INT_VALUE_INFOS ( + { + .value.i64 = -1, + .nick = "inherit", + }, + ), + ), + ), + PROPERTY_INFO_WITH_DESC (NM_SETTING_GENEVE_DF, + .property_type = &_pt_gobject_enum, + ), + NULL +}; + #undef _CURRENT_NM_META_SETTING_TYPE #define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_GSM static const NMMetaPropertyInfo *const property_infos_GSM[] = { @@ -9018,6 +9069,7 @@ _setting_init_fcn_wireless (ARGS_SETTING_INIT_FCN) #define SETTING_PRETTY_NAME_DUMMY N_("Dummy settings") #define SETTING_PRETTY_NAME_ETHTOOL N_("Ethtool settings") #define SETTING_PRETTY_NAME_GENERIC N_("Generic settings") +#define SETTING_PRETTY_NAME_GENEVE N_("Geneve settings") #define SETTING_PRETTY_NAME_GSM N_("GSM mobile broadband connection") #define SETTING_PRETTY_NAME_HOSTNAME N_("Hostname settings") #define SETTING_PRETTY_NAME_HSR N_("HSR settings") @@ -9156,6 +9208,14 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = { NM_META_SETTING_VALID_PART_ITEM (GENERIC, TRUE), ), ), + SETTING_INFO (GENEVE, + .valid_parts = NM_META_SETTING_VALID_PARTS ( + NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE), + NM_META_SETTING_VALID_PART_ITEM (GENEVE, TRUE), + NM_META_SETTING_VALID_PART_ITEM (WIRED, FALSE), + NM_META_SETTING_VALID_PART_ITEM (ETHTOOL, FALSE), + ), + ), SETTING_INFO (GSM, .valid_parts = NM_META_SETTING_VALID_PARTS ( NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE), diff --git a/src/libnmc-setting/settings-docs.h.in b/src/libnmc-setting/settings-docs.h.in index e02a93e43d..97848c8a67 100644 --- a/src/libnmc-setting/settings-docs.h.in +++ b/src/libnmc-setting/settings-docs.h.in @@ -499,6 +499,12 @@ #define DESCRIBE_DOC_NM_SETTING_WPAN_SHORT_ADDRESS N_("Short IEEE 802.15.4 address to be used within a restricted environment.") #define DESCRIBE_DOC_NM_SETTING_BOND_PORT_PRIO N_("The port priority for bond active port re-selection during failover. A higher number means a higher priority in selection. The primary port has the highest priority. This option is only compatible with active-backup, balance-tlb and balance-alb modes.") #define DESCRIBE_DOC_NM_SETTING_BOND_PORT_QUEUE_ID N_("The queue ID of this bond port. The maximum value of queue ID is the number of TX queues currently active in device.") +#define DESCRIBE_DOC_NM_SETTING_GENEVE_DESTINATION_PORT N_("Specifies the UDP destination port to communicate to the remote GENEVE tunnel endpoint.") +#define DESCRIBE_DOC_NM_SETTING_GENEVE_DF N_("Specifies how the Don't Fragment (DF) flag should be handled in the outer IP header of GENEVE tunnel packets. \"unset\" (0) (0): Don't set the DF flag, packets may be fragmented. \"set\" (1) (1): Always set the DF flag, packets will not be fragmented. \"inherit\" (2) (2): Inherit the DF flag from the inner IP header.") +#define DESCRIBE_DOC_NM_SETTING_GENEVE_ID N_("Specifies the GENEVE Network Identifier (or GENEVE Segment Identifier) to use.") +#define DESCRIBE_DOC_NM_SETTING_GENEVE_REMOTE N_("Specifies the unicast destination IP address to use in outgoing packets when communicating with the remote GENEVE tunnel endpoint.") +#define DESCRIBE_DOC_NM_SETTING_GENEVE_TOS N_("Specifies the TOS value to use in outgoing packets. The special value \"inherit\" (1) means inherit from outer packet.") +#define DESCRIBE_DOC_NM_SETTING_GENEVE_TTL N_("Specifies the time-to-live value to use in outgoing packets. The special value \"inherit\" (-1) means inherit from outer packet, 0 means auto, 1-255 are fixed values.") #define DESCRIBE_DOC_NM_SETTING_HOSTNAME_FROM_DHCP N_("Whether the system hostname can be determined from DHCP on this connection. When set to \"default\" (-1), the value from global configuration is used. If the property doesn't have a value in the global configuration, NetworkManager assumes the value to be \"true\" (1).") #define DESCRIBE_DOC_NM_SETTING_HOSTNAME_FROM_DNS_LOOKUP N_("Whether the system hostname can be determined from reverse DNS lookup of addresses on this device. When set to \"default\" (-1), the value from global configuration is used. If the property doesn't have a value in the global configuration, NetworkManager assumes the value to be \"true\" (1).") #define DESCRIBE_DOC_NM_SETTING_HOSTNAME_ONLY_FROM_DEFAULT N_("If set to \"true\" (1), NetworkManager attempts to get the hostname via DHCPv4/DHCPv6 or reverse DNS lookup on this device only when the device has the default route for the given address family (IPv4/IPv6). If set to \"false\" (0), the hostname can be set from this device even if it doesn't have the default route. When set to \"default\" (-1), the value from global configuration is used. If the property doesn't have a value in the global configuration, NetworkManager assumes the value to be \"false\" (0).") diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index d93e16f03c..a3b03efe31 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -4,6 +4,7 @@ */ #include "libnm-client-aux-extern/nm-default-client.h" +#include "nmcli.h" #include "connections.h" @@ -1070,13 +1071,13 @@ const NmcMetaGenericInfo "," NM_SETTING_DCB_SETTING_NAME "," NM_SETTING_TUN_SETTING_NAME \ "," NM_SETTING_IP_TUNNEL_SETTING_NAME "," NM_SETTING_MACSEC_SETTING_NAME \ "," NM_SETTING_MACVLAN_SETTING_NAME "," NM_SETTING_VXLAN_SETTING_NAME \ - "," NM_SETTING_VRF_SETTING_NAME "," NM_SETTING_WPAN_SETTING_NAME \ - "," NM_SETTING_6LOWPAN_SETTING_NAME "," NM_SETTING_WIREGUARD_SETTING_NAME \ - "," NM_SETTING_LINK_SETTING_NAME "," NM_SETTING_PROXY_SETTING_NAME \ - "," NM_SETTING_TC_CONFIG_SETTING_NAME "," NM_SETTING_SRIOV_SETTING_NAME \ - "," NM_SETTING_ETHTOOL_SETTING_NAME "," NM_SETTING_OVS_DPDK_SETTING_NAME \ - "," NM_SETTING_HOSTNAME_SETTING_NAME "," NM_SETTING_HSR_SETTING_NAME \ - "," NM_SETTING_IPVLAN_SETTING_NAME + "," NM_SETTING_GENEVE_SETTING_NAME "," NM_SETTING_VRF_SETTING_NAME \ + "," NM_SETTING_WPAN_SETTING_NAME "," NM_SETTING_6LOWPAN_SETTING_NAME \ + "," NM_SETTING_WIREGUARD_SETTING_NAME "," NM_SETTING_LINK_SETTING_NAME \ + "," NM_SETTING_PROXY_SETTING_NAME "," NM_SETTING_TC_CONFIG_SETTING_NAME \ + "," NM_SETTING_SRIOV_SETTING_NAME "," NM_SETTING_ETHTOOL_SETTING_NAME \ + "," NM_SETTING_OVS_DPDK_SETTING_NAME "," NM_SETTING_HOSTNAME_SETTING_NAME \ + "," NM_SETTING_HSR_SETTING_NAME "," NM_SETTING_IPVLAN_SETTING_NAME /* NM_SETTING_DUMMY_SETTING_NAME NM_SETTING_WIMAX_SETTING_NAME */ const NmcMetaGenericInfo *const nmc_fields_con_active_details_groups[] = { @@ -1306,6 +1307,9 @@ usage_connection_add(void) " [source-port-min <0-65535>]\n" " [source-port-max <0-65535>]\n" " [destination-port <0-65535>]\n\n" + " geneve: id \n" + " remote \n" + " [destination-port <0-65535>]\n\n" " wpan: [short-addr <0x0000-0xffff>]\n" " [pan-id <0x0000-0xffff>]\n" " [page ]\n" diff --git a/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in b/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in index 8733cc995b..8b98e95e24 100644 --- a/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in +++ b/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in @@ -629,7 +629,7 @@ alias="type" nmcli-description="Base type of the connection. For hardware-dependent connections, should contain the setting name of the hardware-type specific setting (ie, "802-3-ethernet" or "802-11-wireless" or "bluetooth", etc), and for non-hardware dependent connections like VPN or otherwise, should contain the setting name of that setting type (ie, "vpn" or "bridge", etc)." format="string" - values="6lowpan, 802-11-olpc-mesh, 802-11-wireless, 802-3-ethernet, adsl, bluetooth, bond, bridge, cdma, dummy, generic, gsm, hsr, infiniband, ip-tunnel, ipvlan, loopback, macsec, macvlan, ovs-bridge, ovs-interface, ovs-port, pppoe, team, tun, veth, vlan, vpn, vrf, vxlan, wifi-p2p, wimax, wireguard, wpan" /> + values="6lowpan, 802-11-olpc-mesh, 802-11-wireless, 802-3-ethernet, adsl, bluetooth, bond, bridge, cdma, dummy, generic, geneve, gsm, hsr, infiniband, ip-tunnel, ipvlan, loopback, macsec, macvlan, ovs-bridge, ovs-interface, ovs-port, pppoe, team, tun, veth, vlan, vpn, vrf, vxlan, wifi-p2p, wimax, wireguard, wpan" /> + + + + + + + +