net: tcp2: Socket was accepted too early
The TCP2 was calling accept callback before actually finalizing the connection attempt. Fixes #29164 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
c1ccd6b14e
commit
d3283231a5
|
@ -1079,10 +1079,7 @@ static enum net_verdict tcp_recv(struct net_conn *net_conn,
|
||||||
|
|
||||||
net_ipaddr_copy(&conn_old->context->remote, &conn->dst.sa);
|
net_ipaddr_copy(&conn_old->context->remote, &conn->dst.sa);
|
||||||
|
|
||||||
conn_old->accept_cb(conn->context,
|
conn->accepted_conn = conn_old;
|
||||||
&conn_old->context->remote,
|
|
||||||
sizeof(struct sockaddr), 0,
|
|
||||||
conn_old->context);
|
|
||||||
}
|
}
|
||||||
in:
|
in:
|
||||||
if (conn) {
|
if (conn) {
|
||||||
|
@ -1266,6 +1263,18 @@ next_state:
|
||||||
net_context_set_state(conn->context,
|
net_context_set_state(conn->context,
|
||||||
NET_CONTEXT_CONNECTED);
|
NET_CONTEXT_CONNECTED);
|
||||||
|
|
||||||
|
if (conn->accepted_conn) {
|
||||||
|
conn->accepted_conn->accept_cb(
|
||||||
|
conn->context,
|
||||||
|
&conn->accepted_conn->context->remote,
|
||||||
|
sizeof(struct sockaddr), 0,
|
||||||
|
conn->accepted_conn->context);
|
||||||
|
|
||||||
|
/* Make sure the accept_cb is only called once.
|
||||||
|
*/
|
||||||
|
conn->accepted_conn = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (len) {
|
if (len) {
|
||||||
if (tcp_data_get(conn, pkt) < 0) {
|
if (tcp_data_get(conn, pkt) < 0) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -183,7 +183,10 @@ struct tcp { /* TCP connection */
|
||||||
struct net_if *iface;
|
struct net_if *iface;
|
||||||
void *recv_user_data;
|
void *recv_user_data;
|
||||||
sys_slist_t send_queue;
|
sys_slist_t send_queue;
|
||||||
net_tcp_accept_cb_t accept_cb;
|
union {
|
||||||
|
net_tcp_accept_cb_t accept_cb;
|
||||||
|
struct tcp *accepted_conn;
|
||||||
|
};
|
||||||
struct k_mutex lock;
|
struct k_mutex lock;
|
||||||
struct k_sem connect_sem; /* semaphore for blocking connect */
|
struct k_sem connect_sem; /* semaphore for blocking connect */
|
||||||
struct tcp_options recv_options;
|
struct tcp_options recv_options;
|
||||||
|
|
Loading…
Reference in a new issue