diff options
author | Thomas Haller <thaller@redhat.com> | 2020-05-14 09:16:32 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-05-22 15:58:08 +0200 |
commit | 20a2399aa982f2cae999829805eacbab6328bb70 (patch) | |
tree | 01302fe639de15856c88773be0807498d010d256 | |
parent | 501554732c2d74bebaf8efd630ef2f00d78745a8 (diff) | |
download | NetworkManager-20a2399aa982f2cae999829805eacbab6328bb70.tar.gz |
libnm: verify that ethtool coalesce options "adaptive-[rt]x" are boolean
nm_setting_ethtool_set_coalesce() coerces the values to be either 0 or
1. Verification of NMSettingEthtool should ensure the same.
-rw-r--r-- | libnm-core/nm-setting-ethtool.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-ethtool.c b/libnm-core/nm-setting-ethtool.c index 03245629db..82da6f969f 100644 --- a/libnm-core/nm-setting-ethtool.c +++ b/libnm-core/nm-setting-ethtool.c @@ -540,6 +540,19 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) g_prefix_error (error, "%s.%s: ", NM_SETTING_ETHTOOL_SETTING_NAME, optname); return FALSE; } + + if (NM_IN_SET (ethtool_id, + NM_ETHTOOL_ID_COALESCE_ADAPTIVE_RX, + NM_ETHTOOL_ID_COALESCE_ADAPTIVE_TX)) { + if (!NM_IN_SET (g_variant_get_uint32 (variant), 0, 1)) { + g_set_error_literal (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("coalesce option must be either 0 or 1")); + g_prefix_error (error, "%s.%s: ", NM_SETTING_ETHTOOL_SETTING_NAME, optname); + return FALSE; + } + } } return TRUE; |