diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2019-07-24 12:46:30 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2019-07-25 12:32:20 +0200 |
commit | 6cf390eb559c30ffd52803bbd40cafc21ba248ce (patch) | |
tree | 95c5b1ecc99abe212c5d7c6bb23272484facc48f | |
parent | 3cfe3c0e352f8234a8e628cc968d2a3c170d2fe4 (diff) | |
download | NetworkManager-6cf390eb559c30ffd52803bbd40cafc21ba248ce.tar.gz |
core: add ovs-bridge.datapath-type property
-rw-r--r-- | clients/common/settings-docs.h.in | 1 | ||||
-rw-r--r-- | libnm-core/nm-setting-ovs-bridge.c | 50 | ||||
-rw-r--r-- | libnm-core/nm-setting-ovs-bridge.h | 3 |
3 files changed, 54 insertions, 0 deletions
diff --git a/clients/common/settings-docs.h.in b/clients/common/settings-docs.h.in index 5316f11ccb..af32e827fc 100644 --- a/clients/common/settings-docs.h.in +++ b/clients/common/settings-docs.h.in @@ -256,6 +256,7 @@ #define DESCRIBE_DOC_NM_SETTING_MACVLAN_PROMISCUOUS N_("Whether the interface should be put in promiscuous mode.") #define DESCRIBE_DOC_NM_SETTING_MACVLAN_TAP N_("Whether the interface should be a MACVTAP.") #define DESCRIBE_DOC_NM_SETTING_MATCH_INTERFACE_NAME N_("A list of interface names to match. Each element is a shell wildcard pattern. When an element is prefixed with exclamation mark (!) the condition is inverted. A candidate interface name is considered matching when both these conditions are satisfied: (a) any of the elements not prefixed with '!' matches or there aren't such elements; (b) none of the elements prefixed with '!' match.") +#define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_DATAPATH_TYPE N_("The data path type. One of \"system\", \"netdev\" or empty.") #define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_FAIL_MODE N_("The bridge failure mode. One of \"secure\", \"standalone\" or empty.") #define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE N_("Enable or disable multicast snooping.") #define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_RSTP_ENABLE N_("Enable or disable RSTP.") diff --git a/libnm-core/nm-setting-ovs-bridge.c b/libnm-core/nm-setting-ovs-bridge.c index 4a6c197654..473bdb94a9 100644 --- a/libnm-core/nm-setting-ovs-bridge.c +++ b/libnm-core/nm-setting-ovs-bridge.c @@ -40,6 +40,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_MCAST_SNOOPING_ENABLE, PROP_RSTP_ENABLE, PROP_STP_ENABLE, + PROP_DATAPATH_TYPE, ); /** @@ -51,6 +52,7 @@ struct _NMSettingOvsBridge { NMSetting parent; char *fail_mode; + char *datapath_type; gboolean mcast_snooping_enable; gboolean rstp_enable; gboolean stp_enable; @@ -128,6 +130,22 @@ nm_setting_ovs_bridge_get_stp_enable (NMSettingOvsBridge *self) return self->stp_enable; } +/** + * nm_setting_ovs_bridge_get_datapath_type: + * @self: the #NMSettingOvsBridge + * + * Returns: the #NMSettingOvsBridge:datapath_type property of the setting + * + * Since: 1.20 + **/ +const char * +nm_setting_ovs_bridge_get_datapath_type (NMSettingOvsBridge *self) +{ + g_return_val_if_fail (NM_IS_SETTING_OVS_BRIDGE (self), NULL); + + return self->datapath_type; +} + /*****************************************************************************/ static int @@ -172,6 +190,16 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } + if (!NM_IN_STRSET (self->datapath_type, "system", "netdev", NULL)) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' is not valid"), + self->datapath_type); + g_prefix_error (error, "%s.%s: ", NM_SETTING_OVS_BRIDGE_SETTING_NAME, NM_SETTING_OVS_BRIDGE_DATAPATH_TYPE); + return FALSE; + } + return TRUE; } @@ -196,6 +224,9 @@ get_property (GObject *object, guint prop_id, case PROP_STP_ENABLE: g_value_set_boolean (value, self->stp_enable); break; + case PROP_DATAPATH_TYPE: + g_value_set_string (value, self->datapath_type); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -222,6 +253,10 @@ set_property (GObject *object, guint prop_id, case PROP_STP_ENABLE: self->stp_enable = g_value_get_boolean (value); break; + case PROP_DATAPATH_TYPE: + g_free (self->datapath_type); + self->datapath_type = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -256,6 +291,7 @@ finalize (GObject *object) NMSettingOvsBridge *self = NM_SETTING_OVS_BRIDGE (object); g_free (self->fail_mode); + g_free (self->datapath_type); G_OBJECT_CLASS (nm_setting_ovs_bridge_parent_class)->finalize (object); } @@ -329,6 +365,20 @@ nm_setting_ovs_bridge_class_init (NMSettingOvsBridgeClass *klass) G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); + /** + * NMSettingOvsBridge:datapath-type: + * + * The data path type. One of "system", "netdev" or empty. + * + * Since: 1.20 + **/ + obj_properties[PROP_DATAPATH_TYPE] = + g_param_spec_string (NM_SETTING_OVS_BRIDGE_DATAPATH_TYPE, "", "", + NULL, + G_PARAM_READWRITE | + NM_SETTING_PARAM_INFERRABLE | + G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); _nm_setting_class_commit (setting_class, NM_META_SETTING_TYPE_OVS_BRIDGE); diff --git a/libnm-core/nm-setting-ovs-bridge.h b/libnm-core/nm-setting-ovs-bridge.h index d4837e58a2..b9f92c0656 100644 --- a/libnm-core/nm-setting-ovs-bridge.h +++ b/libnm-core/nm-setting-ovs-bridge.h @@ -41,6 +41,7 @@ G_BEGIN_DECLS #define NM_SETTING_OVS_BRIDGE_MCAST_SNOOPING_ENABLE "mcast-snooping-enable" #define NM_SETTING_OVS_BRIDGE_RSTP_ENABLE "rstp-enable" #define NM_SETTING_OVS_BRIDGE_STP_ENABLE "stp-enable" +#define NM_SETTING_OVS_BRIDGE_DATAPATH_TYPE "datapath-type" typedef struct _NMSettingOvsBridgeClass NMSettingOvsBridgeClass; @@ -57,6 +58,8 @@ NM_AVAILABLE_IN_1_10 gboolean nm_setting_ovs_bridge_get_rstp_enable (NMSettingOvsBridge *self); NM_AVAILABLE_IN_1_10 gboolean nm_setting_ovs_bridge_get_stp_enable (NMSettingOvsBridge *self); +NM_AVAILABLE_IN_1_20 +const char *nm_setting_ovs_bridge_get_datapath_type (NMSettingOvsBridge *self); G_END_DECLS |