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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to