Skip to content

Commit f344a42

Browse files
zhhyu7xiaoxiang781216
authored andcommitted
tcp_input: remove tcp_callback(ABORT) when accept conn recv TCP_RESET
when accept conn receives TCP_RESET, only accept conn itself should handle the event, and there is no need to notify the listening conn. otherwise, the server's poll will return with POLLERR and POLLHUP. this may cause some applications to execute incorrect logic in the future. Signed-off-by: zhanghongyu <[email protected]>
1 parent a4fd1b3 commit f344a42

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

net/tcp/tcp_input.c

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,6 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
901901

902902
if ((tcp->flags & TCP_RST) != 0)
903903
{
904-
FAR struct tcp_conn_s *listener = NULL;
905-
906904
/* An RST received during the 3-way connection handshake requires
907905
* little more clean-up.
908906
*/
@@ -912,33 +910,6 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
912910
conn->tcpstateflags = TCP_CLOSED;
913911
nwarn("WARNING: RESET in TCP_SYN_RCVD\n");
914912

915-
/* Notify the listener for the connection of the reset event */
916-
917-
#ifdef CONFIG_NET_IPv6
918-
# ifdef CONFIG_NET_IPv4
919-
if (domain == PF_INET6)
920-
# endif
921-
{
922-
net_ipv6addr_copy(&uaddr.ipv6.laddr, IPv6BUF->destipaddr);
923-
}
924-
#endif
925-
926-
#ifdef CONFIG_NET_IPv4
927-
# ifdef CONFIG_NET_IPv6
928-
if (domain == PF_INET)
929-
# endif
930-
{
931-
net_ipv4addr_copy(uaddr.ipv4.laddr,
932-
net_ip4addr_conv32(IPv4BUF->destipaddr));
933-
}
934-
#endif
935-
936-
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
937-
listener = tcp_findlistener(&uaddr, conn->lport, domain);
938-
#else
939-
listener = tcp_findlistener(&uaddr, conn->lport);
940-
#endif
941-
942913
/* We must free this TCP connection structure; this connection
943914
* will never be established. There should only be one reference
944915
* on this connection when we allocated for the connection.
@@ -955,15 +926,10 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
955926

956927
/* Notify this connection of the reset event */
957928

958-
listener = conn;
929+
tcp_callback(dev, conn, TCP_ABORT);
959930
}
960931

961-
/* Perform the TCP_ABORT callback and drop the packet */
962-
963-
if (listener != NULL)
964-
{
965-
tcp_callback(dev, listener, TCP_ABORT);
966-
}
932+
/* Drop the packet */
967933

968934
goto drop;
969935
}

0 commit comments

Comments
 (0)