summaryrefslogtreecommitdiff
path: root/node/Switch.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-04-19 12:09:35 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-04-19 12:09:35 -0700
commit2f18a92e2013729b608f8d95f80eb364e69594f6 (patch)
tree1027fd378019f57062d7c05d410cb6488f6e66ae /node/Switch.cpp
parentaffbca74b41a48e6a485d69409936d7c2bd12858 (diff)
downloadinfinitytier-2f18a92e2013729b608f8d95f80eb364e69594f6.tar.gz
infinitytier-2f18a92e2013729b608f8d95f80eb364e69594f6.zip
Cleanup in numerous places, reduce network chattiness around MULTICAST_LIKE, and fix a "how was that working" latent bug causing some control traffic to take the scenic route.
Diffstat (limited to 'node/Switch.cpp')
-rw-r--r--node/Switch.cpp49
1 files changed, 24 insertions, 25 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp
index 8df7ba04..9dbabdca 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -229,7 +229,6 @@ void Switch::onRemotePacket(const InetAddress &localAddr,const InetAddress &from
return;
}
#endif
-
relayTo = RR->topology->getBestRoot(&source,1,true);
if (relayTo)
relayTo->send(packet.data(),packet.size(),now);
@@ -681,7 +680,7 @@ unsigned long Switch::doTimerTasks(uint64_t now)
Mutex::Lock _l(_contactQueue_m);
for(std::list<ContactQueueEntry>::iterator qi(_contactQueue.begin());qi!=_contactQueue.end();) {
if (now >= qi->fireAtTime) {
- if (!qi->peer->pushDirectPaths(qi->localAddr,qi->inaddr,now,true))
+ if (!qi->peer->pushDirectPaths(qi->localAddr,qi->inaddr,now,true,false))
qi->peer->sendHELLO(qi->localAddr,qi->inaddr,now);
_contactQueue.erase(qi++);
continue;
@@ -790,38 +789,38 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid)
return false; // we probably just left this network, let its packets die
}
+ Path *viaPath = peer->getBestPath(now);
SharedPtr<Peer> relay;
- // Check for a network preferred relay
- Path *viaPath = peer->getBestPath(now);
- if ((!viaPath)&&(network)) {
- unsigned int bestq = ~((unsigned int)0); // max unsigned int since quality is lower==better
- for(unsigned int ri=0;ri<network->config().staticDeviceCount();++ri) {
- const ZT_VirtualNetworkStaticDevice &r = network->config().staticDevice(ri);
- if ((r.address != peer->address().toInt())&&((r.flags & ZT_NETWORK_STATIC_DEVICE_IS_RELAY) != 0)) {
- SharedPtr<Peer> rp(RR->topology->getPeer(Address(r.address)));
- if (rp) {
- const unsigned int q = rp->relayQuality(now);
- if (q < bestq) {
- bestq = q;
- rp.swap(relay);
+ if (!viaPath) {
+ if (network) {
+ unsigned int bestq = ~((unsigned int)0); // max unsigned int since quality is lower==better
+ for(unsigned int ri=0;ri<network->config().staticDeviceCount();++ri) {
+ const ZT_VirtualNetworkStaticDevice &r = network->config().staticDevice(ri);
+ if ((r.address != peer->address().toInt())&&((r.flags & ZT_NETWORK_STATIC_DEVICE_IS_RELAY) != 0)) {
+ SharedPtr<Peer> rp(RR->topology->getPeer(Address(r.address)));
+ if (rp) {
+ const unsigned int q = rp->relayQuality(now);
+ if (q < bestq) {
+ bestq = q;
+ rp.swap(relay);
+ }
}
}
}
}
- }
- // Otherwise relay off a root server
- if (!relay)
- relay = RR->topology->getBestRoot();
+ if (!relay)
+ relay = RR->topology->getBestRoot();
- // No relay or relay has no active paths == :P~~~~
- if ( (!(relay)) || (!(viaPath = relay->getBestPath(now))) )
- return false;
+ if ( (!relay) || (!(viaPath = relay->getBestPath(now))) )
+ return false;
+ }
+ // viaPath will not be null if we make it here
- if ((network)&&(relay)&&(network->isAllowed(peer))) {
- // Push hints for direct connectivity to this peer if we are relaying
- peer->pushDirectPaths(viaPath->localAddress(),viaPath->address(),now,false);
+ // Push possible direct paths to us if we are relaying
+ if (relay) {
+ peer->pushDirectPaths(viaPath->localAddress(),viaPath->address(),now,false,( (network)&&(network->isAllowed(peer)) ));
viaPath->sent(now);
}