mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 17:30:09 +01:00
cli: strictly validate SR-IOV attributes
Report an error when the user tries to add an unknown attribute instead of silently accepting (and ignoring) it. Note that this commit also changes the behavior of public API nm_utils_sriov_vf_from_str() to return an error when an unknown attribute is found. I think the previous behavior was buggy as wrong attributes were simply ignored without any way for the user to know. Fixes:a9b4532fa7(cherry picked from commit769e0726a8)
This commit is contained in:
parent
67994f0e6f
commit
082bb02fa0
4 changed files with 14 additions and 6 deletions
|
|
@ -252,7 +252,7 @@ gboolean _nm_ip_route_attribute_validate_all (const NMIPRoute *route);
|
|||
const char **_nm_ip_route_get_attribute_names (const NMIPRoute *route, gboolean sorted, guint *out_length);
|
||||
GHashTable *_nm_ip_route_get_attributes_direct (NMIPRoute *route);
|
||||
|
||||
NMSriovVF *_nm_utils_sriov_vf_from_strparts (const char *index, const char *detail, GError **error);
|
||||
NMSriovVF *_nm_utils_sriov_vf_from_strparts (const char *index, const char *detail, gboolean ignore_unknown, GError **error);
|
||||
gboolean _nm_sriov_vf_attribute_validate_all (const NMSriovVF *vf, GError **error);
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ sriov_vfs_parser (KeyfileReaderInfo *info, NMSetting *setting, const char *key)
|
|||
keys[i],
|
||||
NULL);
|
||||
|
||||
vf = _nm_utils_sriov_vf_from_strparts (rest, value, NULL);
|
||||
vf = _nm_utils_sriov_vf_from_strparts (rest, value, TRUE, NULL);
|
||||
if (vf)
|
||||
g_ptr_array_add (vfs, vf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2737,11 +2737,14 @@ nm_utils_sriov_vf_from_str (const char *str, GError **error)
|
|||
detail++;
|
||||
}
|
||||
|
||||
return _nm_utils_sriov_vf_from_strparts (str, detail, error);
|
||||
return _nm_utils_sriov_vf_from_strparts (str, detail, FALSE, error);
|
||||
}
|
||||
|
||||
NMSriovVF *
|
||||
_nm_utils_sriov_vf_from_strparts (const char *index, const char *detail, GError **error)
|
||||
_nm_utils_sriov_vf_from_strparts (const char *index,
|
||||
const char *detail,
|
||||
gboolean ignore_unknown,
|
||||
GError **error)
|
||||
{
|
||||
NMSriovVF *vf;
|
||||
guint32 n_index;
|
||||
|
|
@ -2761,7 +2764,12 @@ _nm_utils_sriov_vf_from_strparts (const char *index, const char *detail, GError
|
|||
|
||||
vf = nm_sriov_vf_new (n_index);
|
||||
if (detail) {
|
||||
ht = nm_utils_parse_variant_attributes (detail, ' ', '=', TRUE, _nm_sriov_vf_attribute_spec, error);
|
||||
ht = nm_utils_parse_variant_attributes (detail,
|
||||
' ',
|
||||
'=',
|
||||
ignore_unknown,
|
||||
_nm_sriov_vf_attribute_spec,
|
||||
error);
|
||||
if (!ht) {
|
||||
nm_sriov_vf_unref (vf);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -2261,7 +2261,7 @@ make_sriov_setting (shvarFile *ifcfg)
|
|||
|
||||
key += NM_STRLEN ("SRIOV_VF");
|
||||
|
||||
vf = _nm_utils_sriov_vf_from_strparts (key, value, &error);
|
||||
vf = _nm_utils_sriov_vf_from_strparts (key, value, TRUE, &error);
|
||||
if (!vf) {
|
||||
PARSE_WARNING ("ignoring invalid SR-IOV VF '%s %s': %s",
|
||||
key, value, error->message);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue