All of lore.kernel.org
 help / color / mirror / Atom feed
* BUG: 32 bit net stats
@ 2013-09-23 21:49 Jamal Hadi Salim
  2013-09-23 22:04 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Jamal Hadi Salim @ 2013-09-23 21:49 UTC (permalink / raw)
  To: netdev; +Cc: Eric Dumazet

[-- Attachment #1: Type: text/plain, Size: 506 bytes --]


Something broke in sending of 32 bit version of netstat around the
time 64 bit version was improved. I went back as far as 3.8.0 to recent
kernels. Could have been earlier.
The work around in user space is when you see 64 bit stats just ignore
the 32 bit version (which iproute2 does and so am i;->).

But assumming there are tools out there that know only of 32 bit
variant they will get bad stats. Here's a compile tested only patch.
Wont have to test anything for at least another day.

cheers,
jamal


[-- Attachment #2: p-untested --]
[-- Type: text/plain, Size: 1339 bytes --]

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 2a0e21d..005be70 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -659,7 +659,7 @@ static unsigned int rtnl_dev_combine_flags(const struct net_device *dev,
 }
 
 static void copy_rtnl_link_stats(struct rtnl_link_stats *a,
-				 const struct rtnl_link_stats64 *b)
+				 const struct net_device_stats *b)
 {
 	a->rx_packets = b->rx_packets;
 	a->tx_packets = b->tx_packets;
@@ -876,6 +876,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 	struct nlattr *attr, *af_spec;
 	struct rtnl_af_ops *af_ops;
 	struct net_device *upper_dev = netdev_master_upper_dev_get(dev);
+	const struct net_device_stats *stats32 = &dev->stats;
+	const struct net_device_ops *ops = dev->netdev_ops;
 
 	ASSERT_RTNL();
 	nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags);
@@ -940,9 +942,11 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 	if (attr == NULL)
 		goto nla_put_failure;
 
-	stats = dev_get_stats(dev, &temp);
-	copy_rtnl_link_stats(nla_data(attr), stats);
+	if (ops->ndo_get_stats)
+		stats32 = ops->ndo_get_stats(dev);
+	copy_rtnl_link_stats(nla_data(attr), stats32);
 
+	stats = dev_get_stats(dev, &temp);
 	attr = nla_reserve(skb, IFLA_STATS64,
 			sizeof(struct rtnl_link_stats64));
 	if (attr == NULL)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: BUG: 32 bit net stats
  2013-09-23 21:49 BUG: 32 bit net stats Jamal Hadi Salim
@ 2013-09-23 22:04 ` Eric Dumazet
  2013-09-23 22:15   ` Jamal Hadi Salim
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2013-09-23 22:04 UTC (permalink / raw)
  To: Jamal Hadi Salim; +Cc: netdev, Eric Dumazet

On Mon, 2013-09-23 at 17:49 -0400, Jamal Hadi Salim wrote:
> Something broke in sending of 32 bit version of netstat around the
> time 64 bit version was improved. I went back as far as 3.8.0 to recent
> kernels. Could have been earlier.
> The work around in user space is when you see 64 bit stats just ignore
> the 32 bit version (which iproute2 does and so am i;->).
> 
> But assumming there are tools out there that know only of 32 bit
> variant they will get bad stats. Here's a compile tested only patch.
> Wont have to test anything for at least another day.
> 
> cheers,
> jamal
> 

Hi Jamal

Sorry, this doesnt make sense to me.

Existing code seems to be fine.

Which driver do you use ?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: BUG: 32 bit net stats
  2013-09-23 22:04 ` Eric Dumazet
@ 2013-09-23 22:15   ` Jamal Hadi Salim
  2013-09-23 22:42     ` Jamal Hadi Salim
  0 siblings, 1 reply; 4+ messages in thread
From: Jamal Hadi Salim @ 2013-09-23 22:15 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, Eric Dumazet

On 13-09-23 06:04 PM, Eric Dumazet wrote:

>
> Sorry, this doesnt make sense to me.
>
> Existing code seems to be fine.
>
> Which driver do you use ?

Sorry - let me take a closer look and get back
to you. I think the bug maybe in user space.

cheers,
jamal

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: BUG: 32 bit net stats
  2013-09-23 22:15   ` Jamal Hadi Salim
@ 2013-09-23 22:42     ` Jamal Hadi Salim
  0 siblings, 0 replies; 4+ messages in thread
From: Jamal Hadi Salim @ 2013-09-23 22:42 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, Eric Dumazet

On 13-09-23 06:15 PM, Jamal Hadi Salim wrote:

> Sorry - let me take a closer look and get back
> to you. I think the bug maybe in user space.

Sigh - long standing bug on my (user space) side
got aggrevated by last changes.
Ignore the noise. Kernel works fine.

cheers,
jamal

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-23 22:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-23 21:49 BUG: 32 bit net stats Jamal Hadi Salim
2013-09-23 22:04 ` Eric Dumazet
2013-09-23 22:15   ` Jamal Hadi Salim
2013-09-23 22:42     ` Jamal Hadi Salim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.