compat: backport ndo_get_stats64 addition
The net_device_ops data structure gets a new ndo_get_stats64
callback through two patches. For newer kernels that actually do
have the net_device_ops data structure we have no other option
but to #ifdef that code. For older kernels that do not have the
net_device_ops we stuff the new callback into this compat
module / header files and make netdev_attach_ops() ignore it.
And again -- for newer kernels just #ifdef that stuff out.
This is an example of a complex data structure series of
changes through different sets of collateral evolutions.
If we can figure out a way to not requre #ifdef changes
for *newer* kernels that *do* have the net_device_ops it
would be great. One way to likely accomplish this is to
redefine the net_device_ops data structure through a define
for all kernels and make it out own and in our own
netdev_attach_ops() routine handle the differences.
If this would be possible (needs to be proven but I think
Ozan has already proven this) I'm hopeful we'll eventually
be able to replace net_device_ops() collateral evolutions with
0 lines required to be changed on upstream code!
There are two patches that added ndo_get_stats64, fortunately
both were implemented during the 2.6.36 deveopment cycle.
mcgrof@tux ~/linux-next (git::master)$ git describe --contains
be1f3c2c
v2.6.36-rc1~571^2~600
mcgrof@tux ~/linux-next (git::master)$ git describe --contains
28172739
v2.6.36-rc1~571^2~334
commit
be1f3c2c027cc5ad735df6a45a542ed1db7ec48b
Author: Ben Hutchings <bhutchings@solarflare.com>
Date: Tue Jun 8 07:19:54 2010 +0000
net: Enable 64-bit net device statistics on 32-bit architectures
Use struct rtnl_link_stats64 as the statistics structure.
On 32-bit architectures, insert 32 bits of padding after/before each
field of struct net_device_stats to make its layout compatible with
struct rtnl_link_stats64. Add an anonymous union in net_device; move
stats into the union and add struct rtnl_link_stats64 stats64.
Add net_device_ops::ndo_get_stats64, implementations of which will
return a pointer to struct rtnl_link_stats64. Drivers that implement
this operation must not update the structure asynchronously.
Change dev_get_stats() to call ndo_get_stats64 if available, and to
return a pointer to struct rtnl_link_stats64. Change callers of
dev_get_stats() accordingly.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
commit
28172739f0a276eb8d6ca917b3974c2edb036da3
Author: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed Jul 7 14:58:56 2010 -0700
net: fix 64 bit counters on 32 bit arches
There is a small possibility that a reader gets incorrect values on 32
bit arches. SNMP applications could catch incorrect counters when a
32bit high part is changed by another stats consumer/provider.
One way to solve this is to add a rtnl_link_stats64 param to all
ndo_get_stats64() methods, and also add such a parameter to
dev_get_stats().
Rule is that we are not allowed to use dev->stats64 as a temporary
storage for 64bit stats, but a caller provided area (usually on stack)
Old drivers (only providing get_stats() method) need no changes.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>