Skip to content

Commit d57568c

Browse files
committed
Fix LISTEN state socker regression shooting RST
1 parent 5c5cac4 commit d57568c

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/test/unit/unit_tests_tcp_flow.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3921,6 +3921,13 @@ START_TEST(test_tcp_input_listen_accept_final_ack_does_not_send_rst)
39213921
ck_assert_uint_eq(last_frame_sent_size, 0U);
39223922
ck_assert_int_eq(listen_ts->sock.tcp.state, TCP_LISTEN);
39233923
ck_assert_int_eq(client_ts->sock.tcp.state, TCP_ESTABLISHED);
3924+
3925+
inject_tcp_segment(&s, TEST_PRIMARY_IF, 0x0A000002U, 0x0A000001U,
3926+
4321, 1234, client_ts->sock.tcp.ack, client_ts->sock.tcp.seq, TCP_FLAG_ACK);
3927+
3928+
ck_assert_uint_eq(last_frame_sent_size, 0U);
3929+
ck_assert_int_eq(listen_ts->sock.tcp.state, TCP_LISTEN);
3930+
ck_assert_int_eq(client_ts->sock.tcp.state, TCP_ESTABLISHED);
39243931
}
39253932
END_TEST
39263933

src/wolfip.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,7 +3772,7 @@ static void tcp_ack(struct tsocket *t, const struct wolfIP_tcp_seg *tcp)
37723772

37733773
}
37743774

3775-
static int tcp_listen_ack_matches_pending_child(struct wolfIP *S,
3775+
static int tcp_listen_ack_matches_child_socket(struct wolfIP *S,
37763776
const struct tsocket *listener, const struct wolfIP_tcp_seg *tcp)
37773777
{
37783778
int i;
@@ -3786,7 +3786,7 @@ static int tcp_listen_ack_matches_pending_child(struct wolfIP *S,
37863786

37873787
if (t == listener || t->proto == 0 || t->S == NULL)
37883788
continue;
3789-
if (t->sock.tcp.state != TCP_SYN_RCVD)
3789+
if (t->sock.tcp.state <= TCP_LISTEN)
37903790
continue;
37913791
if (t->src_port != local_port || t->dst_port != remote_port)
37923792
continue;
@@ -3877,7 +3877,7 @@ static void tcp_input(struct wolfIP *S, unsigned int if_idx,
38773877
if (tcp->flags & TCP_FLAG_RST)
38783878
continue;
38793879
if (tcp->flags & TCP_FLAG_ACK) {
3880-
if (!tcp_listen_ack_matches_pending_child(S, t, tcp))
3880+
if (!tcp_listen_ack_matches_child_socket(S, t, tcp))
38813881
tcp_send_reset_reply(S, if_idx, tcp);
38823882
continue;
38833883
}

0 commit comments

Comments
 (0)