You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/07/08 19:47:39 UTC
[GitHub] [incubator-nuttx] anchao opened a new pull request, #6589: net/tcp: fix assertion of fallback connection alloc
anchao opened a new pull request, #6589:
URL: https://github.com/apache/incubator-nuttx/pull/6589
## Summary
net/tcp: fix assertion of fallback connection alloc
When the free connection list is unenough to alloc a new instance,
the TCP stack will reuse the currently closed connection, but if
the handle is not released by the user via close(2), the reference
count of the connection remains in a non-zero value, it will cause
the assertion to fail, so when the handle is not released we should
not use such a conn instance when being actively closed, and ensure
that the reference count is assigned within the net lock protection
```
|(gdb) bt
|#0 up_assert (filename=0x565c78f7 "tcp/tcp_conn.c", lineno=771) at sim/up_assert.c:75
|#1 0x56566177 in _assert (filename=0x565c78f7 "tcp/tcp_conn.c", linenum=771) at assert/lib_assert.c:36
|#2 0x5657d620 in tcp_free (conn=0x565fb3e0 <g_tcp_connections>) at tcp/tcp_conn.c:771
|#3 0x5657d5a1 in tcp_alloc (domain=2 '\002') at tcp/tcp_conn.c:700
|#4 0x565b1f50 in inet_tcp_alloc (psock=0xf3dea150) at inet/inet_sockif.c:144
|#5 0x565b2082 in inet_setup (psock=0xf3dea150, protocol=0) at inet/inet_sockif.c:253
|#6 0x565b1bf0 in psock_socket (domain=2, type=1, protocol=0, psock=0xf3dea150) at socket/socket.c:121
|#7 0x56588f5f in socket (domain=2, type=1, protocol=0) at socket/socket.c:278
|#8 0x565b11c0 in hello_main (argc=1, argv=0xf3dfab10) at hello_main.c:35
|#9 0x56566631 in nxtask_startup (entrypt=0x565b10ef <hello_main>, argc=1, argv=0xf3dfab10) at sched/task_startup.c:70
|#10 0x565597fa in nxtask_start () at task/task_start.c:134
```
Signed-off-by: chao.an <an...@xiaomi.com>
## Impact
tcp fallback connection alloc
## Testing
test demo:
set the tcp connect count to 1:
CONFIG_NET_TCP_CONNS=1
```
int main(int argc, char **argv)
{
struct sockaddr_in serveraddr;
int crash_sock;
int sock;
int ret;
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
return sock;
}
serveraddr.sin_family = AF_INET;
serveraddr.sin_addr.s_addr = inet_addr("192.168.1.111");
serveraddr.sin_port = htons(atoi("112237"));
ret = connect(sock, (struct sockaddr*)&serveraddr, sizeof(serveraddr));
if (ret < 0)
{
return ret;
}
/* Delay 5m to wait the server teardown */
sleep(5);
/* if CONFIG_NET_TCP_CONNS=1, fall-back to active conn, trigger assertion failure */
crash_sock = socket(AF_INET, SOCK_STREAM, 0);
close(sock);
close(crash_sock);
return 0;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] masayuki2009 merged pull request #6589: net/tcp: fix assertion of fallback connection alloc
Posted by GitBox <gi...@apache.org>.
masayuki2009 merged PR #6589:
URL: https://github.com/apache/incubator-nuttx/pull/6589
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] anchao commented on pull request #6589: net/tcp: fix assertion of fallback connection alloc
Posted by GitBox <gi...@apache.org>.
anchao commented on PR #6589:
URL: https://github.com/apache/incubator-nuttx/pull/6589#issuecomment-1179312591
@pkarashchenko @yamt
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] anchao commented on a diff in pull request #6589: net/tcp: fix assertion of fallback connection alloc
Posted by GitBox <gi...@apache.org>.
anchao commented on code in PR #6589:
URL: https://github.com/apache/incubator-nuttx/pull/6589#discussion_r917162878
##########
net/tcp/tcp_conn.c:
##########
@@ -656,11 +656,13 @@ FAR struct tcp_conn_s *tcp_alloc(uint8_t domain)
* in the socket layer.
Review Comment:
Yes, REVISIT comment could be removed directly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6589: net/tcp: fix assertion of fallback connection alloc
Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6589:
URL: https://github.com/apache/incubator-nuttx/pull/6589#discussion_r917151834
##########
net/tcp/tcp_conn.c:
##########
@@ -656,11 +656,13 @@ FAR struct tcp_conn_s *tcp_alloc(uint8_t domain)
* in the socket layer.
Review Comment:
since `crefs = 0;` is now moved after `SO_LINGER` handling, should we consider this change as one that address "REVISIT" comment here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org