summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-09-27 12:22:25 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-09-27 12:22:25 -0700
commitcc4bacc1995d5af6b8ab66973a6d22a229367eb4 (patch)
treecb34960de2163c61ce17cc03f826d2d6f00e8fc7 /node
parent15c07c58b610f699fd2a7164fde96712e1595f2b (diff)
downloadinfinitytier-cc4bacc1995d5af6b8ab66973a6d22a229367eb4.tar.gz
infinitytier-cc4bacc1995d5af6b8ab66973a6d22a229367eb4.zip
Cleanup, and implement compression disable flag for networks.
Diffstat (limited to 'node')
-rw-r--r--node/IncomingPacket.cpp7
-rw-r--r--node/Multicaster.cpp3
-rw-r--r--node/Multicaster.hpp2
-rw-r--r--node/Network.cpp1
-rw-r--r--node/NetworkConfig.hpp10
-rw-r--r--node/OutboundMulticast.cpp4
-rw-r--r--node/OutboundMulticast.hpp2
-rw-r--r--node/Packet.hpp3
-rw-r--r--node/Switch.cpp10
9 files changed, 32 insertions, 10 deletions
diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp
index 3988546e..0a3d58af 100644
--- a/node/IncomingPacket.cpp
+++ b/node/IncomingPacket.cpp
@@ -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());
} break;
- case Packet::VERB_WHOIS: {
+ case Packet::VERB_WHOIS:
if (RR->topology->isUpstream(peer->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))));
}
- } break;
+ break;
case Packet::VERB_NETWORK_CONFIG_REQUEST: {
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);
} break;
- //case Packet::VERB_ECHO: {
- //} break;
-
case Packet::VERB_MULTICAST_GATHER: {
const uint64_t nwid = at<uint64_t>(ZT_PROTO_VERB_MULTICAST_GATHER__OK__IDX_NETWORK_ID);
const SharedPtr<Network> network(RR->node->network(nwid));
diff --git a/node/Multicaster.cpp b/node/Multicaster.cpp
index fc8fa1bd..8743e8f8 100644
--- a/node/Multicaster.cpp
+++ b/node/Multicaster.cpp
@@ -155,6 +155,7 @@ void Multicaster::send(
unsigned int limit,
uint64_t now,
uint64_t nwid,
+ bool disableCompression,
const std::vector<Address> &alwaysSendTo,
const MulticastGroup &mg,
const MAC &src,
@@ -193,6 +194,7 @@ void Multicaster::send(
RR,
now,
nwid,
+ disableCompression,
limit,
1, // we'll still gather a little from peers to keep multicast list fresh
src,
@@ -265,6 +267,7 @@ void Multicaster::send(
RR,
now,
nwid,
+ disableCompression,
limit,
gatherLimit,
src,
diff --git a/node/Multicaster.hpp b/node/Multicaster.hpp
index 8be3b736..5c94cd3a 100644
--- a/node/Multicaster.hpp
+++ b/node/Multicaster.hpp
@@ -153,6 +153,7 @@ public:
* @param limit Multicast limit
* @param now Current time
* @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 mg Multicast group
* @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,
uint64_t now,
uint64_t nwid,
+ bool disableCompression,
const std::vector<Address> &alwaysSendTo,
const MulticastGroup &mg,
const MAC &src,
diff --git a/node/Network.cpp b/node/Network.cpp
index e24e3e16..601395d0 100644
--- a/node/Network.cpp
+++ b/node/Network.cpp
@@ -962,7 +962,6 @@ uint64_t Network::handleConfigChunk(const Packet &chunk,unsigned int ptr)
if (totalLength >= ZT_NETWORKCONFIG_DICT_CAPACITY)
return 0;
- // Find oldest slot for this udpate to use buffer space
for(int i=0;i<ZT_NETWORK_MAX_INCOMING_UPDATES;++i) {
if ((!c)||(_incomingConfigChunks[i].ts < c->ts))
c = &(_incomingConfigChunks[i]);
diff --git a/node/NetworkConfig.hpp b/node/NetworkConfig.hpp
index 5ad86855..a548e866 100644
--- a/node/NetworkConfig.hpp
+++ b/node/NetworkConfig.hpp
@@ -77,6 +77,11 @@
#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
*/
#define ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE 0x0000020000000000ULL
@@ -256,6 +261,11 @@ public:
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)
*/
inline bool isPublic() const throw() { return (this->type == ZT_NETWORK_TYPE_PUBLIC); }
diff --git a/node/OutboundMulticast.cpp b/node/OutboundMulticast.cpp
index 6e811581..2f6bf986 100644
--- a/node/OutboundMulticast.cpp
+++ b/node/OutboundMulticast.cpp
@@ -31,6 +31,7 @@ void OutboundMulticast::init(
const RuntimeEnvironment *RR,
uint64_t timestamp,
uint64_t nwid,
+ bool disableCompression,
unsigned int limit,
unsigned int gatherLimit,
const MAC &src,
@@ -78,7 +79,8 @@ void OutboundMulticast::init(
_packet.append((uint32_t)dest.adi());
_packet.append((uint16_t)etherType);
_packet.append(payload,_frameLen);
- _packet.compress();
+ if (!disableCompression)
+ _packet.compress();
memcpy(_frameData,payload,_frameLen);
}
diff --git a/node/OutboundMulticast.hpp b/node/OutboundMulticast.hpp
index 0ded8baf..6370d0d7 100644
--- a/node/OutboundMulticast.hpp
+++ b/node/OutboundMulticast.hpp
@@ -56,6 +56,7 @@ public:
* @param RR Runtime environment
* @param timestamp Creation time
* @param nwid Network ID
+ * @param disableCompression Disable compression of frame payload
* @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 src Source MAC address of frame or NULL to imply compute from sender ZT address
@@ -69,6 +70,7 @@ public:
const RuntimeEnvironment *RR,
uint64_t timestamp,
uint64_t nwid,
+ bool disableCompression,
unsigned int limit,
unsigned int gatherLimit,
const MAC &src,
diff --git a/node/Packet.hpp b/node/Packet.hpp
index 23597f68..cc3d323b 100644
--- a/node/Packet.hpp
+++ b/node/Packet.hpp
@@ -799,6 +799,9 @@ public:
* carries the same payload as OK(NETWORK_CONFIG_REQUEST) and has the same
* semantics.
*
+ * The legacy mode missing the additional chunking fields is not supported
+ * here.
+ *
* Flags:
* 0x01 - Use fast propagation
*
diff --git a/node/Switch.cpp b/node/Switch.cpp
index e3d57835..6611d6b6 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -476,6 +476,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
network->config().multicastLimit,
RR->node->now(),
network->id(),
+ network->config().disableCompression(),
network->config().activeBridges(),
multicastGroup,
(fromBridged) ? from : MAC(),
@@ -501,14 +502,16 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
from.appendTo(outp);
outp.append((uint16_t)etherType);
outp.append(data,len);
- outp.compress();
+ if (!network->config().disableCompression())
+ outp.compress();
send(outp,true);
} else {
Packet outp(toZT,RR->identity.address(),Packet::VERB_FRAME);
outp.append(network->id());
outp.append((uint16_t)etherType);
outp.append(data,len);
- outp.compress();
+ if (!network->config().disableCompression())
+ outp.compress();
send(outp,true);
}
@@ -565,7 +568,8 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
from.appendTo(outp);
outp.append((uint16_t)etherType);
outp.append(data,len);
- outp.compress();
+ if (!network->config().disableCompression())
+ outp.compress();
send(outp,true);
} else {
TRACE("%.16llx: %s -> %s %s packet not sent: filterOutgoingPacket() returned false",network->id(),from.toString().c_str(),to.toString().c_str(),etherTypeName(etherType));