Drain pending UDP traffic before snapshotting INIT validation state
This commit is contained in:
1 parent
0860b1e06d
commit
d9aede4138
1 file changed
+7
-1
@@ -223,6 +223,12 @@ static void send_init_request_body(const struct ETCP_INIT_REQUEST_PKT *request,
|
||||
|
||||
static void request_boundaries(unsigned established) {
|
||||
setup(0, established);
|
||||
unsigned drained = 0; uint8_t pending;
|
||||
while (recv(ep[1].socket->fd, (char*)&pending, 1, MSG_PEEK) >= 0) {
|
||||
etcp_connections_read_callback_socket(ep[1].socket->fd, ep[1].socket); drained++;
|
||||
}
|
||||
CHECK(socket_get_error() == ERR_WOULDBLOCK || socket_get_error() == ERR_AGAIN);
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "INIT boundary fixture: established=%u drained_previous_packets=%u", established, drained);
|
||||
struct ETCP_INIT_REQUEST_PKT request = {0};
|
||||
for (unsigned i = 0; i < 8; i++) {
|
||||
request.node_id[i] = ep[0].inst->node_id >> (56 - i * 8);
|
||||
@@ -362,11 +368,11 @@ static void check_memory(size_t baseline) {
|
||||
int main(void) {
|
||||
debug_config_init(); debug_set_level(DEBUG_LEVEL_ERROR);
|
||||
debug_set_category_level(DEBUG_CATEGORY_CRYPTO, DEBUG_LEVEL_DISABLED);
|
||||
test_clock_init(10); CHECK(socket_platform_init() == 0);
|
||||
if (getenv("UTUN_TEST_DEBUG")) {
|
||||
debug_set_category_level(DEBUG_CATEGORY_ETCP, DEBUG_LEVEL_DEBUG);
|
||||
debug_set_category_level(DEBUG_CATEGORY_DEBUG, DEBUG_LEVEL_DEBUG);
|
||||
}
|
||||
test_clock_init(10); CHECK(socket_platform_init() == 0);
|
||||
size_t baseline = u_get_allocated_count();
|
||||
for (unsigned established = 0; established < 2; established++) { request_boundaries(established); check_memory(baseline); }
|
||||
response_boundaries(); check_memory(baseline);
|
||||
|
||||
Reference in new issue
Block a user