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.
This commit is contained in:
Thomas Haller 2020-02-18 15:33:33 +01:00
parent 07b7c82d04
commit a11edd4a82
2 changed files with 11 additions and 10 deletions

View file

@ -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__ */

View file

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