]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ipmroute: add support for age dumping
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Wed, 21 Sep 2016 09:45:58 +0000 (11:45 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 10 Oct 2016 02:09:31 +0000 (19:09 -0700)
Add support to dump the mroute cache entry age if the show_stats (-s)
switch is provided.
Example:
$ ip -s mroute
(0.0.0.0, 239.10.10.10)          Iif: eth0       Oifs: eth0
  0 packets, 0 bytes, Age  245.44

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
ip/ipmroute.c

index 133367a2388d6f561d1a8eb100bf23f54c80c7e5..512afcd2086eb6b4706fc1860dbdfc05e9f2d581 100644 (file)
@@ -169,6 +169,13 @@ int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
                        fprintf(fp, ", %"PRIu64" arrived on wrong iif.",
                                (uint64_t)mfcs->mfcs_wrong_if);
        }
+       if (show_stats && tb[RTA_EXPIRES]) {
+               struct timeval tv;
+
+               __jiffies_to_tv(&tv, rta_getattr_u64(tb[RTA_EXPIRES]));
+               fprintf(fp, ", Age %4i.%.2i", (int)tv.tv_sec,
+                       (int)tv.tv_usec/10000);
+       }
        fprintf(fp, "\n");
        fflush(fp);
        return 0;