From fa649df52eb7eeb57d0dc8d70c1e738c75ef8093 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 14 May 2017 08:39:53 -0600 Subject: [PATCH 1/6] Photon: Small update from Simon Piriou. --- drivers/wireless/ieee80211/bcmf_driver.c | 4 +--- drivers/wireless/ieee80211/bcmf_netdev.c | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/wireless/ieee80211/bcmf_driver.c b/drivers/wireless/ieee80211/bcmf_driver.c index 4666d8da9f8..94a2c750c5a 100644 --- a/drivers/wireless/ieee80211/bcmf_driver.c +++ b/drivers/wireless/ieee80211/bcmf_driver.c @@ -370,7 +370,6 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, struct bcmf_event_s *event, unsigned int len) { uint32_t status; - uint32_t reason; uint32_t event_len; struct wl_escan_result *result; struct wl_bss_info *bss; @@ -387,7 +386,6 @@ void bcmf_wl_scan_event_handler(FAR struct bcmf_dev_s *priv, } status = bcmf_getle32(&event->status); - reason = bcmf_getle32(&event->reason); escan_result_len = bcmf_getle32(&event->len); len -= sizeof(struct bcmf_event_s); @@ -464,7 +462,7 @@ wl_escan_result_processed: /* Scan done */ - wlinfo("escan done event %d %d\n", status, reason); + wlinfo("escan done event %d %d\n", status, bcmf_getle32(&event->reason)); wd_cancel(priv->scan_timeout); diff --git a/drivers/wireless/ieee80211/bcmf_netdev.c b/drivers/wireless/ieee80211/bcmf_netdev.c index 02527fe60ce..455b15529bd 100644 --- a/drivers/wireless/ieee80211/bcmf_netdev.c +++ b/drivers/wireless/ieee80211/bcmf_netdev.c @@ -177,7 +177,7 @@ int bcmf_netdev_alloc_tx_frame(FAR struct bcmf_dev_s *priv) priv->cur_tx_frame = bcmf_bdc_allocate_frame(priv, MAX_NET_DEV_MTU, true); if (!priv->cur_tx_frame) { - wlerr("Cannot allocate TX frame\n"); + wlerr("ERROR: Cannot allocate TX frame\n"); return -ENOMEM; } @@ -215,7 +215,7 @@ static int bcmf_transmit(FAR struct bcmf_dev_s *priv, if (ret) { - wlerr("Failed to transmit frame\n"); + wlerr("ERROR: Failed to transmit frame\n"); return -EIO; } @@ -392,7 +392,7 @@ static void bcmf_receive(FAR struct bcmf_dev_s *priv) else #endif { - wlinfo("RX dropped\n"); + wlerr("ERROR: RX dropped\n"); NETDEV_RXDROPPED(&priv->bc_dev); priv->bus->free_frame(priv, frame); } @@ -992,11 +992,11 @@ static int bcmf_ioctl(FAR struct net_driver_s *dev, int cmd, switch (cmd) { case SIOCSIWSCAN: - ret = bcmf_wl_start_scan(priv, (struct ifreq *)arg); + ret = bcmf_wl_start_scan(priv, (struct iwreq *)arg); break; case SIOCGIWSCAN: - ret = bcmf_wl_get_scan_results(priv, (struct ifreq *)arg); + ret = bcmf_wl_get_scan_results(priv, (struct iwreq *)arg); break; case SIOCSIFHWADDR: /* Set device MAC address */ From 8dc7f6d79e63b26b5890fcee318334f196d0a595 Mon Sep 17 00:00:00 2001 From: Simon Piriou Date: Sun, 14 May 2017 09:08:32 -0600 Subject: [PATCH 2/6] tcp: wait for 3-Way Handshare before accept() returns --- net/tcp/Kconfig | 7 +++++++ net/tcp/tcp_input.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/net/tcp/Kconfig b/net/tcp/Kconfig index fac41794dcf..1660b080eee 100644 --- a/net/tcp/Kconfig +++ b/net/tcp/Kconfig @@ -156,6 +156,13 @@ config NET_TCPBACKLOG Incoming connections pend in a backlog until accept() is called. The size of the backlog is selected when listen() is called. +config NET_ACCEPT_ON_ACK + bool "accept() returns on TCP 3-Way Handshake completion" + default n + ---help--- + accept() returns after 3-Way Handshake is complete (SYN, SYN/ACK, ACK). + Without this flag it returns after SYN packet is received. + config NET_TCP_SPLIT bool "Enable packet splitting" default n diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c index 1918bd34924..22e11be7ae1 100644 --- a/net/tcp/tcp_input.c +++ b/net/tcp/tcp_input.c @@ -185,6 +185,8 @@ static void tcp_input(FAR struct net_driver_s *dev, unsigned int iplen) */ conn->crefs = 1; + +#ifndef CONFIG_NET_ACCEPT_ON_ACK if (tcp_accept_connection(dev, conn, tmp16) != OK) { /* No, then we have to give the connection back and drop the packet */ @@ -193,6 +195,7 @@ static void tcp_input(FAR struct net_driver_s *dev, unsigned int iplen) tcp_free(conn); conn = NULL; } +#endif } if (!conn) @@ -464,6 +467,23 @@ found: { conn->tcpstateflags = TCP_ESTABLISHED; +#ifdef CONFIG_NET_ACCEPT_ON_ACK + if (tcp_accept_connection(dev, conn, tcp->destport) != OK) + { + /* No more listener for current port. We can free conn here + * because it has not been shared with upper layers yet as + * handshake is not complete + */ + + nerr("Listen canceled while waiting for ACK on port %d\n", + tcp->destport); + conn->crefs = 0; + tcp_free(conn); + conn = NULL; + goto drop; + } +#endif + #ifdef CONFIG_NET_TCP_WRITE_BUFFERS conn->isn = tcp_getsequence(tcp->ackno); tcp_setsequence(conn->sndseq, conn->isn); From d339ba9e0eb743d5444d9d3b1e31cebb033f5641 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 14 May 2017 10:56:25 -0600 Subject: [PATCH 3/6] TCP: Fix some potential error conditions that could result from deferring the connection until the full 3-way handshake has completed. --- net/tcp/Kconfig | 7 ------ net/tcp/tcp.h | 13 +++++++++++ net/tcp/tcp_input.c | 38 ++++++++++++++++++-------------- net/tcp/tcp_listen.c | 2 +- net/tcp/tcp_timer.c | 52 +++++++++++++++++++++++++++++++++++++++----- 5 files changed, 82 insertions(+), 30 deletions(-) diff --git a/net/tcp/Kconfig b/net/tcp/Kconfig index 1660b080eee..fac41794dcf 100644 --- a/net/tcp/Kconfig +++ b/net/tcp/Kconfig @@ -156,13 +156,6 @@ config NET_TCPBACKLOG Incoming connections pend in a backlog until accept() is called. The size of the backlog is selected when listen() is called. -config NET_ACCEPT_ON_ACK - bool "accept() returns on TCP 3-Way Handshake completion" - default n - ---help--- - accept() returns after 3-Way Handshake is complete (SYN, SYN/ACK, ACK). - Without this flag it returns after SYN packet is received. - config NET_TCP_SPLIT bool "Enable packet splitting" default n diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index 4b3bb85e754..2797f4f3bc1 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -697,6 +697,19 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, void tcp_listen_initialize(void); +/**************************************************************************** + * Name: tcp_findlistener + * + * Description: + * Return the connection listener for connections on this port (if any) + * + * Assumptions: + * Called at interrupt level + * + ****************************************************************************/ + +FAR struct tcp_conn_s *tcp_findlistener(uint16_t portno); + /**************************************************************************** * Name: tcp_unlisten * diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c index 22e11be7ae1..8788b5ca95d 100644 --- a/net/tcp/tcp_input.c +++ b/net/tcp/tcp_input.c @@ -179,23 +179,25 @@ static void tcp_input(FAR struct net_driver_s *dev, unsigned int iplen) conn = tcp_alloc_accept(dev, tcp); if (conn) { - /* The connection structure was successfully allocated. Now see if - * there is an application waiting to accept the connection (or at - * least queue it it for acceptance). + /* The connection structure was successfully allocated and has + * been initialized in the TCP_SYN_RECVD state. The expected + * sequence of events is then the rest of the 3-way handshake: + * + * 1. We just received a TCP SYN packet from a remote host. + * 2. We will send the SYN-ACK response below (perhaps + * repeatedly in the event of a timeout) + * 3. Then we expect to receive an ACK from the remote host + * indicated the TCP socket connection is ESTABLISHED. + * + * Possible failure: + * + * 1. The ACK is never received. This will be handled by + * a timeout managed by tcp_timer(). + * 2. The listener "unlistens()". This will be handled by + * the failure of tcp_accept_connection() when the ACK is received. */ conn->crefs = 1; - -#ifndef CONFIG_NET_ACCEPT_ON_ACK - if (tcp_accept_connection(dev, conn, tmp16) != OK) - { - /* No, then we have to give the connection back and drop the packet */ - - conn->crefs = 0; - tcp_free(conn); - conn = NULL; - } -#endif } if (!conn) @@ -465,9 +467,14 @@ found: if ((flags & TCP_ACKDATA) != 0) { + /* The three way handshake is complete and the TCP connection + * is now in the ESTABLISHED state. + */ + conn->tcpstateflags = TCP_ESTABLISHED; -#ifdef CONFIG_NET_ACCEPT_ON_ACK + /* Wake up any listener waiting for a connection on this port */ + if (tcp_accept_connection(dev, conn, tcp->destport) != OK) { /* No more listener for current port. We can free conn here @@ -482,7 +489,6 @@ found: conn = NULL; goto drop; } -#endif #ifdef CONFIG_NET_TCP_WRITE_BUFFERS conn->isn = tcp_getsequence(tcp->ackno); diff --git a/net/tcp/tcp_listen.c b/net/tcp/tcp_listen.c index f7d771d2b6d..b3d36a126d3 100644 --- a/net/tcp/tcp_listen.c +++ b/net/tcp/tcp_listen.c @@ -257,7 +257,7 @@ int tcp_accept_connection(FAR struct net_driver_s *dev, */ listener = tcp_findlistener(portno); - if (listener) + if (listener != NULL) { /* Yes, there is a listener. Is it accepting connections now? */ diff --git a/net/tcp/tcp_timer.c b/net/tcp/tcp_timer.c index 245e849ec67..8e21bb5d8fb 100644 --- a/net/tcp/tcp_timer.c +++ b/net/tcp/tcp_timer.c @@ -218,17 +218,57 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, goto done; } #endif - /* Should we close the connection? */ + /* Check for a timeout on connection in the TCP_SYN_RCVD state. + * On such timeouts, we would normally resend the SYNACK until + * the ACK is received, completing the 3-way handshek. But if + * the retry count elapsed, then we must assume that no ACK is + * forthcoming and terminate the attempted connection. + */ - if ( + if (conn->tcpstateflags == TCP_SYN_RCVD && + conn->nrtx >= TCP_MAXSYNRTX) + { + FAR struct tcp_conn_s *listener; + + conn->tcpstateflags = TCP_CLOSED; + ninfo("TCP state: TCP_CLOSED\n"); + + /* Find the listener for this connectins */ + + listener = tcp_findlistener(conn->lport); + if (listener != NULL) + { + /* We call tcp_callback() for the connection with + * TCP_TIMEDOUT to inform the listener that the + * connection has timed out. + */ + + result = tcp_callback(dev, listener, TCP_TIMEDOUT); + } + + /* We also send a reset packet to the remote host. */ + + tcp_send(dev, conn, TCP_RST | TCP_ACK, hdrlen); + + /* Finally, we must free this TCP connection structure */ + + tcp_free(conn); + goto done; + } + + /* Otherwise, check for a timeout on an established connection. + * If the retry count is exceeded in this case, we should + * close the connection. + */ + + else if ( #ifdef CONFIG_NET_TCP_WRITE_BUFFERS conn->expired > 0 || #else - conn->nrtx == TCP_MAXRTX || + conn->nrtx >= TCP_MAXRTX || #endif - ((conn->tcpstateflags == TCP_SYN_SENT || - conn->tcpstateflags == TCP_SYN_RCVD) && - conn->nrtx == TCP_MAXSYNRTX) + (conn->tcpstateflags == TCP_SYN_SENT && + conn->nrtx >= TCP_MAXSYNRTX) ) { conn->tcpstateflags = TCP_CLOSED; From 7e75d61ea020773a4e143559c86f02992c0dcec3 Mon Sep 17 00:00:00 2001 From: Simon Piriou Date: Sun, 14 May 2017 19:29:44 +0200 Subject: [PATCH 4/6] photon/wlan: disable network logs and add nsh over telnet --- configs/photon/wlan/defconfig | 54 +++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/configs/photon/wlan/defconfig b/configs/photon/wlan/defconfig index 652636ab5e4..996eed22735 100644 --- a/configs/photon/wlan/defconfig +++ b/configs/photon/wlan/defconfig @@ -65,14 +65,11 @@ CONFIG_DEBUG_INFO=y # CONFIG_DEBUG_GRAPHICS is not set # CONFIG_DEBUG_LIB is not set # CONFIG_DEBUG_MM is not set -CONFIG_DEBUG_NET=y -CONFIG_DEBUG_NET_ERROR=y -CONFIG_DEBUG_NET_WARN=y -CONFIG_DEBUG_NET_INFO=y +# CONFIG_DEBUG_NET is not set CONFIG_DEBUG_WIRELESS=y CONFIG_DEBUG_WIRELESS_ERROR=y CONFIG_DEBUG_WIRELESS_WARN=y -CONFIG_DEBUG_WIRELESS_INFO=y +# CONFIG_DEBUG_WIRELESS_INFO is not set # CONFIG_DEBUG_SCHED is not set # @@ -169,7 +166,6 @@ CONFIG_ARCH_CORTEXM3=y # CONFIG_ARCH_CORTEXR7F is not set CONFIG_ARCH_FAMILY="armv7-m" CONFIG_ARCH_CHIP="stm32" -# CONFIG_ARCH_TOOLCHAIN_IAR is not set # CONFIG_ARMV7M_USEBASEPRI is not set CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARMV7M_CMNVECTOR is not set @@ -569,6 +565,7 @@ CONFIG_STM32_SDIO_DMAPRIO=0x00010000 # # USB Device Configuration # +# CONFIG_ARCH_TOOLCHAIN_IAR is not set CONFIG_ARCH_TOOLCHAIN_GNU=y # @@ -870,7 +867,9 @@ CONFIG_NETDEVICES=y # General Ethernet MAC Driver Options # # CONFIG_NETDEV_LOOPBACK is not set -# CONFIG_NETDEV_TELNET is not set +CONFIG_NETDEV_TELNET=y +CONFIG_TELNET_RXBUFFER_SIZE=256 +CONFIG_TELNET_TXBUFFER_SIZE=256 # CONFIG_NETDEV_MULTINIC is not set # CONFIG_ARCH_HAVE_NETDEV_STATISTICS is not set CONFIG_NETDEV_LATEINIT=y @@ -892,7 +891,7 @@ CONFIG_NETDEV_LATEINIT=y CONFIG_SERIAL=y # CONFIG_DEV_LOWCONSOLE is not set # CONFIG_SERIAL_REMOVABLE is not set -CONFIG_SERIAL_CONSOLE=y +# CONFIG_SERIAL_CONSOLE is not set # CONFIG_16550_UART is not set # CONFIG_UART_SERIALDRIVER is not set # CONFIG_UART0_SERIALDRIVER is not set @@ -923,9 +922,9 @@ CONFIG_STANDARD_SERIAL=y # CONFIG_SERIAL_DMA is not set # CONFIG_SERIAL_TIOCSERGSTRUCT is not set CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y -CONFIG_USART1_SERIAL_CONSOLE=y +# CONFIG_USART1_SERIAL_CONSOLE is not set # CONFIG_OTHER_SERIAL_CONSOLE is not set -# CONFIG_NO_SERIAL_CONSOLE is not set +CONFIG_NO_SERIAL_CONSOLE=y # # USART1 Configuration @@ -966,11 +965,14 @@ CONFIG_SYSLOG_WRITE=y # CONFIG_SYSLOG_BUFFER is not set # CONFIG_SYSLOG_INTBUFFER is not set # CONFIG_SYSLOG_TIMESTAMP is not set -CONFIG_SYSLOG_SERIAL_CONSOLE=y -# CONFIG_SYSLOG_CHAR is not set -CONFIG_SYSLOG_CONSOLE=y +# CONFIG_SYSLOG_SERIAL_CONSOLE is not set +CONFIG_SYSLOG_CHAR=y +# CONFIG_SYSLOG_CONSOLE is not set # CONFIG_SYSLOG_NONE is not set # CONFIG_SYSLOG_FILE is not set +# CONFIG_CONSOLE_SYSLOG is not set +CONFIG_SYSLOG_CHAR_CRLF=y +CONFIG_SYSLOG_DEVPATH="/dev/ttyS0" # CONFIG_SYSLOG_CHARDEV is not set # @@ -1076,7 +1078,6 @@ CONFIG_NET_ARPTAB_SIZE=16 CONFIG_NET_ARP_MAXAGE=120 # CONFIG_NET_ARP_IPIN is not set # CONFIG_NET_ARP_SEND is not set -# CONFIG_NET_ARP_DUMP is not set # # User-space networking stack API @@ -1293,7 +1294,6 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # # CONFIG_C99_BOOL8 is not set CONFIG_HAVE_CXX=y -CONFIG_HAVE_CXXINITIALIZE=y # CONFIG_CXX_NEWLONG is not set # @@ -1310,6 +1310,10 @@ CONFIG_HAVE_CXXINITIALIZE=y # Application Configuration # +# +# NxWidgets/NxWM +# + # # Built-In Applications # @@ -1430,7 +1434,7 @@ CONFIG_NETUTILS_PING=y CONFIG_NETUTILS_PING_SIGNO=13 # CONFIG_NETUTILS_PPPD is not set # CONFIG_NETUTILS_SMTP is not set -# CONFIG_NETUTILS_TELNETD is not set +CONFIG_NETUTILS_TELNETD=y # CONFIG_NETUTILS_TFTPC is not set # CONFIG_NETUTILS_WEBCLIENT is not set # CONFIG_NETUTILS_WEBSERVER is not set @@ -1533,8 +1537,7 @@ CONFIG_NSH_FILEIOSIZE=512 # # Console Configuration # -CONFIG_NSH_CONSOLE=y -# CONFIG_NSH_ALTCONDEV is not set +# CONFIG_NSH_CONSOLE is not set CONFIG_NSH_ARCHINIT=y # @@ -1567,17 +1570,26 @@ CONFIG_NSH_WAPI_ALG=3 CONFIG_NSH_WAPI_SSID="myApSSID" CONFIG_NSH_WAPI_PASSPHRASE="mySSIDpassphrase" CONFIG_NSH_MAX_ROUNDTRIP=20 -# CONFIG_NSH_LOGIN is not set -# CONFIG_NSH_CONSOLE_LOGIN is not set # -# NxWidgets/NxWM +# Telnet Configuration # +CONFIG_NSH_TELNET=y +CONFIG_NSH_TELNETD_PORT=23 +CONFIG_NSH_TELNETD_DAEMONPRIO=100 +CONFIG_NSH_TELNETD_DAEMONSTACKSIZE=2048 +CONFIG_NSH_TELNETD_CLIENTPRIO=100 +CONFIG_NSH_TELNETD_CLIENTSTACKSIZE=2048 +CONFIG_NSH_IOBUFFER_SIZE=512 +# CONFIG_NSH_LOGIN is not set +# CONFIG_NSH_CONSOLE_LOGIN is not set +# CONFIG_NSH_TELNET_LOGIN is not set # # Platform-specific Support # # CONFIG_PLATFORM_CONFIGDATA is not set +CONFIG_HAVE_CXXINITIALIZE=y # # System Libraries and NSH Add-Ons From 8acfea1197e7b6d74672511126bda331d329d6c8 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 14 May 2017 12:14:31 -0600 Subject: [PATCH 5/6] Fix some typos --- configs/photon/wlan/defconfig | 8 ++++---- net/tcp/tcp_input.c | 12 +++++++----- net/tcp/tcp_timer.c | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/configs/photon/wlan/defconfig b/configs/photon/wlan/defconfig index 996eed22735..409aae40fc6 100644 --- a/configs/photon/wlan/defconfig +++ b/configs/photon/wlan/defconfig @@ -1310,10 +1310,6 @@ CONFIG_HAVE_CXX=y # Application Configuration # -# -# NxWidgets/NxWM -# - # # Built-In Applications # @@ -1585,6 +1581,10 @@ CONFIG_NSH_IOBUFFER_SIZE=512 # CONFIG_NSH_CONSOLE_LOGIN is not set # CONFIG_NSH_TELNET_LOGIN is not set +# +# NxWidgets/NxWM +# + # # Platform-specific Support # diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c index 8788b5ca95d..dc911bbf3f6 100644 --- a/net/tcp/tcp_input.c +++ b/net/tcp/tcp_input.c @@ -194,7 +194,8 @@ static void tcp_input(FAR struct net_driver_s *dev, unsigned int iplen) * 1. The ACK is never received. This will be handled by * a timeout managed by tcp_timer(). * 2. The listener "unlistens()". This will be handled by - * the failure of tcp_accept_connection() when the ACK is received. + * the failure of tcp_accept_connection() when the ACK is + * received. */ conn->crefs = 1; @@ -202,10 +203,11 @@ static void tcp_input(FAR struct net_driver_s *dev, unsigned int iplen) if (!conn) { - /* Either (1) all available connections are in use, or (2) there is no - * application in place to accept the connection. We drop packet and hope that - * the remote end will retransmit the packet at a time when we - * have more spare connections or someone waiting to accept the connection. + /* Either (1) all available connections are in use, or (2) + * there is no application in place to accept the connection. + * We drop packet and hope that the remote end will retransmit + * the packet at a time when we have more spare connections + * or someone waiting to accept the connection. */ #ifdef CONFIG_NET_STATISTICS diff --git a/net/tcp/tcp_timer.c b/net/tcp/tcp_timer.c index 8e21bb5d8fb..a9047fc4785 100644 --- a/net/tcp/tcp_timer.c +++ b/net/tcp/tcp_timer.c @@ -220,7 +220,7 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, #endif /* Check for a timeout on connection in the TCP_SYN_RCVD state. * On such timeouts, we would normally resend the SYNACK until - * the ACK is received, completing the 3-way handshek. But if + * the ACK is received, completing the 3-way handshake. But if * the retry count elapsed, then we must assume that no ACK is * forthcoming and terminate the attempted connection. */ @@ -233,7 +233,7 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, conn->tcpstateflags = TCP_CLOSED; ninfo("TCP state: TCP_CLOSED\n"); - /* Find the listener for this connectins */ + /* Find the listener for this connection. */ listener = tcp_findlistener(conn->lport); if (listener != NULL) From aa57fb159da6b20b9b11e79b0dc09e9340bc0826 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 14 May 2017 13:30:59 -0600 Subject: [PATCH 6/6] TCP: Send RST if applicaiton 'unlistens()' before we complete the connection sequence. --- net/tcp/tcp_input.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c index dc911bbf3f6..23bec6a6e55 100644 --- a/net/tcp/tcp_input.c +++ b/net/tcp/tcp_input.c @@ -486,10 +486,16 @@ found: nerr("Listen canceled while waiting for ACK on port %d\n", tcp->destport); + + /* Free the connection structure */ + conn->crefs = 0; tcp_free(conn); conn = NULL; - goto drop; + + /* And send a reset packet to the remote host. */ + + goto reset; } #ifdef CONFIG_NET_TCP_WRITE_BUFFERS