diff options
author | Thomas Haller <thaller@redhat.com> | 2019-06-11 11:20:53 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-06-11 11:27:43 +0200 |
commit | 356a159731cc3619aea54b1c421dc2ba522b4e2e (patch) | |
tree | 3da3da47ba0b127aee7d3b26efb3a3a2b4b8b805 | |
parent | 1850dc495206e08a4bdb1adb62996fe2710fa071 (diff) | |
download | NetworkManager-356a159731cc3619aea54b1c421dc2ba522b4e2e.tar.gz |
libnm: add nm_setting_ethtool_get_optnames() function
It's rather limiting if we have no API to ask NMSettingEthtool which
options are set.
Note that currently NMSettingEthtool only supports offload features.
In the future, it should also support other options like coalesce
or ring options. Hence, this returns all option names, not only
features.
If a caller needs to know whether the name is an option name, he/she
should call nm_ethtool_optname_is_feature().
-rw-r--r-- | libnm-core/nm-setting-ethtool.c | 34 | ||||
-rw-r--r-- | libnm-core/nm-setting-ethtool.h | 4 | ||||
-rw-r--r-- | libnm/libnm.ver | 1 |
3 files changed, 39 insertions, 0 deletions
diff --git a/libnm-core/nm-setting-ethtool.c b/libnm-core/nm-setting-ethtool.c index 6369c58ca6..29cb401290 100644 --- a/libnm-core/nm-setting-ethtool.c +++ b/libnm-core/nm-setting-ethtool.c @@ -91,6 +91,9 @@ _notify_attributes (NMSettingEthtool *self) * Gets and offload feature setting. Returns %NM_TERNARY_DEFAULT if the * feature is not set. * + * Note that @optname must be a valid name for a feature, according to + * nm_ethtool_optname_is_feature(). + * * Returns: a #NMTernary value indicating whether the offload feature * is enabled, disabled, or left untouched. * @@ -124,6 +127,9 @@ nm_setting_ethtool_get_feature (NMSettingEthtool *setting, * * Sets and offload feature setting. * + * Note that @optname must be a valid name for a feature, according to + * nm_ethtool_optname_is_feature(). + * * Since: 1.14 */ void @@ -245,6 +251,34 @@ nm_setting_ethtool_init_features (NMSettingEthtool *setting, /*****************************************************************************/ +/** + * nm_setting_ethtool_get_optnames: + * @setting: the #NMSettingEthtool instance. + * @out_length: (out) (optional): return location for the number of keys returned, or %NULL + * + * This returns all options names that are set. This includes the feature names + * like %NM_ETHTOOL_OPTNAME_FEATURE_GRO. See nm_ethtool_optname_is_feature() to + * check whether the option name is valid for offload features. + * + * Returns: (array zero-terminated=1) (transfer container): list of set option + * names or %NULL if no options are set. The option names are still owned by + * @setting and may get invalidated when @setting gets modified. + * + * Since: 1.20 + */ +const char ** +nm_setting_ethtool_get_optnames (NMSettingEthtool *setting, + guint *out_length) +{ + g_return_val_if_fail (NM_IS_SETTING_ETHTOOL (setting), NULL); + + return nm_utils_strdict_get_keys (_nm_setting_gendata_hash (NM_SETTING (setting), FALSE), + TRUE, + out_length); +} + +/*****************************************************************************/ + static gboolean verify (NMSetting *setting, NMConnection *connection, GError **error) { diff --git a/libnm-core/nm-setting-ethtool.h b/libnm-core/nm-setting-ethtool.h index 3142fa16a4..09f3753243 100644 --- a/libnm-core/nm-setting-ethtool.h +++ b/libnm-core/nm-setting-ethtool.h @@ -119,6 +119,10 @@ void nm_setting_ethtool_set_feature (NMSettingEthtool *setting, NM_AVAILABLE_IN_1_14 void nm_setting_ethtool_clear_features (NMSettingEthtool *setting); +NM_AVAILABLE_IN_1_20 +const char ** nm_setting_ethtool_get_optnames (NMSettingEthtool *setting, + guint *out_length); + G_END_DECLS #endif /* __NM_SETTING_ETHTOOL_H__ */ diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 36bdacdedb..57fc7331f3 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -1610,4 +1610,5 @@ global: nm_device_modem_get_apn; nm_device_modem_get_device_id; nm_device_modem_get_operator_code; + nm_setting_ethtool_get_optnames; } libnm_1_18_0; |