[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r10230: Provide actual reasons when dropping an uploaded extrainfo f (in tor/trunk: . src/or)



Author: nickm
Date: 2007-05-20 14:03:26 -0400 (Sun, 20 May 2007)
New Revision: 10230

Modified:
   tor/trunk/
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/router.c
   tor/trunk/src/or/routerlist.c
   tor/trunk/src/or/test.c
Log:
 r13021@Kushana:  nickm | 2007-05-20 14:03:10 -0400
 Provide actual reasons when dropping an uploaded extrainfo for incompatibility; also, clean whitespace.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13021] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2007-05-20 17:43:55 UTC (rev 10229)
+++ tor/trunk/src/or/directory.c	2007-05-20 18:03:26 UTC (rev 10230)
@@ -1973,7 +1973,8 @@
       case -2:
       case -1:
       case 1:
-        log_notice(LD_DIRSERV,"Rejected router descriptor from %s.",
+        log_notice(LD_DIRSERV,
+                   "Rejected router descriptor or extra-info from %s.",
                    conn->_base.address);
         /* malformed descriptor, or something wrong */
         write_http_status_line(conn, 400, msg);

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2007-05-20 17:43:55 UTC (rev 10229)
+++ tor/trunk/src/or/dirserv.c	2007-05-20 18:03:26 UTC (rev 10230)
@@ -630,8 +630,7 @@
     extrainfo_free(ei);
     return -1;
   }
-  if (routerinfo_incompatible_with_extrainfo(ri, ei)) {
-    *msg = "Router descriptor incompatible with extra-info descriptor";
+  if (routerinfo_incompatible_with_extrainfo(ri, ei, msg)) {
     extrainfo_free(ei);
     return -1;
   }

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-05-20 17:43:55 UTC (rev 10229)
+++ tor/trunk/src/or/or.h	2007-05-20 18:03:26 UTC (rev 10230)
@@ -3185,7 +3185,8 @@
 void router_reset_descriptor_download_failures(void);
 void router_reset_status_download_failures(void);
 int router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2);
-int routerinfo_incompatible_with_extrainfo(routerinfo_t *ri, extrainfo_t *ei);
+int routerinfo_incompatible_with_extrainfo(routerinfo_t *ri, extrainfo_t *ei,
+                                           const char **msg);
 const char *esc_router_info(routerinfo_t *router);
 
 char *networkstatus_getinfo_helper_single(routerstatus_t *rs);

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2007-05-20 17:43:55 UTC (rev 10229)
+++ tor/trunk/src/or/router.c	2007-05-20 18:03:26 UTC (rev 10230)
@@ -1063,7 +1063,7 @@
                 ri->cache_info.signed_descriptor_body,
                 ri->cache_info.signed_descriptor_len);
 
-  tor_assert(! routerinfo_incompatible_with_extrainfo(ri, ei));
+  tor_assert(! routerinfo_incompatible_with_extrainfo(ri, ei, NULL));
 
   if (desc_routerinfo)
     routerinfo_free(desc_routerinfo);

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-05-20 17:43:55 UTC (rev 10229)
+++ tor/trunk/src/or/routerlist.c	2007-05-20 18:03:26 UTC (rev 10230)
@@ -1802,7 +1802,7 @@
     /* This router is unknown; we can't even verify the signature. Give up.*/
     goto done;
   }
-  if (routerinfo_incompatible_with_extrainfo(ri, ei)) {
+  if (routerinfo_incompatible_with_extrainfo(ri, ei, NULL)) {
     if (ei->bad_sig) /* If the signature didn't check, it's just wrong. */
       goto done;
     sd = digestmap_get(rl->desc_by_eid_map,
@@ -4029,7 +4029,8 @@
     if ((rs_old = router_get_combined_status_by_digest(lowest))) {
       if (!memcmp(rs_out->status.descriptor_digest,
                   most_recent->descriptor_digest, DIGEST_LEN)) {
-        rs_out->dl_status.n_download_failures = rs_old->dl_status.n_download_failures;
+        rs_out->dl_status.n_download_failures =
+          rs_old->dl_status.n_download_failures;
         rs_out->dl_status.next_attempt_at = rs_old->dl_status.next_attempt_at;
       }
       rs_out->name_lookup_warned = rs_old->name_lookup_warned;
@@ -4848,7 +4849,8 @@
 
 /** DOCDOC */
 int
-routerinfo_incompatible_with_extrainfo(routerinfo_t *ri, extrainfo_t *ei)
+routerinfo_incompatible_with_extrainfo(routerinfo_t *ri, extrainfo_t *ei,
+                                       const char **msg)
 {
   tor_assert(ri);
   tor_assert(ei);
@@ -4860,8 +4862,10 @@
    * by the same rotuer.  */
   if (strcmp(ri->nickname, ei->nickname) ||
       memcmp(ri->cache_info.identity_digest, ei->cache_info.identity_digest,
-             DIGEST_LEN))
+             DIGEST_LEN)) {
+    if (msg) *msg = "Extrainfo nickname or identity did not match routerinfo";
     return 1; /* different servers */
+  }
 
   if (ei->pending_sig) {
     char signed_digest[128];
@@ -4871,21 +4875,27 @@
                DIGEST_LEN)) {
       ei->bad_sig = 1;
       tor_free(ei->pending_sig);
+      if (msg) *msg = "Extrainfo signature bad, or signed with wrong key";
       return 1; /* Bad signature, or no match. */
     }
 
     tor_free(ei->pending_sig);
   }
 
+  if (ei->cache_info.published_on < ei->cache_info.published_on) {
+    if (msg) *msg = "Extrainfo published time did not match routerdesc";
+    return 1;
+  } else if (ei->cache_info.published_on > ei->cache_info.published_on) {
+    if (msg) *msg = "Extrainfo published time did not match routerdesc";
+    return -1;
+  }
+
   if (memcmp(ei->cache_info.signed_descriptor_digest,
-             ri->cache_info.extra_info_digest, DIGEST_LEN))
+             ri->cache_info.extra_info_digest, DIGEST_LEN)) {
+    if (msg) *msg = "Extrainfo digest did not match value from routerdesc";
     return 1; /* Digest doesn't match declared value. */
+  }
 
-  if (ei->cache_info.published_on < ei->cache_info.published_on)
-    return 1;
-  else if (ei->cache_info.published_on > ei->cache_info.published_on)
-    return -1;
-
   return 0;
 }
 

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2007-05-20 17:43:55 UTC (rev 10229)
+++ tor/trunk/src/or/test.c	2007-05-20 18:03:26 UTC (rev 10230)
@@ -1106,7 +1106,6 @@
   test_assert(smartlist_string_isin(sl, "arma"));
   test_assert(smartlist_string_isin(sl, "the"));
 
-
   /* Test bsearch. */
   smartlist_sort(sl, _compare_strs);
   test_streq("nickm", smartlist_bsearch(sl, "zNicKM",
@@ -1114,8 +1113,6 @@
   test_streq("and", smartlist_bsearch(sl, " AND", _compare_without_first_ch));
   test_eq_ptr(NULL, smartlist_bsearch(sl, " ANz", _compare_without_first_ch));
 
-
-
   /* Test reverse() and pop_last() */
   smartlist_reverse(sl);
   cp = smartlist_join_strings(sl, ",", 0, NULL);