Skip to content

Commit ea22f43

Browse files
msudheer337kuba-moo
authored andcommitted
ethtool: add netlink attr in rss get reply only if value is not null
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 <[email protected]> Reviewed-by: Michal Kubecek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 01644a1 commit ea22f43

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/ethtool/rss.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,13 @@ rss_fill_reply(struct sk_buff *skb, const struct ethnl_req_info *req_base,
122122
{
123123
const struct rss_reply_data *data = RSS_REPDATA(reply_base);
124124

125-
if (nla_put_u32(skb, ETHTOOL_A_RSS_HFUNC, data->hfunc) ||
126-
nla_put(skb, ETHTOOL_A_RSS_INDIR,
127-
sizeof(u32) * data->indir_size, data->indir_table) ||
128-
nla_put(skb, ETHTOOL_A_RSS_HKEY, data->hkey_size, data->hkey))
125+
if ((data->hfunc &&
126+
nla_put_u32(skb, ETHTOOL_A_RSS_HFUNC, data->hfunc)) ||
127+
(data->indir_size &&
128+
nla_put(skb, ETHTOOL_A_RSS_INDIR,
129+
sizeof(u32) * data->indir_size, data->indir_table)) ||
130+
(data->hkey_size &&
131+
nla_put(skb, ETHTOOL_A_RSS_HKEY, data->hkey_size, data->hkey)))
129132
return -EMSGSIZE;
130133

131134
return 0;

0 commit comments

Comments
 (0)