commit 0f4f40b70fe6ea16a43940f86db767e1a16a4f6e Merge: 962b0b849 065001714 Author: Nick Mathewson nickm@torproject.org Date: Fri Sep 15 12:00:50 2017 -0400
Merge remote-tracking branch 'dgoulet/ticket12541_032_02'
changes/ticket12541 | 23 ++ configure.ac | 28 ++ doc/tor.1.txt | 30 ++ src/common/sandbox.c | 34 +- src/ext/ht.h | 2 + src/or/channel.c | 8 +- src/or/channel.h | 2 +- src/or/config.c | 91 ++++-- src/or/include.am | 2 + src/or/networkstatus.c | 19 +- src/or/networkstatus.h | 7 +- src/or/or.h | 28 +- src/or/scheduler.c | 735 +++++++++++++++++++----------------------- src/or/scheduler.h | 203 ++++++++++-- src/or/scheduler_kist.c | 774 +++++++++++++++++++++++++++++++++++++++++++++ src/or/scheduler_vanilla.c | 196 ++++++++++++ src/test/test_options.c | 295 ++++------------- src/test/test_scheduler.c | 692 +++++++++++++++++++++++++++++----------- 18 files changed, 2264 insertions(+), 905 deletions(-)
diff --cc src/or/config.c index a5bda8be0,95f27b071..4a1361f9f --- a/src/or/config.c +++ b/src/or/config.c @@@ -2923,11 -2889,65 +2928,66 @@@ warn_about_relative_paths(or_options_t for (config_line_t *hs_line = options->RendConfigLines; hs_line; hs_line = hs_line->next) { if (!strcasecmp(hs_line->key, "HiddenServiceDir")) - warn_if_option_path_is_relative("HiddenServiceDir",hs_line->value); + n += warn_if_option_path_is_relative("HiddenServiceDir",hs_line->value); } + return n != 0; }
+ /* Validate options related to the scheduler. From the Schedulers list, the + * SchedulerTypes_ list is created with int values so once we select the + * scheduler, which can happen anytime at runtime, we don't have to parse + * strings and thus be quick. + * + * Return 0 on success else -1 and msg is set with an error message. */ + static int + options_validate_scheduler(or_options_t *options, char **msg) + { + tor_assert(options); + tor_assert(msg); + + if (!options->Schedulers || smartlist_len(options->Schedulers) == 0) { + REJECT("Empty Schedulers list. Either remove the option so the defaults " + "can be used or set at least one value."); + } + /* Ok, we do have scheduler types, validate them. */ + options->SchedulerTypes_ = smartlist_new(); + SMARTLIST_FOREACH_BEGIN(options->Schedulers, const char *, type) { + int *sched_type; + if (!strcasecmp("KISTLite", type)) { + sched_type = tor_malloc_zero(sizeof(int)); + *sched_type = SCHEDULER_KIST_LITE; + smartlist_add(options->SchedulerTypes_, sched_type); + } else if (!strcasecmp("KIST", type)) { + sched_type = tor_malloc_zero(sizeof(int)); + *sched_type = SCHEDULER_KIST; + smartlist_add(options->SchedulerTypes_, sched_type); + } else if (!strcasecmp("Vanilla", type)) { + sched_type = tor_malloc_zero(sizeof(int)); + *sched_type = SCHEDULER_VANILLA; + smartlist_add(options->SchedulerTypes_, sched_type); + } else { + tor_asprintf(msg, "Unknown type %s in option Schedulers. " + "Possible values are KIST, KISTLite and Vanilla.", + escaped(type)); + return -1; + } + } SMARTLIST_FOREACH_END(type); + + if (options->KISTSockBufSizeFactor < 0) { + REJECT("KISTSockBufSizeFactor must be at least 0"); + } + + /* Don't need to validate that the Interval is less than anything because + * zero is valid and all negative values are valid. */ + if (options->KISTSchedRunInterval > KIST_SCHED_RUN_INTERVAL_MAX) { + tor_asprintf(msg, "KISTSchedRunInterval must not be more than %d (ms)", + KIST_SCHED_RUN_INTERVAL_MAX); + return -1; + } + + return 0; + } + /* Validate options related to single onion services. * Modifies some options that are incompatible with single onion services. * On failure returns -1, and sets *msg to an error string.
tor-commits@lists.torproject.org