summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--node/NetworkConfig.cpp62
-rw-r--r--node/NetworkConfig.hpp102
-rw-r--r--node/Node.cpp22
-rw-r--r--node/Switch.cpp24
-rw-r--r--node/Topology.cpp10
5 files changed, 4 insertions, 216 deletions
diff --git a/node/NetworkConfig.cpp b/node/NetworkConfig.cpp
index 7a7abdd6..a8ab4dac 100644
--- a/node/NetworkConfig.cpp
+++ b/node/NetworkConfig.cpp
@@ -108,24 +108,6 @@ bool NetworkConfig::toDictionary(Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d,b
if (ab.length() > 0) {
if (!d.add(ZT_NETWORKCONFIG_DICT_KEY_ACTIVE_BRIDGES_OLD,ab.c_str())) return false;
}
-
- std::vector<Relay> rvec(this->relays());
- std::string rl;
- for(std::vector<Relay>::const_iterator i(rvec.begin());i!=rvec.end();++i) {
- if (rl.length() > 0)
- rl.push_back(',');
- rl.append(i->address.toString());
- if (i->phy4) {
- rl.push_back(';');
- rl.append(i->phy4.toString());
- } else if (i->phy6) {
- rl.push_back(';');
- rl.append(i->phy6.toString());
- }
- }
- if (rl.length() > 0) {
- if (!d.add(ZT_NETWORKCONFIG_DICT_KEY_RELAYS_OLD,rl.c_str())) return false;
- }
}
#endif // ZT_SUPPORT_OLD_STYLE_NETCONF
@@ -165,15 +147,6 @@ bool NetworkConfig::toDictionary(Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d,b
}
tmp.clear();
- for(unsigned int i=0;i<this->pinnedCount;++i) {
- this->pinned[i].zt.appendTo(tmp);
- this->pinned[i].phy.serialize(tmp);
- }
- if (tmp.size()) {
- if (!d.add(ZT_NETWORKCONFIG_DICT_KEY_PINNED,tmp)) return false;
- }
-
- tmp.clear();
for(unsigned int i=0;i<this->ruleCount;++i) {
tmp.append((uint8_t)rules[i].t);
switch((ZT_VirtualNetworkRuleType)(rules[i].t & 0x7f)) {
@@ -331,32 +304,6 @@ bool NetworkConfig::fromDictionary(const Dictionary<ZT_NETWORKCONFIG_DICT_CAPACI
this->addSpecialist(Address(f),ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE);
}
}
-
- if (d.get(ZT_NETWORKCONFIG_DICT_KEY_RELAYS_OLD,tmp2,sizeof(tmp2)) > 0) {
- char *saveptr = (char *)0;
- for(char *f=Utils::stok(tmp2,",",&saveptr);(f);f=Utils::stok((char *)0,",",&saveptr)) {
- char tmp3[256];
- Utils::scopy(tmp3,sizeof(tmp3),f);
-
- InetAddress phy;
- char *semi = tmp3;
- while (*semi) {
- if (*semi == ';') {
- *semi = (char)0;
- ++semi;
- phy = InetAddress(semi);
- } else ++semi;
- }
- Address zt(tmp3);
-
- this->addSpecialist(zt,ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_PREFERRED_RELAY);
- if ((phy)&&(this->pinnedCount < ZT_MAX_NETWORK_PINNED)) {
- this->pinned[this->pinnedCount].zt = zt;
- this->pinned[this->pinnedCount].phy = phy;
- ++this->pinnedCount;
- }
- }
- }
#else
return false;
#endif // ZT_SUPPORT_OLD_STYLE_NETCONF
@@ -395,15 +342,6 @@ bool NetworkConfig::fromDictionary(const Dictionary<ZT_NETWORKCONFIG_DICT_CAPACI
}
}
- if (d.get(ZT_NETWORKCONFIG_DICT_KEY_PINNED,tmp)) {
- unsigned int p = 0;
- while ((p < tmp.size())&&(pinnedCount < ZT_MAX_NETWORK_PINNED)) {
- this->pinned[this->pinnedCount].zt.setTo(tmp.field(p,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH); p += ZT_ADDRESS_LENGTH;
- p += this->pinned[this->pinnedCount].phy.deserialize(tmp,p);
- ++this->pinnedCount;
- }
- }
-
if (d.get(ZT_NETWORKCONFIG_DICT_KEY_RULES,tmp)) {
unsigned int p = 0;
while ((p < tmp.size())&&(ruleCount < ZT_MAX_NETWORK_RULES)) {
diff --git a/node/NetworkConfig.hpp b/node/NetworkConfig.hpp
index f2dab6d3..af7ce93b 100644
--- a/node/NetworkConfig.hpp
+++ b/node/NetworkConfig.hpp
@@ -53,11 +53,6 @@
#define ZT_NETWORKCONFIG_FLAG_ENABLE_IPV6_NDP_EMULATION 0x0000000000000004ULL
/**
- * Device is a network preferred relay
- */
-#define ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_PREFERRED_RELAY 0x0000010000000000ULL
-
-/**
* Device is an active bridge
*/
#define ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE 0x0000020000000000ULL
@@ -110,8 +105,6 @@ namespace ZeroTier {
#define ZT_NETWORKCONFIG_DICT_KEY_ROUTES "RT"
// static IPs (binary blob)
#define ZT_NETWORKCONFIG_DICT_KEY_STATIC_IPS "I"
-// pinned address physical route mappings (binary blob)
-#define ZT_NETWORKCONFIG_DICT_KEY_PINNED "P"
// rules (binary blob)
#define ZT_NETWORKCONFIG_DICT_KEY_RULES "R"
@@ -148,17 +141,6 @@ class NetworkConfig
{
public:
/**
- * Network preferred relay with optional physical endpoint addresses
- *
- * This is used by the convenience relays() method.
- */
- struct Relay
- {
- Address address;
- InetAddress phy4,phy6;
- };
-
- /**
* Create an instance of a NetworkConfig for the test network ID
*
* The test network ID is defined as ZT_TEST_NETWORK_ID. This is a
@@ -284,43 +266,6 @@ public:
}
/**
- * Get pinned physical address for a given ZeroTier address, if any
- *
- * @param zt ZeroTier address
- * @param af Address family (e.g. AF_INET) or 0 for the first we find of any type
- * @return Physical address, if any
- */
- inline InetAddress findPinnedAddress(const Address &zt,unsigned int af) const
- {
- for(unsigned int i=0;i<pinnedCount;++i) {
- if (pinned[i].zt == zt) {
- if ((af == 0)||((unsigned int)pinned[i].phy.ss_family == af))
- return pinned[i].phy;
- }
- }
- return InetAddress();
- }
-
- /**
- * This gets network preferred relays with their static physical address if one is defined
- *
- * @return Network-preferred relays for this network (if none, only roots will be used)
- */
- inline std::vector<Relay> relays() const
- {
- std::vector<Relay> r;
- for(unsigned int i=0;i<specialistCount;++i) {
- if ((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_PREFERRED_RELAY) != 0) {
- r.push_back(Relay());
- r.back().address = specialists[i];
- r.back().phy4 = findPinnedAddress(r.back().address,AF_INET);
- r.back().phy6 = findPinnedAddress(r.back().address,AF_INET6);
- }
- }
- return r;
- }
-
- /**
* @param fromPeer Peer attempting to bridge other Ethernet peers onto network
* @return True if this network allows bridging
*/
@@ -336,37 +281,6 @@ public:
}
/**
- * Iterate through relays efficiently
- *
- * @param ptr Value-result parameter -- start by initializing with zero, then call until return is null
- * @return Address of relay or NULL if no more
- */
- Address nextRelay(unsigned int &ptr) const
- {
- while (ptr < specialistCount) {
- if ((specialists[ptr] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_PREFERRED_RELAY) != 0) {
- return Address(specialists[ptr++]);
- } else {
- ++ptr;
- }
- }
- return Address();
- }
-
- /**
- * @param zt ZeroTier address
- * @return True if this address is a relay
- */
- bool isRelay(const Address &zt) const
- {
- for(unsigned int i=0;i<specialistCount;++i) {
- if ((zt == specialists[i])&&((specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_NETWORK_PREFERRED_RELAY) != 0))
- return true;
- }
- return false;
- }
-
- /**
* @return True if this network config is non-NULL
*/
inline operator bool() const throw() { return (networkId != 0); }
@@ -396,11 +310,6 @@ public:
printf("staticIpCount==%u\n",staticIpCount);
for(unsigned int i=0;i<staticIpCount;++i)
printf(" staticIps[i]==%s\n",staticIps[i].toString().c_str());
- printf("pinnedCount==%u\n",pinnedCount);
- for(unsigned int i=0;i<pinnedCount;++i) {
- printf(" pinned[i].zt==%s\n",pinned[i].zt.toString().c_str());
- printf(" pinned[i].phy==%s\n",pinned[i].phy.toString().c_str());
- }
printf("ruleCount==%u\n",ruleCount);
printf("name==%s\n",name);
printf("com==%s\n",com.toString().c_str());
@@ -507,17 +416,6 @@ public:
InetAddress staticIps[ZT_MAX_ZT_ASSIGNED_ADDRESSES];
/**
- * Pinned devices with physical address hints
- *
- * These can be used to specify a physical address where a given device
- * can be reached. It's usually used with network relays (specialists).
- */
- struct {
- Address zt;
- InetAddress phy;
- } pinned[ZT_MAX_NETWORK_PINNED];
-
- /**
* Rules table
*/
ZT_VirtualNetworkRule rules[ZT_MAX_NETWORK_RULES];
diff --git a/node/Node.cpp b/node/Node.cpp
index 13085028..e5d04e31 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -173,11 +173,10 @@ ZT_ResultCode Node::processVirtualNetworkFrame(
class _PingPeersThatNeedPing
{
public:
- _PingPeersThatNeedPing(const RuntimeEnvironment *renv,uint64_t now,const std::vector<NetworkConfig::Relay> &relays) :
+ _PingPeersThatNeedPing(const RuntimeEnvironment *renv,uint64_t now) :
lastReceiveFromUpstream(0),
RR(renv),
_now(now),
- _relays(relays),
_world(RR->topology->world())
{
}
@@ -214,17 +213,6 @@ public:
// flapping in Cluster mode.
if (RR->topology->amRoot())
return;
-
- // Check for network preferred relays, also considered 'upstream' and thus always
- // pinged to keep links up. If they have stable addresses we will try them there.
- for(std::vector<NetworkConfig::Relay>::const_iterator r(_relays.begin());r!=_relays.end();++r) {
- if (r->address == p->address()) {
- stableEndpoint4 = r->phy4;
- stableEndpoint6 = r->phy6;
- upstream = true;
- break;
- }
- }
}
if (upstream) {
@@ -267,7 +255,6 @@ public:
private:
const RuntimeEnvironment *RR;
uint64_t _now;
- const std::vector<NetworkConfig::Relay> &_relays;
World _world;
};
@@ -283,7 +270,6 @@ ZT_ResultCode Node::processBackgroundTasks(uint64_t now,volatile uint64_t *nextB
_lastPingCheck = now;
// Get relays and networks that need config without leaving the mutex locked
- std::vector< NetworkConfig::Relay > networkRelays;
std::vector< SharedPtr<Network> > needConfig;
{
Mutex::Lock _l(_networks_m);
@@ -291,10 +277,6 @@ ZT_ResultCode Node::processBackgroundTasks(uint64_t now,volatile uint64_t *nextB
if (((now - n->second->lastConfigUpdate()) >= ZT_NETWORK_AUTOCONF_DELAY)||(!n->second->hasConfig())) {
needConfig.push_back(n->second);
}
- if (n->second->hasConfig()) {
- std::vector<NetworkConfig::Relay> r(n->second->config().relays());
- networkRelays.insert(networkRelays.end(),r.begin(),r.end());
- }
}
}
@@ -303,7 +285,7 @@ ZT_ResultCode Node::processBackgroundTasks(uint64_t now,volatile uint64_t *nextB
(*n)->requestConfiguration();
// Do pings and keepalives
- _PingPeersThatNeedPing pfunc(RR,now,networkRelays);
+ _PingPeersThatNeedPing pfunc(RR,now);
RR->topology->eachPeer<_PingPeersThatNeedPing &>(pfunc);
// Update online status, post status change as event
diff --git a/node/Switch.cpp b/node/Switch.cpp
index f644774f..41756aa9 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -844,33 +844,11 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid)
SharedPtr<Peer> relay;
if (!viaPath) {
- if (network) {
- unsigned int bestq = ~((unsigned int)0); // max unsigned int since quality is lower==better
- unsigned int ptr = 0;
- for(;;) {
- const Address raddr(network->config().nextRelay(ptr));
- if (raddr) {
- SharedPtr<Peer> rp(RR->topology->getPeer(raddr));
- if (rp) {
- const unsigned int q = rp->relayQuality(now);
- if (q < bestq) {
- bestq = q;
- rp.swap(relay);
- }
- }
- } else break;
- }
- }
-
- if (!relay)
- relay = RR->topology->getBestRoot();
-
+ relay = RR->topology->getBestRoot();
if ( (!relay) || (!(viaPath = relay->getBestPath(now))) )
return false;
}
- // viaPath will not be null if we make it here
- // 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);
diff --git a/node/Topology.cpp b/node/Topology.cpp
index 6e96f2eb..9b434732 100644
--- a/node/Topology.cpp
+++ b/node/Topology.cpp
@@ -281,15 +281,7 @@ SharedPtr<Peer> Topology::getBestRoot(const Address *avoid,unsigned int avoidCou
bool Topology::isUpstream(const Identity &id) const
{
- if (isRoot(id))
- return true;
- std::vector< SharedPtr<Network> > nws(RR->node->allNetworks());
- for(std::vector< SharedPtr<Network> >::const_iterator nw(nws.begin());nw!=nws.end();++nw) {
- if ((*nw)->config().isRelay(id.address())) {
- return true;
- }
- }
- return false;
+ return isRoot(id);
}
bool Topology::worldUpdateIfValid(const World &newWorld)