- Highlight current day in top list when visible
- Changes in interface specific detected bandwidth limits are reported
in the log
+ - UpdateInterval value is automatically adjusted during daemon startup if
+ found to be too high compared to the value of MaxBandwidth
- Notes
- Added clarification to the man page that the 'jsonversion' and
'xmlversion' fields in the --json and --xml outputs should be seen as
void validatecfg(void)
{
+ uint32_t rolloversecs;
const char *invalidvalue = "Invalid value for";
const char *resettingto = "resetting to";
const char *noslashstart = "doesn't start with \"/\", resetting to default.";
snprintf(errorstring, 1024, "%s OfflineSaveInterval, %s \"%d\".", invalidvalue, resettingto, cfg.offsaveinterval);
printe(PT_Config);
}
+
+ /* enforce update interval to be short enough that 32-bit interface counter rollover can be detected */
+ /* 1.02 is the same 2% safety buffer as used in processifinfo() in daemon.c */
+ /* noexit check results in warning being shown only when the daemon is started */
+ if (noexit && cfg.maxbw > 0) {
+ rolloversecs = (uint32_t)(MAX32 / (cfg.maxbw * 1024 * 1024 * (float)1.02 / 8));
+ if (rolloversecs <= (uint32_t)cfg.updateinterval) {
+ cfg.updateinterval = UPDATEINTERVAL;
+ if (rolloversecs <= (uint32_t)cfg.updateinterval) {
+ cfg.updateinterval /= 2;
+ }
+ snprintf(errorstring, 1024, "UpdateInterval has been reset to %d seconds in order to ensure correct counter rollover detection at %d Mbit.", cfg.updateinterval, cfg.maxbw);
+ printe(PT_Config);
+ }
+ }
}
void defaultcfg(void)
}
END_TEST
+START_TEST(validatecfg_can_tune_updateinterval_to_avoid_rollover_issues)
+{
+ noexit = 1;
+ defaultcfg();
+ cfg.updateinterval = 60;
+ cfg.maxbw = 1000;
+ cfg.bwdetection = 1;
+ suppress_output();
+ validatecfg();
+ ck_assert_int_ne(cfg.updateinterval, 60);
+ ck_assert_int_eq(cfg.updateinterval, UPDATEINTERVAL);
+}
+END_TEST
+
+START_TEST(validatecfg_has_fallback_for_updateinterval_for_very_fast_interfaces)
+{
+ noexit = 1;
+ defaultcfg();
+ cfg.updateinterval = 60;
+ cfg.maxbw = 2000;
+ cfg.bwdetection = 1;
+ suppress_output();
+ validatecfg();
+ ck_assert_int_ne(cfg.updateinterval, 60);
+ ck_assert_int_ne(cfg.updateinterval, UPDATEINTERVAL);
+ ck_assert_int_eq(cfg.updateinterval, (UPDATEINTERVAL / 2));
+}
+END_TEST
+
START_TEST(printcfgfile_default)
{
defaultcfg();
tcase_add_test(tc_config, validatecfg_default);
tcase_add_test(tc_config, validatecfg_does_not_modify_valid_changes);
tcase_add_test(tc_config, validatecfg_restores_invalid_values_back_to_default);
+ tcase_add_test(tc_config, validatecfg_can_tune_updateinterval_to_avoid_rollover_issues);
+ tcase_add_test(tc_config, validatecfg_has_fallback_for_updateinterval_for_very_fast_interfaces);
tcase_add_test(tc_config, printcfgfile_default);
tcase_add_test(tc_config, loadcfg_included_default);
tcase_add_test(tc_config, loadcfg_no_file);