shared: add NMU_IFACE_ANY for nm_utils_ifname_valid()

nm_utils_ifname_valid() is to validate "connection.interface-name"
property. But the exact validation depends on the connection type.

Add "NMU_IFACE_ANY" to validate the name to check whether it would be
valid for any connection type.

This is for completeness and for places where the caller might not know
the connection type.
This commit is contained in:
Thomas Haller 2020-02-17 16:44:32 +01:00
parent a11edd4a82
commit 807cddc754
2 changed files with 13 additions and 1 deletions

View file

@ -4211,6 +4211,17 @@ nm_utils_ifname_valid (const char* name,
return _nm_utils_ifname_valid_kernel (name, error);
case NMU_IFACE_OVS:
return _nm_utils_ifname_valid_ovs (name, error);
case NMU_IFACE_ANY: {
gs_free_error GError *local = NULL;
if (_nm_utils_ifname_valid_kernel (name, error ? &local : NULL))
return TRUE;
if (_nm_utils_ifname_valid_ovs (name, NULL))
return TRUE;
if (error)
g_propagate_error (error, g_steal_pointer (&local));
return FALSE;
}
}
g_return_val_if_reached (FALSE);

View file

@ -1678,7 +1678,8 @@ nm_utils_strdup_reset (char **dst, const char *src)
/*****************************************************************************/
typedef enum {
NMU_IFACE_KERNEL = 0,
NMU_IFACE_ANY,
NMU_IFACE_KERNEL,
NMU_IFACE_OVS,
} NMUtilsIfaceType;