Skip to content
Commit e2bf52ff authored by Felix Riemann's avatar Felix Riemann Committed by Greg Kroah-Hartman
Browse files

net: Fix unwanted sign extension in netdev_stats_to_stats64()

commit 9b55d3f0 upstream.

When converting net_device_stats to rtnl_link_stats64 sign extension
is triggered on ILP32 machines as 6c1c5097 changed the previous
"ulong -> u64" conversion to "long -> u64" by accessing the
net_device_stats fields through a (signed) atomic_long_t.

This causes for example the received bytes counter to jump to 16EiB after
having received 2^31 bytes. Casting the atomic value to "unsigned long"
beforehand converting it into u64 avoids this.

Fixes: 6c1c5097

 ("net: add atomic_long_t to net_device_stats fields")
Signed-off-by: default avatarFelix Riemann <felix.riemann@sma.de>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1933be14
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