diff options
author | Thomas Haller <thaller@redhat.com> | 2020-05-14 09:16:32 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-05-20 21:27:16 +0200 |
commit | accafccb1854c0153cd92ce8fe57261cd37cd3b5 (patch) | |
tree | 0e5dfeebdf3999b8af925a93c8f25bbd5945bca9 | |
parent | 39707f54322c6cea53cb2902967e2bb4cc16877b (diff) | |
download | NetworkManager-accafccb1854c0153cd92ce8fe57261cd37cd3b5.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; |