Skip to content

Commit 8bcb55b

Browse files
committed
restore previously removed bandwidth limit configuration sanity check as it could still save huge spikes from getting recorded in edge cases
1 parent 7b898aa commit 8bcb55b

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

CHANGES

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
- Fixed
44
- Opening of body html tag was missing on some pages in image output
55
example cgi (examples/vnstat.cgi)
6-
- Unnecessary bandwidth limit configuration sanity check removed when
7-
interface counters are in 64-bit range without overflow detected
86
- New
97
- Add database data merge support as --merge
108
- Add --db for specifying database file for queries (vnstat and vnstati)

src/daemon.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ int processifinfo(DSTATE *s, datacache **dc)
553553
uint64_t maxtransfer;
554554
uint32_t maxbw;
555555
time_t interval;
556-
short detected64bit = 0, noreset64bit = 0;
556+
short detected64bit = 0;
557557

558558
if ((*dc)->syncneeded) { /* if --sync was used during startup */
559559
(*dc)->currx = ifinfo.rx;
@@ -583,10 +583,6 @@ int processifinfo(DSTATE *s, datacache **dc)
583583
detected64bit = 1;
584584
}
585585

586-
if ((ifinfo.rx > MAX32 && ifinfo.rx >= (*dc)->currx) || (ifinfo.tx > MAX32 && ifinfo.tx >= (*dc)->curtx)) {
587-
noreset64bit = 1;
588-
}
589-
590586
rxchange = countercalc(&(*dc)->currx, &ifinfo.rx, ifinfo.is64bit);
591587
txchange = countercalc(&(*dc)->curtx, &ifinfo.tx, ifinfo.is64bit);
592588

@@ -600,16 +596,10 @@ int processifinfo(DSTATE *s, datacache **dc)
600596
}
601597
}
602598

603-
/* trust interface data without limits when counters are 64-bit and over maximum 32-bit range without both having overflown */
604-
if (noreset64bit) {
605-
maxbw = 0;
606-
} else {
607-
/* get bandwidth limit for current interface */
608-
ibwget((*dc)->interface, &maxbw);
609-
}
599+
/* get bandwidth limit for current interface */
600+
ibwget((*dc)->interface, &maxbw);
610601

611602
if (maxbw > 0) {
612-
613603
/* calculate maximum possible transfer since last update based on set maximum rate */
614604
/* and add 2% in order to be on the safe side */
615605
maxtransfer = (uint64_t)(ceilf(((float)maxbw / (float)8) * (float)interval * (float)1.02)) * 1024 * 1024;

tests/daemon_tests.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ START_TEST(processifinfo_does_not_add_traffic_when_over_limit)
13631363
}
13641364
END_TEST
13651365

1366-
START_TEST(processifinfo_adds_traffic_when_over_limit_with_64bit)
1366+
START_TEST(processifinfo_does_not_add_add_traffic_when_over_limit_with_64bit)
13671367
{
13681368
int ret;
13691369
DSTATE s;
@@ -1395,9 +1395,7 @@ START_TEST(processifinfo_adds_traffic_when_over_limit_with_64bit)
13951395
ck_assert_int_eq(s.dcache->syncneeded, 0);
13961396
ck_assert(s.dcache->currx == (MAX32 + 1111111));
13971397
ck_assert(s.dcache->curtx == (MAX32 + 2222222));
1398-
ck_assert_ptr_ne(s.dcache->log, NULL);
1399-
ck_assert_int_eq(s.dcache->log->rx, 1111110);
1400-
ck_assert_int_eq(s.dcache->log->tx, 2222221);
1398+
ck_assert_ptr_eq(s.dcache->log, NULL);
14011399

14021400
datacache_clear(&s.dcache);
14031401
}
@@ -1673,7 +1671,7 @@ void add_daemon_tests(Suite *s)
16731671
tcase_add_test(tc_daemon, processifinfo_syncs_if_timestamps_match);
16741672
tcase_add_test(tc_daemon, processifinfo_adds_traffic);
16751673
tcase_add_test(tc_daemon, processifinfo_does_not_add_traffic_when_over_limit);
1676-
tcase_add_test(tc_daemon, processifinfo_adds_traffic_when_over_limit_with_64bit);
1674+
tcase_add_test(tc_daemon, processifinfo_does_not_add_add_traffic_when_over_limit_with_64bit);
16771675
tcase_add_test(tc_daemon, processifinfo_adds_zero_traffic_when_over_limit);
16781676
tcase_add_test(tc_daemon, datacache_status_can_handle_nothing);
16791677
tcase_add_test(tc_daemon, datacache_status_can_show_limits);

0 commit comments

Comments
 (0)