]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
sched: validate KIST sched options
authorMatt Traudt <sirmatt@ksu.edu>
Wed, 13 Sep 2017 16:47:02 +0000 (12:47 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Fri, 15 Sep 2017 15:40:59 +0000 (11:40 -0400)
src/or/config.c
src/or/scheduler.h
src/or/scheduler_kist.c

index 285d4952f2a748b4e8bf6667f0da2693940939db..f332ac97f834e842d26f3f4c6409a62623945386 100644 (file)
@@ -3112,6 +3112,19 @@ options_validate(or_options_t *old_options, or_options_t *options,
     routerset_union(options->ExcludeExitNodesUnion_,options->ExcludeNodes);
   }
 
+  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) {
+    char *buf = tor_calloc(80, sizeof(char));
+    tor_snprintf(buf, 80, "KISTSchedRunInterval must not be more than %d (ms)",
+                 KIST_SCHED_RUN_INTERVAL_MAX);
+    *msg = buf;
+    return -1;
+  }
+
   if (options->NodeFamilies) {
     options->NodeFamilySets = smartlist_new();
     for (cl = options->NodeFamilies; cl; cl = cl->next) {
index 6cf75c585a1c9f1c958095edef3eae96aa57a4d9..0d82352734abb9b8bcba86987d891e6c3393fcf2 100644 (file)
@@ -82,6 +82,20 @@ typedef struct scheduler_s {
   void (*on_new_options)(void);
 } scheduler_t;
 
+/*****************************************************************************
+ * Globally visible scheduler variables/values
+ *
+ * These are variables/constants that all of Tor should be able to see.
+ *****************************************************************************/
+
+/* Default interval that KIST runs (in ms). */
+#define KIST_SCHED_RUN_INTERVAL_DEFAULT 10
+/* Minimum interval that KIST runs. This value disables KIST. */
+#define KIST_SCHED_RUN_INTERVAL_MIN 0
+/* Maximum interval that KIST runs (in ms). */
+#define KIST_SCHED_RUN_INTERVAL_MAX 100
+
+
 /*****************************************************************************
  * Globally visible scheduler functions
  *
index d3b19fdd1d65f2ad8c6c8954c1d0b1bcf780eb1e..3c3d26ad5afe689f71d176b6319225d7b23fc43b 100644 (file)
@@ -623,13 +623,6 @@ get_kist_scheduler(void)
   return kist_scheduler;
 }
 
-/* Default interval that KIST runs (in ms). */
-#define KIST_SCHED_RUN_INTERVAL_DEFAULT 10
-/* Minimum interval that KIST runs. This value disables KIST. */
-#define KIST_SCHED_RUN_INTERVAL_MIN 0
-/* Maximum interval that KIST runs (in ms). */
-#define KIST_SCHED_RUN_INTERVAL_MAX 100
-
 /* Check the torrc for the configured KIST scheduler run interval.
  * - If torrc < 0, then return the negative torrc value (shouldn't even be
  *   using KIST)