]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge remote-tracking branch 'dgoulet/ticket12541_032_02'
authorNick Mathewson <nickm@torproject.org>
Fri, 15 Sep 2017 16:00:50 +0000 (12:00 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 15 Sep 2017 16:00:50 +0000 (12:00 -0400)
1  2 
doc/tor.1.txt
src/or/channel.c
src/or/config.c
src/or/networkstatus.c
src/or/networkstatus.h
src/or/or.h
src/test/test_options.c

diff --cc doc/tor.1.txt
Simple merge
Simple merge
diff --cc src/or/config.c
index a5bda8be006b561e7d1c382ac9bfcc66b64bd4a2,95f27b0717613329f4edec8c983926ebb1bfab64..4a1361f9f4421b1a445fed624978f839d16bbf8f
@@@ -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.
Simple merge
Simple merge
diff --cc src/or/or.h
Simple merge
Simple merge