mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Be a bit more verbose in circuit test reports to more clearly track current and upstream hop in graph traversal history.
This commit is contained in:
parent
a95fa379cc
commit
aec13b50fd
4 changed files with 20 additions and 10 deletions
|
@ -1881,7 +1881,7 @@ void SqliteNetworkController::_circuitTestCallback(ZT_Node *node,ZT_CircuitTest
|
||||||
Utils::snprintf(tmp,sizeof(tmp),ZT_PATH_SEPARATOR_S"%.16llx_%.16llx",test->timestamp,test->testId);
|
Utils::snprintf(tmp,sizeof(tmp),ZT_PATH_SEPARATOR_S"%.16llx_%.16llx",test->timestamp,test->testId);
|
||||||
reportSavePath.append(tmp);
|
reportSavePath.append(tmp);
|
||||||
OSUtils::mkdir(reportSavePath);
|
OSUtils::mkdir(reportSavePath);
|
||||||
Utils::snprintf(tmp,sizeof(tmp),ZT_PATH_SEPARATOR_S"%.10llx",report->address);
|
Utils::snprintf(tmp,sizeof(tmp),ZT_PATH_SEPARATOR_S"%.10llx_%.10llx",report->upstream,report->current);
|
||||||
reportSavePath.append(tmp);
|
reportSavePath.append(tmp);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1891,7 +1891,8 @@ void SqliteNetworkController::_circuitTestCallback(ZT_Node *node,ZT_CircuitTest
|
||||||
return;
|
return;
|
||||||
fseek(f,0,SEEK_END);
|
fseek(f,0,SEEK_END);
|
||||||
fprintf(f,"%s{\n"
|
fprintf(f,"%s{\n"
|
||||||
"\t\"address\": \"%.10llx\","ZT_EOL_S
|
"\t\"current\": \"%.10llx\","ZT_EOL_S
|
||||||
|
"\t\"upstream\": \"%.10llx\","ZT_EOL_S
|
||||||
"\t\"testId\": \"%.16llx\","ZT_EOL_S
|
"\t\"testId\": \"%.16llx\","ZT_EOL_S
|
||||||
"\t\"timestamp\": %llu,"ZT_EOL_S
|
"\t\"timestamp\": %llu,"ZT_EOL_S
|
||||||
"\t\"receivedTimestamp\": %llu,"ZT_EOL_S
|
"\t\"receivedTimestamp\": %llu,"ZT_EOL_S
|
||||||
|
@ -1911,7 +1912,8 @@ void SqliteNetworkController::_circuitTestCallback(ZT_Node *node,ZT_CircuitTest
|
||||||
"\t\"receivedFromRemoteAddress\": \"%s\""ZT_EOL_S
|
"\t\"receivedFromRemoteAddress\": \"%s\""ZT_EOL_S
|
||||||
"}",
|
"}",
|
||||||
((ftell(f) > 0) ? ",\n" : ""),
|
((ftell(f) > 0) ? ",\n" : ""),
|
||||||
(unsigned long long)report->address,
|
(unsigned long long)report->current,
|
||||||
|
(unsigned long long)report->upstream,
|
||||||
(unsigned long long)test->testId,
|
(unsigned long long)test->testId,
|
||||||
(unsigned long long)report->timestamp,
|
(unsigned long long)report->timestamp,
|
||||||
(unsigned long long)now,
|
(unsigned long long)now,
|
||||||
|
|
|
@ -733,9 +733,14 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/**
|
/**
|
||||||
* Sender of report
|
* Sender of report (current hop)
|
||||||
*/
|
*/
|
||||||
uint64_t address;
|
uint64_t current;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Previous hop
|
||||||
|
*/
|
||||||
|
uint64_t upstream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 64-bit test ID
|
* 64-bit test ID
|
||||||
|
|
|
@ -993,6 +993,7 @@ bool IncomingPacket::_doCIRCUIT_TEST(const RuntimeEnvironment *RR,const SharedPt
|
||||||
outp.append((uint16_t)0); // error code, currently unused
|
outp.append((uint16_t)0); // error code, currently unused
|
||||||
outp.append((uint64_t)0); // flags, currently unused
|
outp.append((uint64_t)0); // flags, currently unused
|
||||||
outp.append((uint64_t)packetId());
|
outp.append((uint64_t)packetId());
|
||||||
|
peer->address().appendTo(outp);
|
||||||
outp.append((uint8_t)hops());
|
outp.append((uint8_t)hops());
|
||||||
_localAddress.serialize(outp);
|
_localAddress.serialize(outp);
|
||||||
_remoteAddress.serialize(outp);
|
_remoteAddress.serialize(outp);
|
||||||
|
@ -1039,13 +1040,14 @@ bool IncomingPacket::_doCIRCUIT_TEST_REPORT(const RuntimeEnvironment *RR,const S
|
||||||
ZT_CircuitTestReport report;
|
ZT_CircuitTestReport report;
|
||||||
memset(&report,0,sizeof(report));
|
memset(&report,0,sizeof(report));
|
||||||
|
|
||||||
report.address = peer->address().toInt();
|
report.current = peer->address().toInt();
|
||||||
|
report.upstream = Address(field(ZT_PACKET_IDX_PAYLOAD + 52,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH).toInt();
|
||||||
report.testId = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD + 8);
|
report.testId = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD + 8);
|
||||||
report.timestamp = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD);
|
report.timestamp = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD);
|
||||||
report.remoteTimestamp = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD + 16);
|
report.remoteTimestamp = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD + 16);
|
||||||
report.sourcePacketId = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD + 44);
|
report.sourcePacketId = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD + 44);
|
||||||
report.flags = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD + 36);
|
report.flags = at<uint64_t>(ZT_PACKET_IDX_PAYLOAD + 36);
|
||||||
report.sourcePacketHopCount = (*this)[ZT_PACKET_IDX_PAYLOAD + 52];
|
report.sourcePacketHopCount = (*this)[ZT_PACKET_IDX_PAYLOAD + 57]; // end of fixed length headers: 58
|
||||||
report.errorCode = at<uint16_t>(ZT_PACKET_IDX_PAYLOAD + 34);
|
report.errorCode = at<uint16_t>(ZT_PACKET_IDX_PAYLOAD + 34);
|
||||||
report.vendor = (enum ZT_Vendor)((*this)[ZT_PACKET_IDX_PAYLOAD + 24]);
|
report.vendor = (enum ZT_Vendor)((*this)[ZT_PACKET_IDX_PAYLOAD + 24]);
|
||||||
report.protocolVersion = (*this)[ZT_PACKET_IDX_PAYLOAD + 25];
|
report.protocolVersion = (*this)[ZT_PACKET_IDX_PAYLOAD + 25];
|
||||||
|
@ -1055,10 +1057,10 @@ bool IncomingPacket::_doCIRCUIT_TEST_REPORT(const RuntimeEnvironment *RR,const S
|
||||||
report.platform = (enum ZT_Platform)at<uint16_t>(ZT_PACKET_IDX_PAYLOAD + 30);
|
report.platform = (enum ZT_Platform)at<uint16_t>(ZT_PACKET_IDX_PAYLOAD + 30);
|
||||||
report.architecture = (enum ZT_Architecture)at<uint16_t>(ZT_PACKET_IDX_PAYLOAD + 32);
|
report.architecture = (enum ZT_Architecture)at<uint16_t>(ZT_PACKET_IDX_PAYLOAD + 32);
|
||||||
|
|
||||||
const unsigned int receivedOnLocalAddressLen = reinterpret_cast<InetAddress *>(&(report.receivedOnLocalAddress))->deserialize(*this,ZT_PACKET_IDX_PAYLOAD + 53);
|
const unsigned int receivedOnLocalAddressLen = reinterpret_cast<InetAddress *>(&(report.receivedOnLocalAddress))->deserialize(*this,ZT_PACKET_IDX_PAYLOAD + 58);
|
||||||
const unsigned int receivedFromRemoteAddressLen = reinterpret_cast<InetAddress *>(&(report.receivedFromRemoteAddress))->deserialize(*this,ZT_PACKET_IDX_PAYLOAD + 53 + receivedOnLocalAddressLen);
|
const unsigned int receivedFromRemoteAddressLen = reinterpret_cast<InetAddress *>(&(report.receivedFromRemoteAddress))->deserialize(*this,ZT_PACKET_IDX_PAYLOAD + 58 + receivedOnLocalAddressLen);
|
||||||
|
|
||||||
unsigned int nhptr = ZT_PACKET_IDX_PAYLOAD + 53 + receivedOnLocalAddressLen + receivedFromRemoteAddressLen;
|
unsigned int nhptr = ZT_PACKET_IDX_PAYLOAD + 58 + receivedOnLocalAddressLen + receivedFromRemoteAddressLen;
|
||||||
nhptr += at<uint16_t>(nhptr) + 2; // add "additional field" length, which right now will be zero
|
nhptr += at<uint16_t>(nhptr) + 2; // add "additional field" length, which right now will be zero
|
||||||
|
|
||||||
report.nextHopCount = (*this)[nhptr++];
|
report.nextHopCount = (*this)[nhptr++];
|
||||||
|
|
|
@ -1031,6 +1031,7 @@ public:
|
||||||
* <[2] 16-bit error code (set to 0, currently unused)>
|
* <[2] 16-bit error code (set to 0, currently unused)>
|
||||||
* <[8] 64-bit report flags (set to 0, currently unused)>
|
* <[8] 64-bit report flags (set to 0, currently unused)>
|
||||||
* <[8] 64-bit source packet ID>
|
* <[8] 64-bit source packet ID>
|
||||||
|
* <[5] upstream ZeroTier address from which test was received>
|
||||||
* <[1] 8-bit source packet hop count (ZeroTier hop count)>
|
* <[1] 8-bit source packet hop count (ZeroTier hop count)>
|
||||||
* <[...] local wire address on which packet was received>
|
* <[...] local wire address on which packet was received>
|
||||||
* <[...] remote wire address from which packet was received>
|
* <[...] remote wire address from which packet was received>
|
||||||
|
|
Loading…
Add table
Reference in a new issue