From 485aa9415d0367dfbca34de116f0cff9fc16ffc1 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Wed, 4 Jan 2006 04:42:10 +0000 Subject: [PATCH] authdirs now stop whining so loudly about bad descriptors that they fetch from other dirservers. now when there's a log complaint, it's for sure from a freshly uploaded descriptor. svn:r5726 --- src/or/dirserv.c | 2 +- src/or/or.h | 2 +- src/or/routerlist.c | 16 +++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/or/dirserv.c b/src/or/dirserv.c index d95fdd64dc..34a3cf5ed7 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -532,7 +532,7 @@ dirserv_add_descriptor(const char *desc, const char **msg) control_event_or_authdir_new_descriptor("DROPPED", desc, *msg); return 0; } - if ((r = router_add_to_routerlist(ri, msg, 0))<0) { + if ((r = router_add_to_routerlist(ri, msg, 0, 0))<0) { if (r < -1) /* unless the routerinfo was fine, just out-of-date */ control_event_or_authdir_new_descriptor("REJECTED", desc, *msg); return r == -1 ? 0 : -1; diff --git a/src/or/or.h b/src/or/or.h index 06b515b73d..fe78382420 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2278,7 +2278,7 @@ void router_mark_as_down(const char *digest); void routerlist_remove_old_routers(void); void networkstatus_list_clean(time_t now); int router_add_to_routerlist(routerinfo_t *router, const char **msg, - int from_cache); + int from_cache, int from_fetch); int router_load_single_router(const char *s, const char **msg); void router_load_routers_from_string(const char *s, int from_cache, smartlist_t *requested_fingerprints); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 619425b507..eb8af3aa1b 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1465,6 +1465,11 @@ router_mark_as_down(const char *digest) * routerinfo was accepted, but we should notify the generator of the * descriptor using the message *msg. * + * If from_cache, this descriptor came from our disk cache. If + * from_fetch, we received it in response to a request we made. + * (If both are false, that means it was uploaded to us as an auth dir + * server or via the controller.) + * * This function should be called *after* * routers_update_status_from_networkstatus; subsequently, you should call * router_rebuild_store and control_event_descriptors_changed. @@ -1473,7 +1478,7 @@ router_mark_as_down(const char *digest) */ int router_add_to_routerlist(routerinfo_t *router, const char **msg, - int from_cache) + int from_cache, int from_fetch) { int i; char id_digest[DIGEST_LEN]; @@ -1505,7 +1510,8 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg, routerlist_remove_old_routers(); if (authdir) { - if (authdir_wants_to_reject_router(router, msg, !from_cache)) { + if (authdir_wants_to_reject_router(router, msg, + !from_cache && !from_fetch)) { routerinfo_free(router); return -2; } @@ -1831,7 +1837,7 @@ router_load_single_router(const char *s, const char **msg) smartlist_add(lst, ri); routers_update_status_from_networkstatus(lst, 0); - if (router_add_to_routerlist(ri, msg, 0)<0) { + if (router_add_to_routerlist(ri, msg, 0, 0)<0) { warn(LD_DIR, "Couldn't add router to list: %s Dropping.", *msg?*msg:"(No message)."); /* we've already assigned to *msg now, and ri is already freed */ @@ -1847,7 +1853,7 @@ router_load_single_router(const char *s, const char **msg) /** Given a string s containing some routerdescs, parse it and put the * routers into our directory. If from_cache is false, the routers - * have come from the network: cache them. + * are in response to a query to the network: cache them. * * If requested_fingerprints is provided, it must contain a list of * uppercased identity fingerprints. Do not update any router whose @@ -1888,7 +1894,7 @@ router_load_routers_from_string(const char *s, int from_cache, } } - if (router_add_to_routerlist(ri, &msg, from_cache) >= 0) + if (router_add_to_routerlist(ri, &msg, from_cache, !from_cache) >= 0) smartlist_add(changed, ri); });