Apply multicast rate limits on a network to ourselves and do not send multicasts that would exceed limits, for GitHub issue #55

This commit is contained in:
Adam Ierymenko 2014-03-25 21:38:54 -07:00
parent 67a85221d5
commit ab5a460177
2 changed files with 6 additions and 1 deletions

View File

@ -280,7 +280,7 @@ public:
/** /**
* Update multicast balance for an address and multicast group, return whether packet is allowed * Update multicast balance for an address and multicast group, return whether packet is allowed
* *
* @param a Address that wants to send/relay packet * @param a Originating address of multicast packet
* @param mg Multicast group * @param mg Multicast group
* @param bytes Size of packet * @param bytes Size of packet
* @return True if packet is within budget * @return True if packet is within budget

View File

@ -108,6 +108,11 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
mg = MulticastGroup::deriveMulticastGroupForAddressResolution(InetAddress(data.field(24,4),4,0)); mg = MulticastGroup::deriveMulticastGroupForAddressResolution(InetAddress(data.field(24,4),4,0));
} }
if (!network->updateAndCheckMulticastBalance(_r->identity.address(),mg,data.size())) {
TRACE("%s: didn't multicast %d bytes, quota exceeded for multicast group %s",network->tapDeviceName().c_str(),(int)data.size(),mg.toString().c_str());
return;
}
const unsigned int mcid = ++_multicastIdCounter & 0xffffff; const unsigned int mcid = ++_multicastIdCounter & 0xffffff;
const uint16_t bloomNonce = (uint16_t)(_r->prng->next32() & 0xffff); // doesn't need to be cryptographically strong const uint16_t bloomNonce = (uint16_t)(_r->prng->next32() & 0xffff); // doesn't need to be cryptographically strong
unsigned char bloom[ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_BLOOM]; unsigned char bloom[ZT_PROTO_VERB_MULTICAST_FRAME_LEN_PROPAGATION_BLOOM];