]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - misc/ifstat.c
Merge branch 'master' into next
[mirror_iproute2.git] / misc / ifstat.c
index 1be21703bf14c2ea0a7971ec00e73d5df5545071..60efe6cb60faafc78185b17bdadd9ed77f500595 100644 (file)
@@ -45,7 +45,6 @@ int no_update;
 int scan_interval;
 int time_constant;
 int show_errors;
-int pretty;
 double W;
 char **patterns;
 int npatterns;
@@ -111,8 +110,7 @@ static int match(const char *id)
        return 0;
 }
 
-static int get_nlmsg_extended(const struct sockaddr_nl *who,
-                             struct nlmsghdr *m, void *arg)
+static int get_nlmsg_extended(struct nlmsghdr *m, void *arg)
 {
        struct if_stats_msg *ifsm = NLMSG_DATA(m);
        struct rtattr *tb[IFLA_STATS_MAX+1];
@@ -155,8 +153,7 @@ static int get_nlmsg_extended(const struct sockaddr_nl *who,
        return 0;
 }
 
-static int get_nlmsg(const struct sockaddr_nl *who,
-                    struct nlmsghdr *m, void *arg)
+static int get_nlmsg(struct nlmsghdr *m, void *arg)
 {
        struct ifinfomsg *ifi = NLMSG_DATA(m);
        struct rtattr *tb[IFLA_MAX+1];
@@ -204,8 +201,8 @@ static void load_info(void)
        if (is_extended) {
                ll_init_map(&rth);
                filter_mask = IFLA_STATS_FILTER_BIT(filter_type);
-               if (rtnl_wilddump_stats_req_filter(&rth, AF_UNSPEC, RTM_GETSTATS,
-                                                  filter_mask) < 0) {
+               if (rtnl_statsdump_req_filter(&rth, AF_UNSPEC,
+                                             filter_mask) < 0) {
                        perror("Cannot send dump request");
                        exit(1);
                }
@@ -215,7 +212,7 @@ static void load_info(void)
                        exit(1);
                }
        } else {
-               if (rtnl_wilddump_request(&rth, AF_INET, RTM_GETLINK) < 0) {
+               if (rtnl_linkdump_req(&rth, AF_INET) < 0) {
                        perror("Cannot send dump request");
                        exit(1);
                }
@@ -992,12 +989,18 @@ int main(int argc, char *argv[])
            && verify_forging(fd) == 0) {
                FILE *sfp = fdopen(fd, "r");
 
-               load_raw_table(sfp);
-               if (hist_db && source_mismatch) {
-                       fprintf(stderr, "ifstat: history is stale, ignoring it.\n");
-                       hist_db = NULL;
+               if (!sfp) {
+                       fprintf(stderr, "ifstat: fdopen failed: %s\n",
+                               strerror(errno));
+                       close(fd);
+               } else  {
+                       load_raw_table(sfp);
+                       if (hist_db && source_mismatch) {
+                               fprintf(stderr, "ifstat: history is stale, ignoring it.\n");
+                               hist_db = NULL;
+                       }
+                       fclose(sfp);
                }
-               fclose(sfp);
        } else {
                if (fd >= 0)
                        close(fd);