summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-04-18 16:44:23 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-04-18 16:44:23 -0700
commitcecfa99b7bf13b8231a5a8141e723b57a8e5e3cd (patch)
tree6dca05b59a5403ab42387969c389f921dbdd4f1e
parentb3cac538cced1f9596c24a48dff0cf4b17147e20 (diff)
downloadinfinitytier-cecfa99b7bf13b8231a5a8141e723b57a8e5e3cd.tar.gz
infinitytier-cecfa99b7bf13b8231a5a8141e723b57a8e5e3cd.zip
(1) cluster members send a flag indicating that a PUSH_DIRECT_PATHS is a cluster redirect, (2) 1.1.5 uses this to avoid a bug (this bug does not exist in 1.1.4)
-rw-r--r--node/IncomingPacket.cpp4
-rw-r--r--node/Packet.hpp18
-rw-r--r--node/Peer.cpp2
3 files changed, 16 insertions, 8 deletions
diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp
index bb97b4de..8c3aac9a 100644
--- a/node/IncomingPacket.cpp
+++ b/node/IncomingPacket.cpp
@@ -933,7 +933,7 @@ bool IncomingPacket::_doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,const Sha
switch(addrType) {
case 4: {
InetAddress a(field(ptr,4),4,at<uint16_t>(ptr + 4));
- if ( ((flags & 0x01) == 0) && (!peer->hasActivePathTo(now,a)) && (RR->node->shouldUsePathForZeroTierTraffic(_localAddress,a)) ) {
+ if ( ((flags & ZT_PUSH_DIRECT_PATHS_FLAG_FORGET_PATH) == 0) && ( ((flags & ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT) != 0) || (!peer->hasActivePathTo(now,a)) ) && (RR->node->shouldUsePathForZeroTierTraffic(_localAddress,a)) ) {
if (++countPerScope[(int)a.ipScope()][0] <= ZT_PUSH_DIRECT_PATHS_MAX_PER_SCOPE_AND_FAMILY) {
TRACE("attempting to contact %s at pushed direct path %s",peer->address().toString().c_str(),a.toString().c_str());
peer->sendHELLO(InetAddress(),a,now);
@@ -944,7 +944,7 @@ bool IncomingPacket::_doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,const Sha
} break;
case 6: {
InetAddress a(field(ptr,16),16,at<uint16_t>(ptr + 16));
- if ( ((flags & 0x01) == 0) && (!peer->hasActivePathTo(now,a)) && (RR->node->shouldUsePathForZeroTierTraffic(_localAddress,a)) ) {
+ if ( ((flags & ZT_PUSH_DIRECT_PATHS_FLAG_FORGET_PATH) == 0) && ( ((flags & ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT) != 0) || (!peer->hasActivePathTo(now,a)) ) && (RR->node->shouldUsePathForZeroTierTraffic(_localAddress,a)) ) {
if (++countPerScope[(int)a.ipScope()][1] <= ZT_PUSH_DIRECT_PATHS_MAX_PER_SCOPE_AND_FAMILY) {
TRACE("attempting to contact %s at pushed direct path %s",peer->address().toString().c_str(),a.toString().c_str());
peer->sendHELLO(InetAddress(),a,now);
diff --git a/node/Packet.hpp b/node/Packet.hpp
index 7d1e5c68..5c2e64c4 100644
--- a/node/Packet.hpp
+++ b/node/Packet.hpp
@@ -176,6 +176,16 @@
*/
#define ZT_PROTO_SALSA20_ROUNDS 12
+/**
+ * PUSH_DIRECT_PATHS flag: forget path
+ */
+#define ZT_PUSH_DIRECT_PATHS_FLAG_FORGET_PATH 0x01
+
+/**
+ * PUSH_DIRECT_PATHS flag: cluster redirect
+ */
+#define ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT 0x02
+
// Field indexes in packet header
#define ZT_PACKET_IDX_IV 0
#define ZT_PACKET_IDX_DEST 8
@@ -819,7 +829,7 @@ public:
* <[...] paths>
*
* Path record format:
- * <[1] flags>
+ * <[1] 8-bit path flags>
* <[2] length of extended path characteristics or 0 for none>
* <[...] extended path characteristics>
* <[1] address type>
@@ -827,10 +837,8 @@ public:
* <[...] address>
*
* Path record flags:
- * 0x01 - Forget this path if it is currently known
- * 0x02 - (Unused)
- * 0x04 - Disable encryption (trust: privacy)
- * 0x08 - Disable encryption and authentication (trust: ultimate)
+ * 0x01 - Forget this path if currently known (not implemented yet)
+ * 0x02 - Cluster redirect -- use this in preference to others
*
* The receiver may, upon receiving a push, attempt to establish a
* direct link to one or more of the indicated addresses. It is the
diff --git a/node/Peer.cpp b/node/Peer.cpp
index 87ca94e1..6c935e0a 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -81,7 +81,7 @@ void Peer::received(
// For newer peers we can send a more idiomatic verb: PUSH_DIRECT_PATHS.
Packet outp(_id.address(),RR->identity.address(),Packet::VERB_PUSH_DIRECT_PATHS);
outp.append((uint16_t)1); // count == 1
- outp.append((uint8_t)0); // no flags
+ outp.append((uint8_t)ZT_PUSH_DIRECT_PATHS_FLAG_CLUSTER_REDIRECT); // flags: cluster redirect
outp.append((uint16_t)0); // no extensions
if (redirectTo.ss_family == AF_INET) {
outp.append((uint8_t)4);