Skip to content

Commit

Permalink
ethtool: add netlink attr in rss get reply only if value is not null
Browse files Browse the repository at this point in the history
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: 7112a04 ("ethtool: add netlink based get rss support")
Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Link: https://lore.kernel.org/r/20230111235607.85509-1-sudheer.mogilappagari@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
msudheer337 authored and kuba-moo committed Jan 13, 2023
1 parent 01644a1 commit ea22f43
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions net/ethtool/rss.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ea22f43

Please sign in to comment.