Merge pull request #747 from majestrate/master

bug fixes
pull/749/head
Jeff 5 years ago committed by GitHub
commit 3d2dfcc027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3416,7 +3416,7 @@ utp_process_udp(utp_context *ctx, const byte *buffer, size_t len,
return 1; return 1;
} }
/*
if(ctx->utp_sockets->GetCount() > 3000) if(ctx->utp_sockets->GetCount() > 3000)
{ {
#if UTP_DEBUG_LOGGING #if UTP_DEBUG_LOGGING
@ -3427,6 +3427,7 @@ utp_process_udp(utp_context *ctx, const byte *buffer, size_t len,
return 1; return 1;
} }
*/
// true means yes, block connection. false means no, don't block. // true means yes, block connection. false means no, don't block.
if(utp_call_on_firewall(ctx, to, tolen)) if(utp_call_on_firewall(ctx, to, tolen))
{ {

@ -242,12 +242,12 @@ namespace llarp
m_InetToNetwork.Process([&](Pkt_t &pkt) { m_InetToNetwork.Process([&](Pkt_t &pkt) {
PubKey pk; PubKey pk;
{ {
auto itr = m_IPToKey.find(net::IPPacket::ExpandV4(pkt.dstv4())); auto itr = m_IPToKey.find(pkt.dstv6());
if(itr == m_IPToKey.end()) if(itr == m_IPToKey.end())
{ {
// drop // drop
LogWarn(Name(), " dropping packet, has no session at ", LogWarn(Name(), " dropping packet, has no session at ",
pkt.dstv4()); pkt.dstv6());
return; return;
} }
pk = itr->second; pk = itr->second;

@ -759,7 +759,10 @@ namespace llarp
pkt.UpdateIPv6Address({0}, {0}); pkt.UpdateIPv6Address({0}, {0});
if(sendFunc && sendFunc(pkt.Buffer())) if(sendFunc && sendFunc(pkt.Buffer()))
{
MarkIPActive(dst);
return; return;
}
llarp::LogWarn(Name(), " did not flush packets"); llarp::LogWarn(Name(), " did not flush packets");
}); });
} }
@ -799,8 +802,6 @@ namespace llarp
} }
else if(pkt.IsV6()) else if(pkt.IsV6())
{ {
if(pkt.srcv6() != huint128_t{0} || pkt.dstv6() != huint128_t{0})
return false;
pkt.UpdateIPv6Address(themIP, usIP); pkt.UpdateIPv6Address(themIP, usIP);
} }
return true; return true;

@ -69,13 +69,19 @@ namespace llarp
huint128_t huint128_t
IPPacket::srcv6() const IPPacket::srcv6() const
{ {
return In6ToHUInt(HeaderV6()->srcaddr); if(IsV6())
return In6ToHUInt(HeaderV6()->srcaddr);
else
return ExpandV4(srcv4());
} }
huint128_t huint128_t
IPPacket::dstv6() const IPPacket::dstv6() const
{ {
return In6ToHUInt(HeaderV6()->dstaddr); if(IsV6())
return In6ToHUInt(HeaderV6()->dstaddr);
else
return ExpandV4(dstv4());
} }
bool bool

@ -106,7 +106,7 @@ namespace llarp
Path::HandleLRSM(uint64_t status, std::array< EncryptedFrame, 8 >& frames, Path::HandleLRSM(uint64_t status, std::array< EncryptedFrame, 8 >& frames,
AbstractRouter* r) AbstractRouter* r)
{ {
uint64_t currentStatus = LR_StatusRecord::SUCCESS; uint64_t currentStatus = status;
size_t index = 0; size_t index = 0;
while(index < hops.size()) while(index < hops.size())
@ -143,7 +143,7 @@ namespace llarp
++index; ++index;
} }
if((currentStatus & LR_StatusRecord::SUCCESS) == 1) if(currentStatus & 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();
@ -153,7 +153,7 @@ namespace llarp
{ {
r->routerProfiling().MarkPathFail(this); r->routerProfiling().MarkPathFail(this);
llarp::LogInfo("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)
{ {
@ -197,8 +197,9 @@ namespace llarp
{ {
llarp::LogDebug("Path build failed for an unspecified reason"); llarp::LogDebug("Path build failed for an unspecified reason");
} }
auto self = shared_from_this();
EnterState(ePathFailed, r->Now()); r->logic()->queue_func(
[=]() { self->EnterState(ePathFailed, r->Now()); });
} }
// TODO: meaningful return value? // TODO: meaningful return value?
@ -211,6 +212,8 @@ namespace llarp
if(st == ePathFailed) if(st == ePathFailed)
{ {
_status = st; _status = st;
m_PathSet->HandlePathBuildFailed(shared_from_this());
return;
} }
else if(st == ePathExpired && _status == ePathBuilding) else if(st == ePathExpired && _status == ePathBuilding)
{ {

@ -442,15 +442,29 @@ namespace llarp
} }
void void
Builder::HandlePathBuildTimeout(Path_ptr p) Builder::HandlePathBuildFailed(Path_ptr p)
{
router->routerProfiling().MarkPathFail(p.get());
PathSet::HandlePathBuildFailed(p);
DoPathBuildBackoff();
}
void
Builder::DoPathBuildBackoff()
{ {
// linear backoff // linear backoff
static constexpr llarp_time_t MaxBuildInterval = 30 * 1000; static constexpr llarp_time_t MaxBuildInterval = 30 * 1000;
buildIntervalLimit = std::min( buildIntervalLimit = std::min(
MIN_PATH_BUILD_INTERVAL + buildIntervalLimit, MaxBuildInterval); MIN_PATH_BUILD_INTERVAL + buildIntervalLimit, MaxBuildInterval);
LogWarn(Name(), " build interval is now ", buildIntervalLimit);
}
void
Builder::HandlePathBuildTimeout(Path_ptr p)
{
router->routerProfiling().MarkPathFail(p.get()); router->routerProfiling().MarkPathFail(p.get());
PathSet::HandlePathBuildTimeout(p); PathSet::HandlePathBuildTimeout(p);
LogWarn(Name(), " build interval is now ", buildIntervalLimit); DoPathBuildBackoff();
} }
void void

@ -27,6 +27,9 @@ namespace llarp
UrgentBuild(llarp_time_t now) const; UrgentBuild(llarp_time_t now) const;
private: private:
void
DoPathBuildBackoff();
bool bool
DoUrgentBuildAlignedTo(const RouterID remote, DoUrgentBuildAlignedTo(const RouterID remote,
std::vector< RouterContact >& hops); std::vector< RouterContact >& hops);
@ -115,6 +118,9 @@ namespace llarp
virtual void virtual void
HandlePathBuildTimeout(Path_ptr p) override; HandlePathBuildTimeout(Path_ptr p) override;
virtual void
HandlePathBuildFailed(Path_ptr p) override;
}; };
using Builder_ptr = std::shared_ptr< Builder >; using Builder_ptr = std::shared_ptr< Builder >;

@ -291,6 +291,14 @@ namespace llarp
m_BuildStats.timeouts++; m_BuildStats.timeouts++;
} }
void
PathSet::HandlePathBuildFailed(Path_ptr p)
{
LogWarn(Name(), " path build ", p->HopsString(), " failed");
m_BuildStats.fails ++;
}
void void
PathSet::PathBuildStarted(Path_ptr p) PathSet::PathBuildStarted(Path_ptr p)
{ {

@ -128,6 +128,9 @@ namespace llarp
virtual void virtual void
HandlePathBuildTimeout(Path_ptr path); HandlePathBuildTimeout(Path_ptr path);
virtual void
HandlePathBuildFailed(Path_ptr path);
virtual void virtual void
PathBuildStarted(Path_ptr path); PathBuildStarted(Path_ptr path);

@ -32,6 +32,8 @@ namespace llarp
Session* session = static_cast< Session* >(utp_get_userdata(arg->socket)); Session* session = static_cast< Session* >(utp_get_userdata(arg->socket));
if(session && l) if(session && l)
session->OutboundLinkEstablished(l); session->OutboundLinkEstablished(l);
else
utp_close(arg->socket);
return 0; return 0;
} }
@ -59,6 +61,10 @@ namespace llarp
link->HandleTimeout(session); link->HandleTimeout(session);
session->Close(); session->Close();
} }
else
{
utp_close(arg->socket);
}
return 0; return 0;
} }
@ -319,15 +325,20 @@ namespace llarp
LinkLayer* self = LinkLayer* self =
static_cast< LinkLayer* >(utp_context_get_userdata(arg->context)); static_cast< LinkLayer* >(utp_context_get_userdata(arg->context));
Addr remote(*arg->address); Addr remote(*arg->address);
LogDebug("utp accepted from ", remote);
std::shared_ptr< ILinkSession > session = std::shared_ptr< ILinkSession > session =
std::make_shared< InboundSession >(self, arg->socket, remote); std::make_shared< InboundSession >(self, arg->socket, remote);
if(!self->PutSession(session)) if(!self->PutSession(session))
{ {
session->Close(); LogWarn("dropping inbound utp session from ", remote);
// close later
self->m_Logic->call_later(50, [=]() {
session->Close();
});
} }
else else
{ {
LogDebug("utp accepted from ", remote);
session->OnLinkEstablished(self); session->OnLinkEstablished(self);
} }
return 0; return 0;

Loading…
Cancel
Save