aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-11-12 13:12:14 -0500
committerNick Mathewson <nickm@torproject.org>2014-11-12 13:12:14 -0500
commit81433e74322bb6cab67458ff7ba524ee86ad7e1c (patch)
treebcf1f4eb6cd71af800f63cdcef311034a78c0e4e
parentccc54d545ec15205d3ed3a92ad4c783adbdc97d1 (diff)
parent032560fc750811ba361143d99cb61ab4abb26b36 (diff)
downloadtor-81433e74322bb6cab67458ff7ba524ee86ad7e1c.tar.gz
tor-81433e74322bb6cab67458ff7ba524ee86ad7e1c.zip
Merge remote-tracking branch 'rl1987/bug13644'
-rw-r--r--changes/bug136444
-rw-r--r--src/or/dirserv.c6
-rw-r--r--src/or/or.h18
-rw-r--r--src/or/routerlist.c4
-rw-r--r--src/or/routerlist.h2
5 files changed, 27 insertions, 7 deletions
diff --git a/changes/bug13644 b/changes/bug13644
new file mode 100644
index 0000000000..959ce65fc9
--- /dev/null
+++ b/changes/bug13644
@@ -0,0 +1,4 @@
+ o Code simplifications and refactoring:
+ - Document all members of was_router_added_t enum and rename
+ ROUTER_WAS_NOT_NEW to ROUTER_IS_ALREADY_KNOWN to make it less
+ confusable with ROUTER_WAS_TOO_OLD. Fixes issue 13644.
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 730f005a96..d31bb72361 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -512,7 +512,7 @@ dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose,
if (!n_parsed) {
*msg = "No descriptors found in your POST.";
if (WRA_WAS_ADDED(r))
- r = ROUTER_WAS_NOT_NEW;
+ r = ROUTER_IS_ALREADY_KNOWN;
} else {
*msg = "(no message)";
}
@@ -574,7 +574,7 @@ dirserv_add_descriptor(routerinfo_t *ri, const char **msg, const char *source)
ri->cache_info.signed_descriptor_body,
ri->cache_info.signed_descriptor_len, *msg);
routerinfo_free(ri);
- return ROUTER_WAS_NOT_NEW;
+ return ROUTER_IS_ALREADY_KNOWN;
}
/* Make a copy of desc, since router_add_to_routerlist might free
@@ -646,7 +646,7 @@ dirserv_add_extrainfo(extrainfo_t *ei, const char **msg)
if ((r = routerinfo_incompatible_with_extrainfo(ri, ei, NULL, msg))) {
extrainfo_free(ei);
- return r < 0 ? ROUTER_WAS_NOT_NEW : ROUTER_BAD_EI;
+ return r < 0 ? ROUTER_IS_ALREADY_KNOWN : ROUTER_BAD_EI;
}
router_add_extrainfo_to_routerlist(ei, msg, 0, 0);
return ROUTER_ADDED_SUCCESSFULLY;
diff --git a/src/or/or.h b/src/or/or.h
index 524f99daab..5ebe7bfac3 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -5003,14 +5003,30 @@ typedef enum {
/** Return value for router_add_to_routerlist() and dirserv_add_descriptor() */
typedef enum was_router_added_t {
+ /* Router was added successfully. */
ROUTER_ADDED_SUCCESSFULLY = 1,
+ /* Router descriptor was added with warnings to submitter. */
ROUTER_ADDED_NOTIFY_GENERATOR = 0,
+ /* Extrainfo document was rejected because no corresponding router
+ * descriptor was found OR router descriptor was rejected because
+ * it was incompatible with its extrainfo document. */
ROUTER_BAD_EI = -1,
- ROUTER_WAS_NOT_NEW = -2,
+ /* Router descriptor was rejected because it is already known. */
+ ROUTER_IS_ALREADY_KNOWN = -2,
+ /* General purpose router was rejected, because it was not listed
+ * in consensus. */
ROUTER_NOT_IN_CONSENSUS = -3,
+ /* Router was neither in directory consensus nor in any of
+ * networkstatus documents. Caching it to access later.
+ * (Applies to fetched descriptors only.) */
ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS = -4,
+ /* Router was rejected by directory authority. */
ROUTER_AUTHDIR_REJECTS = -5,
+ /* Bridge descriptor was rejected because such bridge was not one
+ * of the bridges we have listed in our configuration. */
ROUTER_WAS_NOT_WANTED = -6,
+ /* Router descriptor was rejected because it was older than
+ * OLD_ROUTER_DESC_MAX_AGE. */
ROUTER_WAS_TOO_OLD = -7,
} was_router_added_t;
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index fb39b6ea64..0ebdac6851 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -3382,7 +3382,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
router_describe(router));
*msg = "Router descriptor was not new.";
routerinfo_free(router);
- return ROUTER_WAS_NOT_NEW;
+ return ROUTER_IS_ALREADY_KNOWN;
}
}
@@ -3467,7 +3467,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
&routerlist->desc_store);
routerlist_insert_old(routerlist, router);
*msg = "Router descriptor was not new.";
- return ROUTER_WAS_NOT_NEW;
+ return ROUTER_IS_ALREADY_KNOWN;
} else {
/* Same key, and either new, or listed in the consensus. */
log_debug(LD_DIR, "Replacing entry for router %s",
diff --git a/src/or/routerlist.h b/src/or/routerlist.h
index c6151deb49..e73e69b63a 100644
--- a/src/or/routerlist.h
+++ b/src/or/routerlist.h
@@ -118,7 +118,7 @@ WRA_WAS_ADDED(was_router_added_t s) {
static INLINE int WRA_WAS_OUTDATED(was_router_added_t s)
{
return (s == ROUTER_WAS_TOO_OLD ||
- s == ROUTER_WAS_NOT_NEW ||
+ s == ROUTER_IS_ALREADY_KNOWN ||
s == ROUTER_NOT_IN_CONSENSUS ||
s == ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS);
}