You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "raiden00pl (via GitHub)" <gi...@apache.org> on 2026/10/21 17:40:09 UTC

[PR] net/tcp: Close the connection when keep-alive probes fail. [nuttx]

raiden00pl opened a new pull request, #20876:
URL: https://github.com/apache/nuttx/pull/20876

   
   ## Summary
   
   net/tcp: Close the connection when keep-alive probes fail.
       
   tcp_timer() only sent TCP_ABORT to the socket and left the connection open.  POSIX XSH 2.10.16: "if SO_KEEPALIVE is enabled and the connected socket fails to respond to the keep-alive messages, the connection shall be broken".  Close it like a retransmission timeout and return ETIMEDOUT from recv(), defined for a connection that "timed out ...  due to a transmission timeout on active connection".
   
   ## Impact
   
   fix SO_KEEPALIVE
   
   ## Testing
   
   Tested with https://github.com/railab/nuttx-testlab (ntfc/tests/ip/test_ip_tcp.py) on qemu-armv8a, rv-virt and qemu-intel64.                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                    
   Test: a NuttX node holds a TCP connection to the host with SO_KEEPALIVE and short TCP_KEEPIDLE/TCP_KEEPINTVL/TCP_KEEPCNT.  The host then drops all packets from the node, so the keep-alive probes are not answered.                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                    
   Before: after the last probe the node sends a RST but the connection stays ESTABLISHED.  A blocked recv() fails with ENOTCONN, poll() sets SO_ERROR to ECONNREFUSED, and close() sends a FIN after the RST and keeps retransmitting it, so the connection stays in the table (LAST_ACK/FIN_WAIT_1).                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                    
   After: the connection is closed after the RST.  recv() fails with ETIMEDOUT, poll() sets SO_ERROR to ETIMEDOUT, close() sends nothing and the connection is freed.                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                    
   


-- 
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


Re: [PR] net/tcp: Close the connection when keep-alive probes fail. [nuttx]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20876:
URL: https://github.com/apache/nuttx/pull/20876#issuecomment-6329115940

   <!-- membrowse-pr-comment -->
   ## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report &middot; [Explore what changed →](https://membrowse.com/public/apache/nuttx?commit_sha=dc11f9f89255b41248442f006dd8f9e0d775b069)
   
   
   *No memory changes detected for:*
   - [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=dc11f9f89255b41248442f006dd8f9e0d775b069&base=0dcbf44487dc1327e4932521e18a0e797dbfaf00)
   - [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=dc11f9f89255b41248442f006dd8f9e0d775b069&base=0dcbf44487dc1327e4932521e18a0e797dbfaf00)
   - [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=dc11f9f89255b41248442f006dd8f9e0d775b069&base=0dcbf44487dc1327e4932521e18a0e797dbfaf00)
   - [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=dc11f9f89255b41248442f006dd8f9e0d775b069&base=0dcbf44487dc1327e4932521e18a0e797dbfaf00)
   - [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=dc11f9f89255b41248442f006dd8f9e0d775b069&base=0dcbf44487dc1327e4932521e18a0e797dbfaf00)
   - [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=dc11f9f89255b41248442f006dd8f9e0d775b069&base=0dcbf44487dc1327e4932521e18a0e797dbfaf00)
   - [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=dc11f9f89255b41248442f006dd8f9e0d775b069&base=0dcbf44487dc1327e4932521e18a0e797dbfaf00)
   - [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=dc11f9f89255b41248442f006dd8f9e0d775b069&base=0dcbf44487dc1327e4932521e18a0e797dbfaf00)
   - [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=dc11f9f89255b41248442f006dd8f9e0d775b069&base=0dcbf44487dc1327e4932521e18a0e797dbfaf00)
   
   ---
   <sub>Catch memory regressions in CI with [MemBrowse](https://membrowse.com). Free for open source.</sub>
   


-- 
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


Re: [PR] net/tcp: Close the connection when keep-alive probes fail. [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #20876:
URL: https://github.com/apache/nuttx/pull/20876


-- 
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