diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-10-04 13:15:02 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-10-04 13:15:02 -0700 |
| commit | 2c8321be1f6b0001912d336843a855dde3043adb (patch) | |
| tree | 0501ce3e76ca481cfe305a05c028850f2880d1f2 /node/Multicaster.cpp | |
| parent | 62da7e67b64712fc5cfce771ff944057abff705b (diff) | |
| download | infinitytier-2c8321be1f6b0001912d336843a855dde3043adb.tar.gz infinitytier-2c8321be1f6b0001912d336843a855dde3043adb.zip | |
Pull logic to always send new multicasts to supernode since we need to do that differently, re-add support for active bridges, and remove some gratuitous use of std::set where not needed.
Diffstat (limited to 'node/Multicaster.cpp')
| -rw-r--r-- | node/Multicaster.cpp | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/node/Multicaster.cpp b/node/Multicaster.cpp index 16c6304a..87162b78 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<Address> &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<uint64_t,MulticastGroup>(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<MulticastGroupMember>::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<Address>::const_iterator ast(alwaysSendTo.begin());ast!=alwaysSendTo.end();++ast) { + if (count++ >= limit) break; + out.sendOnly(*(RR->sw),*ast); } - if (!gotASupernode) { - SharedPtr<Peer> sn(RR->topology->getBestSupernode()); - if (sn) - out.sendOnly(*(RR->sw),sn->address()); + for(std::vector<MulticastGroupMember>::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<Peer> 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<MulticastGroupMember>::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<Address>::const_iterator ast(alwaysSendTo.begin());ast!=alwaysSendTo.end();++ast) + out.sendAndLog(*(RR->sw),*ast); - if (!gotASupernode) { - SharedPtr<Peer> sn(RR->topology->getBestSupernode()); - if (sn) - out.sendAndLog(*(RR->sw),sn->address()); + for(std::vector<MulticastGroupMember>::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); } } } |
