summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-08-26 15:28:31 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-08-26 15:28:31 -0700
commite7dff1c785575372d84ad1923b6605bc8a3b7223 (patch)
treecdb6c782b172d6843d05e972e18a4796b6b07a16 /node
parenta5383d83d8ab8ce23cb1d12f8add0a3529c85506 (diff)
downloadinfinitytier-e7dff1c785575372d84ad1923b6605bc8a3b7223.tar.gz
infinitytier-e7dff1c785575372d84ad1923b6605bc8a3b7223.zip
Change logic a little for self-as-destination in TEE and REDIRECT.
Diffstat (limited to 'node')
-rw-r--r--node/Network.cpp40
1 files changed, 25 insertions, 15 deletions
diff --git a/node/Network.cpp b/node/Network.cpp
index 4081d4e9..24b1917c 100644
--- a/node/Network.cpp
+++ b/node/Network.cpp
@@ -166,25 +166,35 @@ static int _doZtFilter(
case ZT_NETWORK_RULE_ACTION_TEE:
case ZT_NETWORK_RULE_ACTION_REDIRECT: {
const Address fwdAddr(rules[rn].v.fwd.address);
- if ((!noRedirect)&&(fwdAddr != RR->identity.address())) {
- Packet outp(fwdAddr,RR->identity.address(),Packet::VERB_EXT_FRAME);
- outp.append(nconf.networkId);
- outp.append((uint8_t)( ((rt == ZT_NETWORK_RULE_ACTION_REDIRECT) ? 0x04 : 0x02) | (inbound ? 0x08 : 0x00) ));
- macDest.appendTo(outp);
- macSource.appendTo(outp);
- outp.append((uint16_t)etherType);
- outp.append(frameData,(rules[rn].v.fwd.length != 0) ? ((frameLen < (unsigned int)rules[rn].v.fwd.length) ? frameLen : (unsigned int)rules[rn].v.fwd.length) : frameLen);
- outp.compress();
- RR->sw->send(outp,true);
- }
-
- if (rt == ZT_NETWORK_RULE_ACTION_REDIRECT) {
- return -1; // match, drop packet (we redirected it)
- } else {
+ if (fwdAddr == RR->identity.address()) {
+ // If we are the TEE or REDIRECT destination, don't TEE or REDIRECT
+ // to self. We should also accept here instead of interpreting
+ // REDIRECT as DROP since we are the destination.
#ifdef ZT_RULES_ENGINE_DEBUGGING
dlog.clear();
#endif // ZT_RULES_ENGINE_DEBUGGING
thisSetMatches = 1; // TEE does not terminate evaluation
+ } else {
+ if (!noRedirect) {
+ Packet outp(fwdAddr,RR->identity.address(),Packet::VERB_EXT_FRAME);
+ outp.append(nconf.networkId);
+ outp.append((uint8_t)( ((rt == ZT_NETWORK_RULE_ACTION_REDIRECT) ? 0x04 : 0x02) | (inbound ? 0x08 : 0x00) ));
+ macDest.appendTo(outp);
+ macSource.appendTo(outp);
+ outp.append((uint16_t)etherType);
+ outp.append(frameData,(rules[rn].v.fwd.length != 0) ? ((frameLen < (unsigned int)rules[rn].v.fwd.length) ? frameLen : (unsigned int)rules[rn].v.fwd.length) : frameLen);
+ outp.compress();
+ RR->sw->send(outp,true);
+ }
+
+ if (rt == ZT_NETWORK_RULE_ACTION_REDIRECT) {
+ return -1; // match, drop packet (we redirected it)
+ } else {
+#ifdef ZT_RULES_ENGINE_DEBUGGING
+ dlog.clear();
+#endif // ZT_RULES_ENGINE_DEBUGGING
+ thisSetMatches = 1; // TEE does not terminate evaluation
+ }
}
} continue;
case ZT_NETWORK_RULE_ACTION_DEBUG_LOG: