diff options
author | Thomas Haller <thaller@redhat.com> | 2020-02-17 16:44:32 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-02-26 17:51:14 +0100 |
commit | 807cddc7546d6da222aed2759215ae93dcb2c8d7 (patch) | |
tree | 54ae015a73a05ceea7b49b46558a3b52b8941ae0 | |
parent | a11edd4a82e019cd0666b398827c037bf718a7c2 (diff) | |
download | NetworkManager-807cddc7546d6da222aed2759215ae93dcb2c8d7.tar.gz |
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.
-rw-r--r-- | shared/nm-glib-aux/nm-shared-utils.c | 11 | ||||
-rw-r--r-- | shared/nm-glib-aux/nm-shared-utils.h | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index 6e1bcd74cb..26eba35279 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -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); diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h index a5d2ee7292..dc29b85d02 100644 --- a/shared/nm-glib-aux/nm-shared-utils.h +++ b/shared/nm-glib-aux/nm-shared-utils.h @@ -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; |