summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojtech Bubela <vbubela@redhat.com>2022-08-31 11:25:32 +0200
committerVojtech Bubela <vbubela@redhat.com>2022-09-02 08:46:36 +0000
commit5fde7814dc32446ac591b654d79fc71c156ab8ef (patch)
tree800927abdb6c75675fde69acf9aa6c8da3b1d9bd
parent39e8707f0ded9b9c88a19d5935605c7ab432b89f (diff)
downloadNetworkManager-add-ovs-option.tar.gz
ovs: add ofport_request option to ovs interfaceadd-ovs-option
Add option to set ofport_request when configuring ovs interface. When connection with ofport_request configured is activated ovsdb will first try to activated on the port set by ofport_request.
-rw-r--r--src/core/devices/ovs/nm-ovsdb.c12
-rw-r--r--src/libnm-client-impl/libnm.ver5
-rw-r--r--src/libnm-core-impl/nm-setting-ovs-interface.c42
-rw-r--r--src/libnm-core-public/nm-setting-ovs-interface.h5
-rw-r--r--src/libnmc-setting/nm-meta-setting-desc.c3
-rw-r--r--src/libnmc-setting/settings-docs.h.in1
-rw-r--r--src/nmcli/generate-docs-nm-settings-nmcli.xml.in2
7 files changed, 65 insertions, 5 deletions
diff --git a/src/core/devices/ovs/nm-ovsdb.c b/src/core/devices/ovs/nm-ovsdb.c
index e7c9685240..c1f0886d41 100644
--- a/src/core/devices/ovs/nm-ovsdb.c
+++ b/src/core/devices/ovs/nm-ovsdb.c
@@ -767,11 +767,14 @@ _insert_interface(json_t *params,
NMSettingOvsPatch *s_ovs_patch;
json_t *options = json_array();
json_t *row;
- guint32 mtu = 0;
+ guint32 mtu = 0;
+ guint32 ofport_request = 0;
s_ovs_iface = nm_connection_get_setting_ovs_interface(interface);
- if (s_ovs_iface)
- type = nm_setting_ovs_interface_get_interface_type(s_ovs_iface);
+ if (s_ovs_iface) {
+ type = nm_setting_ovs_interface_get_interface_type(s_ovs_iface);
+ ofport_request = nm_setting_ovs_interface_get_ofport_request(s_ovs_iface);
+ }
if (nm_streq0(type, "internal")) {
NMSettingWired *s_wired;
@@ -828,6 +831,9 @@ _insert_interface(json_t *params,
if (mtu != 0)
json_object_set_new(row, "mtu_request", json_integer(mtu));
+ if (ofport_request != 0)
+ json_object_set_new(row, "ofport_request", json_integer(ofport_request));
+
json_array_append_new(params,
json_pack("{s:s, s:s, s:o, s:s}",
"op",
diff --git a/src/libnm-client-impl/libnm.ver b/src/libnm-client-impl/libnm.ver
index e414b7e64d..4a5455ede0 100644
--- a/src/libnm-client-impl/libnm.ver
+++ b/src/libnm-client-impl/libnm.ver
@@ -1844,3 +1844,8 @@ global:
nm_setting_ip4_link_local_get_type;
nm_setting_ip6_config_get_mtu;
} libnm_1_38_0;
+
+libnm_1_42_0 {
+global:
+ nm_setting_ovs_interface_get_ofport_request;
+} libnm_1_40_0;
diff --git a/src/libnm-core-impl/nm-setting-ovs-interface.c b/src/libnm-core-impl/nm-setting-ovs-interface.c
index 6554f5206e..34e6648006 100644
--- a/src/libnm-core-impl/nm-setting-ovs-interface.c
+++ b/src/libnm-core-impl/nm-setting-ovs-interface.c
@@ -21,7 +21,7 @@
/*****************************************************************************/
-NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_TYPE, );
+NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_TYPE, PROP_OFPORT_REQUEST, );
/**
* NMSettingOvsInterface:
@@ -31,7 +31,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_TYPE, );
struct _NMSettingOvsInterface {
NMSetting parent;
- char *type;
+ char *type;
+ guint32 ofport_request;
};
struct _NMSettingOvsInterfaceClass {
@@ -58,6 +59,22 @@ nm_setting_ovs_interface_get_interface_type(NMSettingOvsInterface *self)
return self->type;
}
+/**
+ * nm_setting_ovs_interface_get_ofport_request:
+ * @self: the #NMSettingOvsInterface
+ *
+ * Returns: id of the preassigned ovs port
+ *
+ * Since: 1.42
+ **/
+guint32
+nm_setting_ovs_interface_get_ofport_request(NMSettingOvsInterface *self)
+{
+ g_return_val_if_fail(NM_IS_SETTING_OVS_INTERFACE(self), 0);
+
+ return self->ofport_request;
+}
+
/*****************************************************************************/
int
@@ -378,6 +395,27 @@ nm_setting_ovs_interface_class_init(NMSettingOvsInterfaceClass *klass)
NM_SETTING_PARAM_INFERRABLE,
NMSettingOvsInterface,
type);
+ /**
+ * NMSettingOvsInterface:ofport-request:
+ *
+ * Open vSwitch openflow port number.
+ * Defaults to zero which means that port number will not be specified
+ * and it will be chosen randomly by ovs. OpenFlow ports are the network interfaces
+ * for passing packets between OpenFlow processing and the rest of the network.
+ * OpenFlow switches connect logically to each other via their OpenFlow ports.
+ *
+ * Since: 1.42
+ **/
+ _nm_setting_property_define_direct_uint32(properties_override,
+ obj_properties,
+ NM_SETTING_OVS_INTERFACE_OFPORT_REQUEST,
+ PROP_OFPORT_REQUEST,
+ 0,
+ 65279,
+ 0,
+ NM_SETTING_PARAM_INFERRABLE,
+ NMSettingOvsInterface,
+ ofport_request);
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
diff --git a/src/libnm-core-public/nm-setting-ovs-interface.h b/src/libnm-core-public/nm-setting-ovs-interface.h
index a36a1a5373..8c6beec22f 100644
--- a/src/libnm-core-public/nm-setting-ovs-interface.h
+++ b/src/libnm-core-public/nm-setting-ovs-interface.h
@@ -32,6 +32,8 @@ G_BEGIN_DECLS
#define NM_SETTING_OVS_INTERFACE_TYPE "type"
+#define NM_SETTING_OVS_INTERFACE_OFPORT_REQUEST "ofport-request"
+
typedef struct _NMSettingOvsInterfaceClass NMSettingOvsInterfaceClass;
NM_AVAILABLE_IN_1_10
@@ -42,6 +44,9 @@ NMSetting *nm_setting_ovs_interface_new(void);
NM_AVAILABLE_IN_1_10
const char *nm_setting_ovs_interface_get_interface_type(NMSettingOvsInterface *self);
+NM_AVAILABLE_IN_1_42
+guint32 nm_setting_ovs_interface_get_ofport_request(NMSettingOvsInterface *self);
+
G_END_DECLS
#endif /* __NM_SETTING_OVS_INTERFACE_H__ */
diff --git a/src/libnmc-setting/nm-meta-setting-desc.c b/src/libnmc-setting/nm-meta-setting-desc.c
index 2e471d66a5..45475ec405 100644
--- a/src/libnmc-setting/nm-meta-setting-desc.c
+++ b/src/libnmc-setting/nm-meta-setting-desc.c
@@ -6820,6 +6820,9 @@ static const NMMetaPropertyInfo *const property_infos_OVS_INTERFACE[] = {
.values_static = NM_MAKE_STRV ("internal", "system", "patch", "dpdk"),
),
),
+ PROPERTY_INFO_WITH_DESC (NM_SETTING_OVS_INTERFACE_OFPORT_REQUEST,
+ .property_type = &_pt_gobject_int,
+ ),
NULL
};
diff --git a/src/libnmc-setting/settings-docs.h.in b/src/libnmc-setting/settings-docs.h.in
index 2aef829a46..56a15e476e 100644
--- a/src/libnmc-setting/settings-docs.h.in
+++ b/src/libnmc-setting/settings-docs.h.in
@@ -252,6 +252,7 @@
#define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_STP_ENABLE N_("Enable or disable STP.")
#define DESCRIBE_DOC_NM_SETTING_OVS_DPDK_DEVARGS N_("Open vSwitch DPDK device arguments.")
#define DESCRIBE_DOC_NM_SETTING_OVS_DPDK_N_RXQ N_("Open vSwitch DPDK number of rx queues. Defaults to zero which means to leave the parameter in OVS unspecified and effectively configures one queue.")
+#define DESCRIBE_DOC_NM_SETTING_OVS_INTERFACE_OFPORT_REQUEST N_("Open vSwitch openflow port number. Defaults to zero which means that port number will not be specified and it will be chosen randomly by ovs. OpenFlow ports are the network interfaces for passing packets between OpenFlow processing and the rest of the network. OpenFlow switches connect logically to each other via their OpenFlow ports.")
#define DESCRIBE_DOC_NM_SETTING_OVS_INTERFACE_TYPE N_("The interface type. Either \"internal\", \"system\", \"patch\", \"dpdk\", or empty.")
#define DESCRIBE_DOC_NM_SETTING_OVS_PATCH_PEER N_("Specifies the name of the interface for the other side of the patch. The patch on the other side must also set this interface as peer.")
#define DESCRIBE_DOC_NM_SETTING_OVS_PORT_BOND_DOWNDELAY N_("The time port must be inactive in order to be considered down.")
diff --git a/src/nmcli/generate-docs-nm-settings-nmcli.xml.in b/src/nmcli/generate-docs-nm-settings-nmcli.xml.in
index b6d275c69d..ab6d926b55 100644
--- a/src/nmcli/generate-docs-nm-settings-nmcli.xml.in
+++ b/src/nmcli/generate-docs-nm-settings-nmcli.xml.in
@@ -834,6 +834,8 @@
<setting name="ovs-interface" >
<property name="type"
description="The interface type. Either &quot;internal&quot;, &quot;system&quot;, &quot;patch&quot;, &quot;dpdk&quot;, or empty." />
+ <property name="ofport-request"
+ description="Open vSwitch openflow port number. Defaults to zero which means that port number will not be specified and it will be chosen randomly by ovs. OpenFlow ports are the network interfaces for passing packets between OpenFlow processing and the rest of the network. OpenFlow switches connect logically to each other via their OpenFlow ports." />
</setting>
<setting name="ovs-patch" >
<property name="peer"