Cleanup, and implement compression disable flag for networks.

This commit is contained in:
Adam Ierymenko 2016-09-27 12:22:25 -07:00
parent 15c07c58b6
commit cc4bacc199
9 changed files with 32 additions and 10 deletions

View File

@ -425,12 +425,12 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *RR,const SharedPtr<Peer> &p
RR->sa->iam(peer->address(),_path->localAddress(),_path->address(),externalSurfaceAddress,RR->topology->isUpstream(peer->identity()),RR->node->now()); RR->sa->iam(peer->address(),_path->localAddress(),_path->address(),externalSurfaceAddress,RR->topology->isUpstream(peer->identity()),RR->node->now());
} break; } break;
case Packet::VERB_WHOIS: { case Packet::VERB_WHOIS:
if (RR->topology->isUpstream(peer->identity())) { if (RR->topology->isUpstream(peer->identity())) {
const Identity id(*this,ZT_PROTO_VERB_WHOIS__OK__IDX_IDENTITY); const Identity id(*this,ZT_PROTO_VERB_WHOIS__OK__IDX_IDENTITY);
RR->sw->doAnythingWaitingForPeer(RR->topology->addPeer(SharedPtr<Peer>(new Peer(RR,RR->identity,id)))); RR->sw->doAnythingWaitingForPeer(RR->topology->addPeer(SharedPtr<Peer>(new Peer(RR,RR->identity,id))));
} }
} break; break;
case Packet::VERB_NETWORK_CONFIG_REQUEST: { case Packet::VERB_NETWORK_CONFIG_REQUEST: {
const SharedPtr<Network> network(RR->node->network(at<uint64_t>(ZT_PROTO_VERB_OK_IDX_PAYLOAD))); const SharedPtr<Network> network(RR->node->network(at<uint64_t>(ZT_PROTO_VERB_OK_IDX_PAYLOAD)));
@ -438,9 +438,6 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *RR,const SharedPtr<Peer> &p
network->handleConfigChunk(*this,ZT_PROTO_VERB_OK_IDX_PAYLOAD); network->handleConfigChunk(*this,ZT_PROTO_VERB_OK_IDX_PAYLOAD);
} break; } break;
//case Packet::VERB_ECHO: {
//} break;
case Packet::VERB_MULTICAST_GATHER: { case Packet::VERB_MULTICAST_GATHER: {
const uint64_t nwid = at<uint64_t>(ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_NETWORK_ID); const uint64_t nwid = at<uint64_t>(ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_NETWORK_ID);
const SharedPtr<Network> network(RR->node->network(nwid)); const SharedPtr<Network> network(RR->node->network(nwid));

View File

@ -155,6 +155,7 @@ void Multicaster::send(
unsigned int limit, unsigned int limit,
uint64_t now, uint64_t now,
uint64_t nwid, uint64_t nwid,
bool disableCompression,
const std::vector<Address> &alwaysSendTo, const std::vector<Address> &alwaysSendTo,
const MulticastGroup &mg, const MulticastGroup &mg,
const MAC &src, const MAC &src,
@ -193,6 +194,7 @@ void Multicaster::send(
RR, RR,
now, now,
nwid, nwid,
disableCompression,
limit, limit,
1, // we'll still gather a little from peers to keep multicast list fresh 1, // we'll still gather a little from peers to keep multicast list fresh
src, src,
@ -265,6 +267,7 @@ void Multicaster::send(
RR, RR,
now, now,
nwid, nwid,
disableCompression,
limit, limit,
gatherLimit, gatherLimit,
src, src,

View File

@ -153,6 +153,7 @@ public:
* @param limit Multicast limit * @param limit Multicast limit
* @param now Current time * @param now Current time
* @param nwid Network ID * @param nwid Network ID
* @param disableCompression Disable packet payload compression?
* @param alwaysSendTo Send to these peers first and even if not included in subscriber list * @param alwaysSendTo Send to these peers first and even if not included in subscriber list
* @param mg Multicast group * @param mg Multicast group
* @param src Source Ethernet MAC address or NULL to skip in packet and compute from ZT address (non-bridged mode) * @param src Source Ethernet MAC address or NULL to skip in packet and compute from ZT address (non-bridged mode)
@ -164,6 +165,7 @@ public:
unsigned int limit, unsigned int limit,
uint64_t now, uint64_t now,
uint64_t nwid, uint64_t nwid,
bool disableCompression,
const std::vector<Address> &alwaysSendTo, const std::vector<Address> &alwaysSendTo,
const MulticastGroup &mg, const MulticastGroup &mg,
const MAC &src, const MAC &src,

View File

@ -962,7 +962,6 @@ uint64_t Network::handleConfigChunk(const Packet &chunk,unsigned int ptr)
if (totalLength >= ZT_NETWORKCONFIG_DICT_CAPACITY) if (totalLength >= ZT_NETWORKCONFIG_DICT_CAPACITY)
return 0; return 0;
// Find oldest slot for this udpate to use buffer space
for(int i=0;i<ZT_NETWORK_MAX_INCOMING_UPDATES;++i) { for(int i=0;i<ZT_NETWORK_MAX_INCOMING_UPDATES;++i) {
if ((!c)||(_incomingConfigChunks[i].ts < c->ts)) if ((!c)||(_incomingConfigChunks[i].ts < c->ts))
c = &(_incomingConfigChunks[i]); c = &(_incomingConfigChunks[i]);

View File

@ -76,6 +76,11 @@
*/ */
#define ZT_NETWORKCONFIG_FLAG_RULES_RESULT_OF_UNSUPPORTED_MATCH 0x0000000000000008ULL #define ZT_NETWORKCONFIG_FLAG_RULES_RESULT_OF_UNSUPPORTED_MATCH 0x0000000000000008ULL
/**
* Flag: disable frame compression
*/
#define ZT_NETWORKCONFIG_FLAG_DISABLE_COMPRESSION 0x0000000000000010ULL
/** /**
* Device is an active bridge * Device is an active bridge
*/ */
@ -255,6 +260,11 @@ public:
*/ */
inline bool ndpEmulation() const throw() { return ((this->flags & ZT_NETWORKCONFIG_FLAG_ENABLE_IPV6_NDP_EMULATION) != 0); } inline bool ndpEmulation() const throw() { return ((this->flags & ZT_NETWORKCONFIG_FLAG_ENABLE_IPV6_NDP_EMULATION) != 0); }
/**
* @return True if frames should not be compressed
*/
inline bool disableCompression() const throw() { return ((this->flags & ZT_NETWORKCONFIG_FLAG_DISABLE_COMPRESSION) != 0); }
/** /**
* @return Network type is public (no access control) * @return Network type is public (no access control)
*/ */

View File

@ -31,6 +31,7 @@ void OutboundMulticast::init(
const RuntimeEnvironment *RR, const RuntimeEnvironment *RR,
uint64_t timestamp, uint64_t timestamp,
uint64_t nwid, uint64_t nwid,
bool disableCompression,
unsigned int limit, unsigned int limit,
unsigned int gatherLimit, unsigned int gatherLimit,
const MAC &src, const MAC &src,
@ -78,7 +79,8 @@ void OutboundMulticast::init(
_packet.append((uint32_t)dest.adi()); _packet.append((uint32_t)dest.adi());
_packet.append((uint16_t)etherType); _packet.append((uint16_t)etherType);
_packet.append(payload,_frameLen); _packet.append(payload,_frameLen);
_packet.compress(); if (!disableCompression)
_packet.compress();
memcpy(_frameData,payload,_frameLen); memcpy(_frameData,payload,_frameLen);
} }

View File

@ -56,6 +56,7 @@ public:
* @param RR Runtime environment * @param RR Runtime environment
* @param timestamp Creation time * @param timestamp Creation time
* @param nwid Network ID * @param nwid Network ID
* @param disableCompression Disable compression of frame payload
* @param limit Multicast limit for desired number of packets to send * @param limit Multicast limit for desired number of packets to send
* @param gatherLimit Number to lazily/implicitly gather with this frame or 0 for none * @param gatherLimit Number to lazily/implicitly gather with this frame or 0 for none
* @param src Source MAC address of frame or NULL to imply compute from sender ZT address * @param src Source MAC address of frame or NULL to imply compute from sender ZT address
@ -69,6 +70,7 @@ public:
const RuntimeEnvironment *RR, const RuntimeEnvironment *RR,
uint64_t timestamp, uint64_t timestamp,
uint64_t nwid, uint64_t nwid,
bool disableCompression,
unsigned int limit, unsigned int limit,
unsigned int gatherLimit, unsigned int gatherLimit,
const MAC &src, const MAC &src,

View File

@ -799,6 +799,9 @@ public:
* carries the same payload as OK(NETWORK_CONFIG_REQUEST) and has the same * carries the same payload as OK(NETWORK_CONFIG_REQUEST) and has the same
* semantics. * semantics.
* *
* The legacy mode missing the additional chunking fields is not supported
* here.
*
* Flags: * Flags:
* 0x01 - Use fast propagation * 0x01 - Use fast propagation
* *

View File

@ -476,6 +476,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
network->config().multicastLimit, network->config().multicastLimit,
RR->node->now(), RR->node->now(),
network->id(), network->id(),
network->config().disableCompression(),
network->config().activeBridges(), network->config().activeBridges(),
multicastGroup, multicastGroup,
(fromBridged) ? from : MAC(), (fromBridged) ? from : MAC(),
@ -501,14 +502,16 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
from.appendTo(outp); from.appendTo(outp);
outp.append((uint16_t)etherType); outp.append((uint16_t)etherType);
outp.append(data,len); outp.append(data,len);
outp.compress(); if (!network->config().disableCompression())
outp.compress();
send(outp,true); send(outp,true);
} else { } else {
Packet outp(toZT,RR->identity.address(),Packet::VERB_FRAME); Packet outp(toZT,RR->identity.address(),Packet::VERB_FRAME);
outp.append(network->id()); outp.append(network->id());
outp.append((uint16_t)etherType); outp.append((uint16_t)etherType);
outp.append(data,len); outp.append(data,len);
outp.compress(); if (!network->config().disableCompression())
outp.compress();
send(outp,true); send(outp,true);
} }
@ -565,7 +568,8 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
from.appendTo(outp); from.appendTo(outp);
outp.append((uint16_t)etherType); outp.append((uint16_t)etherType);
outp.append(data,len); outp.append(data,len);
outp.compress(); if (!network->config().disableCompression())
outp.compress();
send(outp,true); send(outp,true);
} else { } else {
TRACE("%.16llx: %s -> %s %s packet not sent: filterOutgoingPacket() returned false",network->id(),from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType)); TRACE("%.16llx: %s -> %s %s packet not sent: filterOutgoingPacket() returned false",network->id(),from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType));