more intellegent path failure profiling using LRSM

pull/1020/head
Jeff Becker 5 years ago
parent 52b13b9f1e
commit a7a101e33c
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -135,11 +135,13 @@ namespace llarp
uint64_t currentStatus = status; uint64_t currentStatus = status;
size_t index = 0; size_t index = 0;
absl::optional< RouterID > failedAt;
while(index < hops.size()) while(index < hops.size())
{ {
if(!frames[index].DoDecrypt(hops[index].shared)) if(!frames[index].DoDecrypt(hops[index].shared))
{ {
currentStatus = LR_StatusRecord::FAIL_DECRYPT_ERROR; currentStatus = LR_StatusRecord::FAIL_DECRYPT_ERROR;
failedAt = hops[index].rc.pubkey;
break; break;
} }
llarp::LogDebug("decrypted LRSM frame from ", hops[index].rc.pubkey); llarp::LogDebug("decrypted LRSM frame from ", hops[index].rc.pubkey);
@ -154,22 +156,31 @@ namespace llarp
llarp::LogWarn("malformed frame inside LRCM from ", llarp::LogWarn("malformed frame inside LRCM from ",
hops[index].rc.pubkey); hops[index].rc.pubkey);
currentStatus = LR_StatusRecord::FAIL_MALFORMED_RECORD; currentStatus = LR_StatusRecord::FAIL_MALFORMED_RECORD;
failedAt = hops[index].rc.pubkey;
break; break;
} }
llarp::LogDebug("Decoded LR Status Record from ", llarp::LogDebug("Decoded LR Status Record from ",
hops[index].rc.pubkey); hops[index].rc.pubkey);
currentStatus = record.status; currentStatus = record.status;
if((record.status & LR_StatusRecord::SUCCESS)
if((currentStatus & LR_StatusRecord::SUCCESS) == 0) != LR_StatusRecord::SUCCESS)
{ {
// failed at next hop
if(index + 1 < hops.size())
{
failedAt = hops[index + 1].rc.pubkey;
}
else
{
failedAt = hops[index].rc.pubkey;
}
break; break;
} }
++index; ++index;
} }
if(currentStatus & LR_StatusRecord::SUCCESS) if((currentStatus & LR_StatusRecord::SUCCESS) == LR_StatusRecord::SUCCESS)
{ {
llarp::LogDebug("LR_Status message processed, path build successful"); llarp::LogDebug("LR_Status message processed, path build successful");
auto self = shared_from_this(); auto self = shared_from_this();
@ -177,8 +188,13 @@ namespace llarp
} }
else else
{ {
r->routerProfiling().MarkPathFail(this); if(failedAt.has_value())
{
LogWarn(Name(), " build failed at ", failedAt.value());
r->routerProfiling().MarkHopFail(failedAt.value());
}
else
r->routerProfiling().MarkPathFail(this);
llarp::LogDebug("LR_Status message processed, path build failed"); llarp::LogDebug("LR_Status message processed, path build failed");
if(currentStatus & LR_StatusRecord::FAIL_TIMEOUT) if(currentStatus & LR_StatusRecord::FAIL_TIMEOUT)
@ -230,7 +246,7 @@ namespace llarp
// TODO: meaningful return value? // TODO: meaningful return value?
return true; return true;
} } // namespace path
void void
Path::EnterState(PathStatus st, llarp_time_t now) Path::EnterState(PathStatus st, llarp_time_t now)

@ -180,6 +180,14 @@ namespace llarp
m_Profiles.erase(r); m_Profiles.erase(r);
} }
void
Profiling::MarkHopFail(const RouterID& r)
{
lock_t lock(&m_ProfilesMutex);
m_Profiles[r].pathFailCount += 1;
m_Profiles[r].lastUpdated = llarp::time_now_ms();
}
void void
Profiling::MarkPathFail(path::Path* p) Profiling::MarkPathFail(path::Path* p)
{ {

@ -77,6 +77,9 @@ namespace llarp
void void
MarkPathSuccess(path::Path* p) LOCKS_EXCLUDED(m_ProfilesMutex); MarkPathSuccess(path::Path* p) LOCKS_EXCLUDED(m_ProfilesMutex);
void
MarkHopFail(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex);
void void
ClearProfile(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex); ClearProfile(const RouterID& r) LOCKS_EXCLUDED(m_ProfilesMutex);

Loading…
Cancel
Save