Bug 3727 - getifaddrs: Missing struct net_device_stats in linux/netdevice.h
Summary: getifaddrs: Missing struct net_device_stats in linux/netdevice.h
Status: RESOLVED INVALID
Alias: None
Product: uClibc
Classification: Unclassified
Component: Networking (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: Bernhard Reutner-Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-16 14:20 UTC by fireboxled
Modified: 2011-05-20 15:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fireboxled 2011-05-16 14:20:59 UTC
<The real source for this is the man pages for glibc getifaddrs>

When using the uClibc library function getifaddrs, a link list of structures is returned. When walking that list, records with address family AF_PACKET can have associated device statistics returned in a net_device_stats structure, and that data is pointed to with the generic void *ifa_data. glibc defines this struct in <linux/netdevice.h>. This struct definition is missing from uClibc <linux/netdevice.h>. This causes any uClibc client to getifaddrs to have to include their own struct definition.
Comment 1 fireboxled 2011-05-16 14:26:34 UTC
Workaround:

In a application .h:
#ifdef __UCLIBC__
struct net_device_stats {unsigned long rx_packets; unsigned long tx_packets; /* and then some... */};
#endif

Suggested Solution:
Add the struct definition in <linux/netdevice.h>
struct net_device_stats
{
	unsigned long	rx_packets;		/* total packets received	*/
	unsigned long	tx_packets;		/* total packets transmitted	*/
	unsigned long	rx_bytes;		/* total bytes received 	*/
	unsigned long	tx_bytes;		/* total bytes transmitted	*/
	unsigned long	rx_errors;		/* bad packets received		*/
	unsigned long	tx_errors;		/* packet transmit problems	*/
	unsigned long	rx_dropped;		/* no space in linux buffers	*/
	unsigned long	tx_dropped;		/* no space available in linux	*/
	unsigned long	multicast;		/* multicast packets received	*/
	unsigned long	collisions;

	/* detailed rx_errors: */
	unsigned long	rx_length_errors;
	unsigned long	rx_over_errors;		/* receiver ring buff overflow	*/
	unsigned long	rx_crc_errors;		/* recved pkt with crc error	*/
	unsigned long	rx_frame_errors;	/* recv'd frame alignment error */
	unsigned long	rx_fifo_errors;		/* recv'r fifo overrun		*/
	unsigned long	rx_missed_errors;	/* receiver missed packet	*/

	/* detailed tx_errors */
	unsigned long	tx_aborted_errors;
	unsigned long	tx_carrier_errors;
	unsigned long	tx_fifo_errors;
	unsigned long	tx_heartbeat_errors;
	unsigned long	tx_window_errors;
	
	/* for cslip etc */
	unsigned long	rx_compressed;
	unsigned long	tx_compressed;
};
Comment 2 fireboxled 2011-05-16 15:34:10 UTC
When using buildroot, uClibc needs to be configured with the UCLIBC_SUPPORT_AI_ADDRCONFIG option (make uclibc-menuconfig, then Networking/Support the AI_ADDRCONFIG flag). This is how support for getifaddrs() and <ifaddrs.h> are made available.
Comment 3 fireboxled 2011-05-20 15:29:15 UTC
Upstream commit changed <linux/netdevice.h>

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=be1f3c2c027cc5ad735df6a45a542ed1db7ec48b

Seems like I need <linux/if_link.h>, struct rtnl_link_stats instead.