summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-18 14:52:28 +0100
committerThomas Haller <thaller@redhat.com>2020-02-26 17:51:14 +0100
commit07b7c82d04ff294277254b195e1a2fa0ffd8875f (patch)
tree85e1f3670c37e5d872f3f8f22a66f532af0424d5
parentaa6bc2868da43199be001e54385c4230e3efc4ca (diff)
downloadNetworkManager-07b7c82d04ff294277254b195e1a2fa0ffd8875f.tar.gz
libnm: allow _nm_setting_ovs_interface_verify_interface_type() without NMSettingOvsInterface instance
_nm_setting_ovs_interface_verify_interface_type() does verify and normalize both. Especially for verify, it's useful to run the operation without having a NMSettingOvsInterface instance, because we might want to know how normalization would react, if we had a NMSettingOvsInterface instance. Allow for that.
-rw-r--r--libnm-core/nm-connection-private.h1
-rw-r--r--libnm-core/nm-connection.c1
-rw-r--r--libnm-core/nm-setting-ovs-interface.c11
3 files changed, 8 insertions, 5 deletions
diff --git a/libnm-core/nm-connection-private.h b/libnm-core/nm-connection-private.h
index 034c350f84..90d91439bc 100644
--- a/libnm-core/nm-connection-private.h
+++ b/libnm-core/nm-connection-private.h
@@ -24,6 +24,7 @@ gboolean _nm_connection_verify_required_interface_name (NMConnection *connect
GError **error);
int _nm_setting_ovs_interface_verify_interface_type (NMSettingOvsInterface *self,
+ const char *type,
NMConnection *connection,
gboolean normalize,
gboolean *out_modified,
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index 5c54c5140f..58c9f0df59 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -1236,6 +1236,7 @@ _normalize_ovs_interface_type (NMConnection *self)
return FALSE;
v = _nm_setting_ovs_interface_verify_interface_type (s_ovs_interface,
+ nm_setting_ovs_interface_get_interface_type (s_ovs_interface),
self,
TRUE,
&modified,
diff --git a/libnm-core/nm-setting-ovs-interface.c b/libnm-core/nm-setting-ovs-interface.c
index 9a7e1fb2ba..85e77b5443 100644
--- a/libnm-core/nm-setting-ovs-interface.c
+++ b/libnm-core/nm-setting-ovs-interface.c
@@ -64,31 +64,31 @@ nm_setting_ovs_interface_get_interface_type (NMSettingOvsInterface *self)
int
_nm_setting_ovs_interface_verify_interface_type (NMSettingOvsInterface *self,
+ const char *type,
NMConnection *connection,
gboolean normalize,
gboolean *out_modified,
const char **normalized_type,
GError **error)
{
- const char *type;
const char *type_from_setting = NULL;
const char *type_setting = NULL;
const char *connection_type;
gboolean is_ovs_connection_type;
- g_return_val_if_fail (NM_IS_SETTING_OVS_INTERFACE (self), FALSE);
if (normalize) {
+ g_return_val_if_fail (NM_IS_SETTING_OVS_INTERFACE (self), FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
nm_assert (self == nm_connection_get_setting_ovs_interface (connection));
- } else
+ } else {
+ g_return_val_if_fail (!self || NM_IS_SETTING_OVS_INTERFACE (self), FALSE);
g_return_val_if_fail (!connection || NM_IS_CONNECTION (connection), FALSE);
+ }
g_return_val_if_fail (!normalized_type || !(*normalized_type), FALSE);
NM_SET_OUT (out_modified, FALSE);
- type = self->type;
-
if ( type
&& !NM_IN_STRSET (type, "internal", "system", "patch", "dpdk")) {
g_set_error (error,
@@ -296,6 +296,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
}
result = _nm_setting_ovs_interface_verify_interface_type (self,
+ self->type,
connection,
FALSE,
NULL,