]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
rtnetlink: fix rtnl_vfinfo_size
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 15 Nov 2016 09:39:03 +0000 (10:39 +0100)
committerBrian Maly <brian.maly@oracle.com>
Tue, 24 Jul 2018 20:03:21 +0000 (16:03 -0400)
The size reported by rtnl_vfinfo_size doesn't match the space used by
rtnl_fill_vfinfo.

rtnl_vfinfo_size currently doesn't account for the nest attributes
used by statistics (added in commit 3b766cd83232), nor for struct
ifla_vf_tx_rate (since commit ed616689a3d9, which added ifla_vf_rate
to the dump without removing ifla_vf_tx_rate, but replaced
ifla_vf_tx_rate with ifla_vf_rate in the size computation).

Fixes: ed616689a3d9 ("net-next:v4: Add support to configure SR-IOV VF minimum and maximum Tx rate through ip tool")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 27998927

(cherry picked from commit 7e75f74a171a8146cc3ee92d5562878b40c25fb5)
Signed-off-by: Divya Indi <divya.indi@oracle.com>
Reviewed-by: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
net/core/rtnetlink.c
(Precedes commits that added VF stats, VF trust, vlan info)

Signed-off-by: Brian Maly <brian.maly@oracle.com>
net/core/rtnetlink.c

index 22e3c68565ce44312ff26824b20ebd746132b297..0120cf5e5986933d8c7affbb1799c430f2947239 100644 (file)
@@ -811,12 +811,13 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev,
        if (dev->dev.parent && dev_is_pci(dev->dev.parent) &&
            (ext_filter_mask & RTEXT_FILTER_VF)) {
                int num_vfs = dev_num_vf(dev->dev.parent);
-               size_t size = nla_total_size(sizeof(struct nlattr));
-               size += nla_total_size(num_vfs * sizeof(struct nlattr));
+               size_t size = nla_total_size(0);
                size += num_vfs *
-                       (nla_total_size(sizeof(struct ifla_vf_mac)) +
+                       (nla_total_size(0) +
+                        nla_total_size(sizeof(struct ifla_vf_mac)) +
                         nla_total_size(sizeof(struct ifla_vf_vlan)) +
                         nla_total_size(sizeof(struct ifla_vf_spoofchk)) +
+                        nla_total_size(sizeof(struct ifla_vf_tx_rate)) +
                         nla_total_size(sizeof(struct ifla_vf_rate)) +
                         nla_total_size(sizeof(struct ifla_vf_link_state)) +
                         nla_total_size(sizeof(struct ifla_vf_rss_query_en)));