diff --git a/node/Multicaster.cpp b/node/Multicaster.cpp
index 16c6304a8..87162b78a 100644
--- a/node/Multicaster.cpp
+++ b/node/Multicaster.cpp
@@ -115,6 +115,7 @@ void Multicaster::send(
unsigned int limit,
uint64_t now,
uint64_t nwid,
+ const std::vector
&alwaysSendTo,
const MulticastGroup &mg,
const MAC &src,
unsigned int etherType,
@@ -124,16 +125,10 @@ void Multicaster::send(
Mutex::Lock _l(_groups_m);
MulticastGroupStatus &gs = _groups[std::pair(nwid,mg)];
- // TODO / DEPRECATED:
- // Right now we also send all multicasts to at least one supernode.
- // This supernode then relays them via the old multicast message
- // type to pre 1.0.0 peers. We'll keep doing this until there aren't
- // any of these on the network. Costs a bit of bandwidth, but maintains
- // backward compability while people upgrade. Then this code can die.
- bool gotASupernode = false;
-
if (gs.members.size() >= limit) {
- // If we already have enough members, just send and we're done -- no need for TX queue
+ // If we already have enough members, just send and we're done. We can
+ // skip the TX queue and skip the overhead of maintaining a send log by
+ // using sendOnly().
OutboundMulticast out;
out.init(
@@ -150,18 +145,18 @@ void Multicaster::send(
len);
unsigned int count = 0;
- for(std::vector::const_reverse_iterator m(gs.members.rbegin());m!=gs.members.rend();++m) {
- out.sendOnly(*(RR->sw),m->address); // sendOnly() avoids overhead of creating sent log since we're going to discard this immediately
- if (RR->topology->isSupernode(m->address))
- gotASupernode = true;
- if (++count >= limit)
+
+ for(std::vector::const_iterator ast(alwaysSendTo.begin());ast!=alwaysSendTo.end();++ast) {
+ if (count++ >= limit)
break;
+ out.sendOnly(*(RR->sw),*ast);
}
- if (!gotASupernode) {
- SharedPtr sn(RR->topology->getBestSupernode());
- if (sn)
- out.sendOnly(*(RR->sw),sn->address());
+ for(std::vector::const_reverse_iterator m(gs.members.rbegin());m!=gs.members.rend();++m) {
+ if (count++ >= limit)
+ break;
+ if (std::find(alwaysSendTo.begin(),alwaysSendTo.end(),m->address) == alwaysSendTo.end())
+ out.sendOnly(*(RR->sw),m->address);
}
} else {
unsigned int gatherLimit = (limit - (unsigned int)gs.members.size()) + 1;
@@ -169,11 +164,6 @@ void Multicaster::send(
if ((now - gs.lastExplicitGather) >= ZT_MULTICAST_EXPLICIT_GATHER_DELAY) {
gs.lastExplicitGather = now;
- // TODO / INPROGRESS: right now supernodes track multicast LIKEs, a relic
- // from the old algorithm. The next step will be to devolve this duty
- // somewhere else, such as node(s) nominated by netconf masters. But
- // we'll keep announcing LIKEs to supernodes for the near future to
- // gradually migrate from old multicast to new without losing old nodes.
SharedPtr sn(RR->topology->getBestSupernode());
if (sn) {
Packet outp(sn->address(),RR->identity.address(),Packet::VERB_MULTICAST_GATHER);
@@ -209,16 +199,12 @@ void Multicaster::send(
data,
len);
- for(std::vector::const_reverse_iterator m(gs.members.rbegin());m!=gs.members.rend();++m) {
- out.sendAndLog(*(RR->sw),m->address);
- if (RR->topology->isSupernode(m->address))
- gotASupernode = true;
- }
+ for(std::vector::const_iterator ast(alwaysSendTo.begin());ast!=alwaysSendTo.end();++ast)
+ out.sendAndLog(*(RR->sw),*ast);
- if (!gotASupernode) {
- SharedPtr sn(RR->topology->getBestSupernode());
- if (sn)
- out.sendAndLog(*(RR->sw),sn->address());
+ for(std::vector::const_reverse_iterator m(gs.members.rbegin());m!=gs.members.rend();++m) {
+ if (std::find(alwaysSendTo.begin(),alwaysSendTo.end(),m->address) == alwaysSendTo.end())
+ out.sendAndLog(*(RR->sw),m->address);
}
}
}
diff --git a/node/Multicaster.hpp b/node/Multicaster.hpp
index 6c117a10e..454f5c936 100644
--- a/node/Multicaster.hpp
+++ b/node/Multicaster.hpp
@@ -123,12 +123,13 @@ public:
/**
* Send a multicast
*
- * @param nwid Network ID
* @param com Certificate of membership to include or NULL for none
* @param limit Multicast limit
* @param now Current time
+ * @param nwid Network ID
+ * @param alwaysSendTo Send to these peers first and even if not included in subscriber list
* @param mg Multicast group
- * @param from Source Ethernet MAC address
+ * @param src Source Ethernet MAC address
* @param etherType Ethernet frame type
* @param data Packet data
* @param len Length of packet data
@@ -138,6 +139,7 @@ public:
unsigned int limit,
uint64_t now,
uint64_t nwid,
+ const std::vector &alwaysSendTo,
const MulticastGroup &mg,
const MAC &src,
unsigned int etherType,
diff --git a/node/Network.cpp b/node/Network.cpp
index 6ad6fcf81..77b2c3227 100644
--- a/node/Network.cpp
+++ b/node/Network.cpp
@@ -200,7 +200,7 @@ bool Network::applyConfiguration(const SharedPtr &conf)
try {
if ((conf->networkId() == _id)&&(conf->issuedTo() == RR->identity.address())) {
- std::set oldStaticIps;
+ std::vector oldStaticIps;
if (_config)
oldStaticIps = _config->staticIps();
@@ -216,14 +216,14 @@ bool Network::applyConfiguration(const SharedPtr &conf)
t->setFriendlyName(fname);
// Remove previously configured static IPs that are gone
- for(std::set::const_iterator oldip(oldStaticIps.begin());oldip!=oldStaticIps.end();++oldip) {
- if (!_config->staticIps().count(*oldip))
+ for(std::vector::const_iterator oldip(oldStaticIps.begin());oldip!=oldStaticIps.end();++oldip) {
+ if (std::find(_config->staticIps().begin(),_config->staticIps().end(),*oldip) == _config->staticIps().end())
t->removeIP(*oldip);
}
// Add new static IPs that were not in previous config
- for(std::set::const_iterator newip(_config->staticIps().begin());newip!=_config->staticIps().end();++newip) {
- if (!oldStaticIps.count(*newip))
+ for(std::vector::const_iterator newip(_config->staticIps().begin());newip!=_config->staticIps().end();++newip) {
+ if (std::find(oldStaticIps.begin(),oldStaticIps.end(),*newip) == oldStaticIps.end())
t->addIP(*newip);
}
@@ -494,7 +494,7 @@ void Network::threadMain()
_tap = t;
if (t) {
if (_config) {
- for(std::set::const_iterator newip(_config->staticIps().begin());newip!=_config->staticIps().end();++newip)
+ for(std::vector::const_iterator newip(_config->staticIps().begin());newip!=_config->staticIps().end();++newip)
t->addIP(*newip);
}
t->setEnabled(_enabled);
diff --git a/node/NetworkConfig.cpp b/node/NetworkConfig.cpp
index e45407a5a..f200ffc27 100644
--- a/node/NetworkConfig.cpp
+++ b/node/NetworkConfig.cpp
@@ -54,18 +54,22 @@ SharedPtr NetworkConfig::createTestNetworkConfig(const Address &s
return nc;
}
-std::set NetworkConfig::allowedEtherTypes() const
+std::vector NetworkConfig::allowedEtherTypes() const
{
- std::set ets;
- for(unsigned int i=0;i>= 1;
- ++et;
+ std::vector ets;
+ if ((_etWhitelist[0] & 1) != 0) {
+ ets.push_back(0);
+ } else {
+ for(unsigned int i=0;i>= 1;
+ ++et;
+ }
}
}
}
@@ -139,17 +143,21 @@ void NetworkConfig::_fromDictionary(const Dictionary &d)
default: // ignore unrecognized address types or junk/empty fields
continue;
}
- _staticIps.insert(addr);
+ _staticIps.push_back(addr);
}
+ std::sort(_staticIps.begin(),_staticIps.end());
+ std::unique(_staticIps.begin(),_staticIps.end());
std::vector activeBridgesSplit(Utils::split(d.get(ZT_NETWORKCONFIG_DICT_KEY_ACTIVE_BRIDGES,"").c_str(),",","",""));
for(std::vector::const_iterator a(activeBridgesSplit.begin());a!=activeBridgesSplit.end();++a) {
if (a->length() == ZT_ADDRESS_LENGTH_HEX) { // ignore empty or garbage fields
Address tmp(*a);
if (!tmp.isReserved())
- _activeBridges.insert(tmp);
+ _activeBridges.push_back(tmp);
}
}
+ std::sort(_activeBridges.begin(),_activeBridges.end());
+ std::unique(_activeBridges.begin(),_activeBridges.end());
Dictionary multicastRateEntries(d.get(ZT_NETWORKCONFIG_DICT_KEY_MULTICAST_RATES,std::string()));
for(Dictionary::const_iterator i(multicastRateEntries.begin());i!=multicastRateEntries.end();++i) {
diff --git a/node/NetworkConfig.hpp b/node/NetworkConfig.hpp
index 547018402..ea27d5253 100644
--- a/node/NetworkConfig.hpp
+++ b/node/NetworkConfig.hpp
@@ -31,9 +31,10 @@
#include
#include