On Sun Mar 13 15:23:19 2011, aldem wrote:
Show quoted text> It seems that net_device_stats struct (defined in linux/netdevice.h) is
> out of sync with structure sent over netlink.
>
> Namely, all members in netlink are 32 bit integers, while in (x64) kernel
> netdevice.h defines "unsigned long", thus 64 bit, members.
>
> The correct structure to use should be rtnl_link_stats (defined in
> linux/if_link.h) - then everything works.
>
> This was discovered on Fedora 12 x64.
Ah. I suspect net_device_stats is the kernel internal version.
Find attached patch.
--
Paul Evans
=== modified file 'lib/IO/Socket/Netlink/Route.pm'
--- lib/IO/Socket/Netlink/Route.pm 2011-03-13 20:56:00 +0000
+++ lib/IO/Socket/Netlink/Route.pm 2011-03-13 20:58:53 +0000
@@ -1,7 +1,7 @@
# You may distribute under the terms of either the GNU General Public License
# or the Artistic License (the same terms as Perl itself)
#
-# (C) Paul Evans, 2010 -- leonerd@leonerd.org.uk
+# (C) Paul Evans, 2010-2011 -- leonerd@leonerd.org.uk
package IO::Socket::Netlink::Route;
@@ -122,7 +122,7 @@
use base qw( IO::Socket::Netlink::Route::_Message );
use Socket::Netlink::Route qw( :DEFAULT
pack_ifinfomsg unpack_ifinfomsg
- pack_net_device_stats unpack_net_device_stats
+ pack_rtnl_link_stats unpack_rtnl_link_stats
);
use Socket qw( AF_UNSPEC );
@@ -218,8 +218,8 @@
linkmode => [ IFLA_LINKMODE, "u8" ],
);
-sub pack_nlattr_stats { pack_net_device_stats $_[1] }
-sub unpack_nlattr_stats { unpack_net_device_stats $_[1] }
+sub pack_nlattr_stats { pack_rtnl_link_stats $_[1] }
+sub unpack_nlattr_stats { unpack_rtnl_link_stats $_[1] }
package IO::Socket::Netlink::Route::_IfaddrMsg;
=== modified file 'lib/Socket/Netlink/Route_const.pm.PL'
--- lib/Socket/Netlink/Route_const.pm.PL 2010-02-25 23:57:17 +0000
+++ lib/Socket/Netlink/Route_const.pm.PL 2011-03-13 20:58:53 +0000
@@ -11,7 +11,7 @@
include "linux/netlink.h";
include "linux/rtnetlink.h";
-include "linux/netdevice.h"; # for struct net_device_stats
+include "linux/if_link.h"; # for struct rtnl_link_stats
use_export;
@@ -36,7 +36,7 @@
STATS COST PRIORITY MASTER WIRELESS PROTINFO TXQLEN MAP WEIGHT OPERSTATE
LINKMODE LINKINFO NET_NS_PID IFALIAS );
-structure "struct net_device_stats",
+structure "struct rtnl_link_stats",
arg_style => "hashref",
members => [
map { $_ => member_numeric } qw(