diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index db1496e3..3168ba18 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,9 @@ +1998-11-30 Martin Baulig + + * netload.c: Use correct header files both for libc5 and glibc. + With Linux >= 2.1.114 we no longer use IP accounting since it + already has byte counts in /proc/net/dev. + 1998-11-22 Martin Baulig * netload.c (glibtop_get_netload_s): Added implementation diff --git a/sysdeps/linux/netload.c b/sysdeps/linux/netload.c index 4fa1b39e..fa715bef 100644 --- a/sysdeps/linux/netload.c +++ b/sysdeps/linux/netload.c @@ -27,8 +27,19 @@ #include #include +#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 +/* GNU LibC */ #include #include +#else /* Libc 5 */ +#include +#include +#include +#include +#include +#include +#include +#endif static const unsigned long _glibtop_sysdeps_netload = (1 << GLIBTOP_NETLOAD_ERRORS_IN) + @@ -158,6 +169,13 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, close (skfd); } + /* Linux 2.1.114 - don't know where exactly this was added, but + * recent kernels have byte count in /proc/net/dev so we don't + * need IP accounting. + */ + +#if LINUX_VERSION_CODE < 131442 + /* If IP accounting is enabled in the kernel and it is * enabled for the requested interface, we use it to * get the data. In this case, we don't use /proc/net/dev @@ -231,6 +249,8 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf, if (success) return; } +#endif + /* Ok, either IP accounting is not enabled in the kernel or * it was not enabled for the requested interface. */