Diagnose adopted transports and isolate traffic test commands
This commit is contained in:
1 parent
34e346463d
commit
17c92e1745
2 files changed
+8
-4
No files matched your search
@@ -832,6 +832,8 @@ int node_conn_direct_open(struct UTUN_INSTANCE* inst, uint64_t node_id,
|
||||
if (!entry) { DEBUG_ERROR(DEBUG_CATEGORY_NCD, "[ncd] alloc entry failed node=0x%016llx", (unsigned long long)node_id); return NCD_ERR; }
|
||||
entry->node_id = node_id; entry->conn = conn; entry->ua = inst->ua;
|
||||
entry->up = (uint8_t)(conn->links_up ? 1 : 0);
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_NCD, "[ncd] adopt conn=%p node=%016llx state=%d links_up=%u initialized=%u tx=%u",
|
||||
(void*)conn, (unsigned long long)node_id, conn->state, conn->links_up, conn->initialized, conn->tx_state);
|
||||
if (ncd_registry_add(inst, entry) < 0) { u_free(entry); return NCD_ERR; }
|
||||
|
||||
struct NODE_CONN_DIRECT* h = u_calloc(1, sizeof(*h));
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#define TRAFFIC_MB (1024*1024)
|
||||
#define PKT_MIN 10
|
||||
#define PKT_MAX 1800
|
||||
#define CLIENT_CMD 253
|
||||
#define SERVER_CMD 254
|
||||
|
||||
static int test_failed = 0;
|
||||
|
||||
@@ -47,7 +49,7 @@ static void receive_packet(struct ETCP_CONN* conn, struct ll_entry* entry) {
|
||||
int valid = entry->dgram && entry->len >= 5;
|
||||
if (valid) {
|
||||
for (unsigned i = 0; i < 4; i++) seq |= (unsigned)entry->dgram[i + 1] << (8 * i);
|
||||
valid = entry->dgram[0] == side && seq == (unsigned)rx->pkts;
|
||||
valid = entry->dgram[0] == (side == 1 ? CLIENT_CMD : SERVER_CMD) && seq == (unsigned)rx->pkts;
|
||||
for (unsigned i = 5; valid && i < entry->len; i++)
|
||||
valid = entry->dgram[i] == (uint8_t)(i * 7 + seq * 13 + side);
|
||||
}
|
||||
@@ -71,7 +73,7 @@ static void connect_cb(struct NODE_CONN_DIRECT* h, enum ncd_event event, void* a
|
||||
}
|
||||
|
||||
static size_t gen_packet(uint8_t *buf, int side, int seq, size_t paylen) {
|
||||
buf[0] = (uint8_t)side;
|
||||
buf[0] = side == 1 ? CLIENT_CMD : SERVER_CMD;
|
||||
buf[1] = (uint8_t)(seq >> 0);
|
||||
buf[2] = (uint8_t)(seq >> 8);
|
||||
buf[3] = (uint8_t)(seq >> 16);
|
||||
@@ -149,8 +151,8 @@ int main(void) {
|
||||
|
||||
memset(&srv_rx, 0, sizeof(srv_rx)); srv_rx.expected_total = TRAFFIC_MB;
|
||||
memset(&cli_rx, 0, sizeof(cli_rx)); cli_rx.expected_total = TRAFFIC_MB;
|
||||
TASSERT(etcp_bind(srv_inst, 1, receive_packet) >= 0);
|
||||
TASSERT(etcp_bind(cli_inst, 2, receive_packet) >= 0);
|
||||
TASSERT(etcp_bind(srv_inst, CLIENT_CMD, receive_packet) >= 0);
|
||||
TASSERT(etcp_bind(cli_inst, SERVER_CMD, receive_packet) >= 0);
|
||||
|
||||
struct TOPO_GROUP_NODE *srv_node = topo_groups_get_default(srv_inst->topo_groups) ? topo_groups_get_default(srv_inst->topo_groups)->local_node : NULL;
|
||||
TASSERT(srv_node);
|
||||
|
||||
Reference in new issue
Block a user