]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
Use correct rt_link_statistics
authorStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 23 Aug 2010 16:13:05 +0000 (09:13 -0700)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 23 Aug 2010 16:13:05 +0000 (09:13 -0700)
In recent kernels, net_device_stats is not exposed and the code
shoulf have used rt_link_statistics.  Also, fix use of sprintf
with user supplied value.

misc/ifstat.c

index 0ce8c928d3831a26d3b621447f9d3dc3060040d0..5cf2e01031b91f57213f10296122278c7a003b0e 100644 (file)
@@ -29,7 +29,8 @@
 #include <getopt.h>
 
 #include <libnetlink.h>
-#include <linux/netdevice.h>
+#include <linux/if.h>
+#include <linux/if_link.h>
 
 #include <SNAPSHOT.h>
 
@@ -48,7 +49,7 @@ int npatterns;
 char info_source[128];
 int source_mismatch;
 
-#define MAXS (sizeof(struct net_device_stats)/sizeof(unsigned long))
+#define MAXS (sizeof(struct rtnl_link_stats)/sizeof(unsigned long))
 
 struct ifstat_ent
 {
@@ -677,9 +678,11 @@ int main(int argc, char *argv[])
        npatterns = argc;
 
        if (getenv("IFSTAT_HISTORY"))
-               snprintf(hist_name, sizeof(hist_name), getenv("IFSTAT_HISTORY"));
+               snprintf(hist_name, sizeof(hist_name),
+                        "%s", getenv("IFSTAT_HISTORY"));
        else
-               sprintf(hist_name, "%s/.ifstat.u%d", P_tmpdir, getuid());
+               snprintf(hist_name, sizeof(hist_name),
+                        "%s/.ifstat.u%d", P_tmpdir, getuid());
 
        if (reset_history)
                unlink(hist_name);