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.
This commit is contained in:
Thomas Haller
2020-02-18 14:52:28 +01:00
parent aa6bc2868d
commit 07b7c82d04
3 changed files with 8 additions and 5 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,