Commit 045de01a authored by Scott Feldman's avatar Scott Feldman Committed by David S. Miller

netlink: bug fix: wrong size was calculated for vfinfo list blob

The wrong size was being calculated for vfinfo.  In one case, it was over-
calculating using nlmsg_total_size on attrs, in another case, it was
under-calculating by assuming ifla_vf_* structs are packed together, but
each struct is it's own attr w/ hdr (and padding).
Signed-off-by: default avatarScott Feldman <scofeldm@cisco.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8ca94183
...@@ -650,11 +650,12 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev) ...@@ -650,11 +650,12 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev)
if (dev->dev.parent && dev_is_pci(dev->dev.parent)) { if (dev->dev.parent && dev_is_pci(dev->dev.parent)) {
int num_vfs = dev_num_vf(dev->dev.parent); int num_vfs = dev_num_vf(dev->dev.parent);
size_t size = nlmsg_total_size(sizeof(struct nlattr)); size_t size = nla_total_size(sizeof(struct nlattr));
size += nlmsg_total_size(num_vfs * sizeof(struct nlattr)); size += nla_total_size(num_vfs * sizeof(struct nlattr));
size += num_vfs * (sizeof(struct ifla_vf_mac) + size += num_vfs *
sizeof(struct ifla_vf_vlan) + (nla_total_size(sizeof(struct ifla_vf_mac)) +
sizeof(struct ifla_vf_tx_rate)); nla_total_size(sizeof(struct ifla_vf_vlan)) +
nla_total_size(sizeof(struct ifla_vf_tx_rate)));
return size; return size;
} else } else
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment