summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-18 15:33:33 +0100
committerThomas Haller <thaller@redhat.com>2020-02-26 17:51:14 +0100
commita11edd4a82e019cd0666b398827c037bf718a7c2 (patch)
treeee9fa3d8c5957642e54a177786ac8e2b2bc216a6
parent07b7c82d04ff294277254b195e1a2fa0ffd8875f (diff)
downloadNetworkManager-a11edd4a82e019cd0666b398827c037bf718a7c2.tar.gz
libnm: always return normalized-type from _nm_setting_ovs_interface_verify_interface_type()
We should return the chosen type whenever we can verify the setting. Previously, the normalized-type output argument was only set when normalization was actually necessary. On most cases, the caller cares whether the setting verifies and which interface type is chosen. It's much less likely that a caller cares only about the normalized-type if normalization is actually necessary. Whenever we return TRUE (indicating that the setting is valid), also return the chosen interface-type.
-rw-r--r--libnm-core/nm-connection-private.h2
-rw-r--r--libnm-core/nm-setting-ovs-interface.c19
2 files changed, 11 insertions, 10 deletions
diff --git a/libnm-core/nm-connection-private.h b/libnm-core/nm-connection-private.h
index 90d91439bc..3c505834b4 100644
--- a/libnm-core/nm-connection-private.h
+++ b/libnm-core/nm-connection-private.h
@@ -28,7 +28,7 @@ int _nm_setting_ovs_interface_verify_interface_type (NMSettingOvsInterface *self
NMConnection *connection,
gboolean normalize,
gboolean *out_modified,
- const char **normalized_type,
+ const char **out_normalized_type,
GError **error);
#endif /* __NM_CONNECTION_PRIVATE_H__ */
diff --git a/libnm-core/nm-setting-ovs-interface.c b/libnm-core/nm-setting-ovs-interface.c
index 85e77b5443..114e0205d3 100644
--- a/libnm-core/nm-setting-ovs-interface.c
+++ b/libnm-core/nm-setting-ovs-interface.c
@@ -68,7 +68,7 @@ _nm_setting_ovs_interface_verify_interface_type (NMSettingOvsInterface *self,
NMConnection *connection,
gboolean normalize,
gboolean *out_modified,
- const char **normalized_type,
+ const char **out_normalized_type,
GError **error)
{
const char *type_from_setting = NULL;
@@ -85,9 +85,8 @@ _nm_setting_ovs_interface_verify_interface_type (NMSettingOvsInterface *self,
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);
+ NM_SET_OUT (out_normalized_type, NULL);
if ( type
&& !NM_IN_STRSET (type, "internal", "system", "patch", "dpdk")) {
@@ -100,8 +99,10 @@ _nm_setting_ovs_interface_verify_interface_type (NMSettingOvsInterface *self,
return FALSE;
}
- if (!connection)
+ if (!connection) {
+ NM_SET_OUT (out_normalized_type, type);
return TRUE;
+ }
connection_type = nm_connection_get_connection_type (connection);
if (!connection_type) {
@@ -192,6 +193,7 @@ _nm_setting_ovs_interface_verify_interface_type (NMSettingOvsInterface *self,
g_prefix_error (error, "%s.%s: ", NM_SETTING_OVS_INTERFACE_SETTING_NAME, NM_SETTING_OVS_INTERFACE_TYPE);
return FALSE;
}
+ NM_SET_OUT (out_normalized_type, type);
return TRUE;
}
type = type_from_setting;
@@ -208,16 +210,17 @@ _nm_setting_ovs_interface_verify_interface_type (NMSettingOvsInterface *self,
}
}
- if (type)
+ if (type) {
+ NM_SET_OUT (out_normalized_type, type);
return TRUE;
+ }
if (is_ovs_connection_type)
type = "internal";
else
type = "system";
- if (normalized_type)
- *normalized_type = type;
+ NM_SET_OUT (out_normalized_type, type);
normalize:
if (!normalize) {
@@ -309,8 +312,6 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
gs_free_error GError *ifname_error = NULL;
const char *ifname = nm_setting_connection_get_interface_name (s_con);
- normalized_type = self->type ? self->type : normalized_type;
-
if ( ifname
&& !nm_streq0 (normalized_type, "patch")
&& !nm_utils_ifname_valid (ifname,