From 8e9396419cb9e9067412e90a932d8d396f810624 Mon Sep 17 00:00:00 2001 From: gardners Date: Tue, 22 May 2012 14:15:35 +0930 Subject: [PATCH] adding ignored manifest list to let us ignore repeated offerings of broken manifests without wasting effort. --- rhizome.c | 6 +++- rhizome.h | 4 +++ rhizome_fetch.c | 75 ++++++++++++++++++++++++++++++++++++++++- rhizome_http.c | 4 +-- rhizome_packetformats.c | 13 +++++-- 5 files changed, 95 insertions(+), 7 deletions(-) diff --git a/rhizome.c b/rhizome.c index 550314f7..4d704223 100644 --- a/rhizome.c +++ b/rhizome.c @@ -376,6 +376,10 @@ long long rhizome_voice_timeout=0; int rhizome_saw_voice_traffic() { /* We are in "voice mode" for a second after sending a voice frame */ - rhizome_voice_timeout=overlay_gettime_ms()+1000; + if (rhizome_voice_timeoutcryptoSignPublic[0]>>(8-IGNORED_BIN_BITS); + int slot; + for(slot=0;slotcryptoSignPublic, + crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)) + { + if (ignored.bins[bin].m[slot].timeout>overlay_gettime_ms()) + return 1; + else + return 0; + } + } + return 0; +} + +int rhizome_queue_ignore_manifest(rhizome_manifest *m, + struct sockaddr_in *peerip,int timeout) +{ + /* The supplied manifest from a given IP has errors, so remember + that it isn't worth considering */ + int i; + + int bin = m->cryptoSignPublic[0]>>(8-IGNORED_BIN_BITS); + int slot; + for(slot=0;slotcryptoSignPublic, + crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)) + break; + } + if (slot>=IGNORED_BIN_SIZE) slot=random()%IGNORED_BIN_SIZE; + bcopy(&m->cryptoSignPublic[0], + &ignored.bins[bin].m[slot].bid[0], + crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES); + /* ignore for a while */ + ignored.bins[bin].m[slot].timeout=overlay_gettime_ms()+timeout; + bcopy(peerip, + &ignored.bins[bin].m[slot].peer, + sizeof(struct sockaddr_in)); + return 0; + +} + int rhizome_queue_manifest_import(rhizome_manifest *m, struct sockaddr_in *peerip) { @@ -469,7 +542,7 @@ int rhizome_fetch_poll() { int rn; if (!rhizome_poll_fetchP) return 0; - if (debug&DEBUG_RHIZOME) WHYF("Checking %d active fetch requests", + if (0&&debug&DEBUG_RHIZOME) WHYF("Checking %d active fetch requests", rhizome_file_fetch_queue_count); for(rn=0;rnpayload->bytes[ofs], manifest_length,RHIZOME_DONTVERIFY); int importManifest=0; - if (m&&(!m->errors)) + if (rhizome_ignore_manifest_check(m,(struct sockaddr_in *)f->recvaddr)) + { + /* Ignoring manifest that has caused us problems recently */ + } + else if (m&&(!m->errors)) { /* Manifest is okay, so see if it is worth storing */ if (rhizome_manifest_version_cache_lookup(m)) { @@ -368,9 +371,12 @@ int overlay_rhizome_saw_advertisements(int i,overlay_frame *f, long long now) else { if (debug&DEBUG_RHIZOME) WHY("Unverified manifest has errors - so not processing any further."); + /* Don't waste any time on this manifest in future attempts for at least + a minute. */ + rhizome_queue_ignore_manifest(m,(struct sockaddr_in*)f->recvaddr,60000); } if (m) rhizome_manifest_free(m); - m=NULL; + m=NULL; if (importManifest) { /* Okay, so the manifest looks like it is potentially interesting to us, @@ -380,6 +386,7 @@ int overlay_rhizome_saw_advertisements(int i,overlay_frame *f, long long now) manifest_length,RHIZOME_VERIFY); if (m->errors) { if (debug&DEBUG_RHIZOME) WHYF("Verifying manifest %s revealed errors -- not storing.",manifest_id); + rhizome_queue_ignore_manifest(m,(struct sockaddr_in*)f->recvaddr,60000); rhizome_manifest_free(m); } else { if (debug&DEBUG_RHIZOME) WHYF("Verifying manifest %s revealed no errors -- will try to store.",manifest_id);