Skip Menu |

This queue is for tickets about the Socket-Netlink-Route CPAN distribution.

Report information
The Basics
Id: 66589
Status: resolved
Priority: 0/
Queue: Socket-Netlink-Route

People
Owner: Nobody in particular
Requestors: aldem-cpan [...] aldem.net
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in:
  • 0.01
  • 0.02
Fixed in: 0.03



Subject: Incorrect members size for device stats
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.
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
Subject: rt66589.patch
=== 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(
I've also just released 0.03 to CPAN, with that patch and a couple of other fixes. Hopefully that should fix it. Let me know and I can close the bug. Thanks, -- Paul Evans
Subject: Re: [rt.cpan.org #66589] Incorrect members size for device stats
Date: Mon, 14 Mar 2011 12:42:13 +0100
To: Paul Evans via RT <bug-Socket-Netlink-Route [...] rt.cpan.org>
From: aldem-cpan [...] aldem.net
Hi Paul, Show quoted text
> I've also just released 0.03 to CPAN, with that patch and a couple of > other fixes. Hopefully that should fix it. > > Let me know and I can close the bug.
Looks OK now, thanks - you may close the ticket. And, by the way - thank you for this module, I was looking for Perl interface for netlink for quite loooong time :) Best regards, /Alexander
On Mon Mar 14 07:42:23 2011, aldem wrote: Show quoted text
> > Let me know and I can close the bug.
Now released as 0.03. -- Paul Evans