]> granicus.if.org Git - vnstat/commitdiff
improve 64-bit interface counter detection
authorTeemu Toivola <git@humdi.net>
Sat, 20 Apr 2019 16:34:03 +0000 (19:34 +0300)
committerTeemu Toivola <git@humdi.net>
Sat, 20 Apr 2019 16:34:03 +0000 (19:34 +0300)
src/common.c
src/daemon.c

index 543cf502ed65558a432dcff33d4d7b06dcc122f2..a3ac25f21f4053b23c5c1099ac2086adf6dc090c 100644 (file)
@@ -217,7 +217,7 @@ uint64_t countercalc(const uint64_t *a, const uint64_t *b, const short is64bit)
                /* rollover exists */
        } else {
                /* counter is 64bit */
-               if (*a > MAX32 || is64bit == 1) {
+               if (*a > MAX32 || *b > MAX32 || is64bit == 1) {
                        if (debug)
                                printf("cc64 (%d): uint64 - %" PRIu64 " + %" PRIu64 " = %" PRIu64 "\n", is64bit, *a, *b, (uint64_t)MAX64 - *a + *b);
                        return MAX64 - *a + *b;
index f62fa64bd293eb0ae4315e7384aed9bfb2a1d995..bafdd6e5eb7722e2f6aced2838e094563f534d3e 100644 (file)
@@ -528,6 +528,10 @@ int processifinfo(DSTATE *s, datacache **dc)
        /* in order to be on the safe side and avoid discarding data in case there's some random extra delay */
        if ((interval >= 1) && (interval <= 360)) {
 
+               if ((*dc)->currx > MAX32 || (*dc)->curtx > MAX32 || ifinfo.rx > MAX32 || ifinfo.tx > MAX32) {
+                       ifinfo.is64bit = 1;
+               }
+
                rxchange = countercalc(&(*dc)->currx, &ifinfo.rx, ifinfo.is64bit);
                txchange = countercalc(&(*dc)->curtx, &ifinfo.tx, ifinfo.is64bit);