Re: [net-2.6 PATCH 2/2] netlink: bug fix: wrong size was calculated for vfinfo list blob

Previous thread: Re: [RFC] netfilter: WIP: Xtables idletimer target implementation by Luciano Coelho on Thursday, May 27, 2010 - 10:25 pm. (11 messages)

Next thread: [net-2.6 PATCH 1/2] netlink: bug fix: don't overrun skbs on vf_port dump by Scott Feldman on Friday, May 28, 2010 - 12:15 am. (2 messages)
From: Scott Feldman
Date: Friday, May 28, 2010 - 12:15 am

From: Scott Feldman <scofeldm@cisco.com>

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: Scott Feldman <scofeldm@cisco.com>
---
 net/core/rtnetlink.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)


diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 7331bb2..1a2af24 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -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)) {
 
 		int num_vfs = dev_num_vf(dev->dev.parent);
-		size_t size = nlmsg_total_size(sizeof(struct nlattr));
-		size += nlmsg_total_size(num_vfs * sizeof(struct nlattr));
-		size += num_vfs * (sizeof(struct ifla_vf_mac) +
-				  sizeof(struct ifla_vf_vlan) +
-				  sizeof(struct ifla_vf_tx_rate));
+		size_t size = nla_total_size(sizeof(struct nlattr));
+		size += nla_total_size(num_vfs * sizeof(struct nlattr));
+		size += num_vfs *
+			(nla_total_size(sizeof(struct ifla_vf_mac)) +
+			 nla_total_size(sizeof(struct ifla_vf_vlan)) +
+			 nla_total_size(sizeof(struct ifla_vf_tx_rate)));
 		return size;
 	} else
 		return 0;

--

From: David Miller
Date: Friday, May 28, 2010 - 3:42 am

From: Scott Feldman <scofeldm@cisco.com>

Applied.
--

Previous thread: Re: [RFC] netfilter: WIP: Xtables idletimer target implementation by Luciano Coelho on Thursday, May 27, 2010 - 10:25 pm. (11 messages)

Next thread: [net-2.6 PATCH 1/2] netlink: bug fix: don't overrun skbs on vf_port dump by Scott Feldman on Friday, May 28, 2010 - 12:15 am. (2 messages)