diff mbox series

[net] ethtool:add netlink attr in rss get reply only if value is not null

Message ID 20230111235607.85509-1-sudheer.mogilappagari@intel.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net] ethtool:add netlink attr in rss get reply only if value is not null | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers warning 3 maintainers not CCed: edumazet@google.com davem@davemloft.net pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Mogilappagari, Sudheer Jan. 11, 2023, 11:56 p.m. UTC
Current code for RSS_GET ethtool command includes netlink attributes
in reply message to user space even if they are null. Added checks
to include netlink attribute in reply message only if a value is
received from driver. Drivers might return null for RSS indirection
table or hash key. Instead of including attributes with empty value
in the reply message, add netlink attribute only if there is content.

Fixes: 7112a04664bf ("ethtool: add netlink based get rss support")
Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>
---
 net/ethtool/rss.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Michal Kubecek Jan. 12, 2023, 8:06 a.m. UTC | #1
On Wed, Jan 11, 2023 at 03:56:07PM -0800, Sudheer Mogilappagari wrote:
> Current code for RSS_GET ethtool command includes netlink attributes
> in reply message to user space even if they are null. Added checks
> to include netlink attribute in reply message only if a value is
> received from driver. Drivers might return null for RSS indirection
> table or hash key. Instead of including attributes with empty value
> in the reply message, add netlink attribute only if there is content.
> 
> Fixes: 7112a04664bf ("ethtool: add netlink based get rss support")
> Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>

Reviewed-by: Michal Kubecek <mkubecek@suse.cz>

Note: the code was added in 6.2-rc1 merge window so that it is still
safe to change the output before 6.2 final without risk of "breaking the
userspace".

Michal

> ---
>  net/ethtool/rss.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c
> index ebe6145aed3f..be260ab34e58 100644
> --- a/net/ethtool/rss.c
> +++ b/net/ethtool/rss.c
> @@ -122,10 +122,13 @@ rss_fill_reply(struct sk_buff *skb, const struct ethnl_req_info *req_base,
>  {
>  	const struct rss_reply_data *data = RSS_REPDATA(reply_base);
>  
> -	if (nla_put_u32(skb, ETHTOOL_A_RSS_HFUNC, data->hfunc) ||
> -	    nla_put(skb, ETHTOOL_A_RSS_INDIR,
> -		    sizeof(u32) * data->indir_size, data->indir_table) ||
> -	    nla_put(skb, ETHTOOL_A_RSS_HKEY, data->hkey_size, data->hkey))
> +	if ((data->hfunc &&
> +	     nla_put_u32(skb, ETHTOOL_A_RSS_HFUNC, data->hfunc)) ||
> +	    (data->indir_size &&
> +	     nla_put(skb, ETHTOOL_A_RSS_INDIR,
> +		     sizeof(u32) * data->indir_size, data->indir_table)) ||
> +	    (data->hkey_size &&
> +	     nla_put(skb, ETHTOOL_A_RSS_HKEY, data->hkey_size, data->hkey)))
>  		return -EMSGSIZE;
>  
>  	return 0;
> -- 
> 2.31.1
>
Jakub Kicinski Jan. 13, 2023, 7:40 p.m. UTC | #2
On Wed, 11 Jan 2023 15:56:07 -0800 Sudheer Mogilappagari wrote:
> Current code for RSS_GET ethtool command includes netlink attributes
> in reply message to user space even if they are null. Added checks
> to include netlink attribute in reply message only if a value is
> received from driver. Drivers might return null for RSS indirection
> table or hash key. Instead of including attributes with empty value
> in the reply message, add netlink attribute only if there is content.
> 
> Fixes: 7112a04664bf ("ethtool: add netlink based get rss support")
> Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c
index ebe6145aed3f..be260ab34e58 100644
--- a/net/ethtool/rss.c
+++ b/net/ethtool/rss.c
@@ -122,10 +122,13 @@  rss_fill_reply(struct sk_buff *skb, const struct ethnl_req_info *req_base,
 {
 	const struct rss_reply_data *data = RSS_REPDATA(reply_base);
 
-	if (nla_put_u32(skb, ETHTOOL_A_RSS_HFUNC, data->hfunc) ||
-	    nla_put(skb, ETHTOOL_A_RSS_INDIR,
-		    sizeof(u32) * data->indir_size, data->indir_table) ||
-	    nla_put(skb, ETHTOOL_A_RSS_HKEY, data->hkey_size, data->hkey))
+	if ((data->hfunc &&
+	     nla_put_u32(skb, ETHTOOL_A_RSS_HFUNC, data->hfunc)) ||
+	    (data->indir_size &&
+	     nla_put(skb, ETHTOOL_A_RSS_INDIR,
+		     sizeof(u32) * data->indir_size, data->indir_table)) ||
+	    (data->hkey_size &&
+	     nla_put(skb, ETHTOOL_A_RSS_HKEY, data->hkey_size, data->hkey)))
 		return -EMSGSIZE;
 
 	return 0;