Hi.

>> > I think sendig FIN is required when closing SYN_RECV connections
>> > even if they are on a backlog-queue(sk->tp_pinfo.af_tcp.syn_wait_queue), 
>> > but Linux releases SYN_RECV connections without anything.
>> > Or it would not be bad idea to send reset (RST) to the peer
>> > than doing nothing.
>> 
>> RST is not good when the SYN-RECV ACK has not been received yet -- you
>> risk killing innocent connections because only after the three way handshake
>> you're fully synchronized. FIN is not good neither. For Established sockets
>> we already do the right thing.
>> 
>> -Andi

No risk there.
It is easy to specify the peer to send RST/FIN and it doesn't matter 
that the peer is SYN-SENT or ESTABLISHED.
The information of the peer -- inetaddress,port,seq ... -- is contained 
in the open_request. 
If a SYN-SENT socket receives RST, status of the socket turns into CLOSE
and make an ECONNREFUSED error.
If a ESTABLISHED socket receives RST, status of the socket turns into CLOSE
and make an ECONNRESET error.

RFC916 says:

RFC916> 5.2.3. SYN-RECEIVED
RFC916>
RFC916>    Arrived at from the LISTEN and SYN-SENT states in response to
RFC916>    an arriving SYN packet.
RFC916>
RFC916>    Departures
RFC916>
RFC916>       - A CLOSE request is made by the user.  Create a packet with
RFC916>         FIN set.  Send it and go to the FIN-WAIT state.

And here is a state diagram of tcp-connection.
We can see how SYN-RECV connection should work.

                                   
                              +---------+ ---------\      active OPEN  
                              |  CLOSED |            \    -----------  
                              +---------+<---------\   \   create TCB  
                                |     ^              \   \  snd SYN    
                   passive OPEN |     |   CLOSE        \   \           
                   ------------ |     | ----------       \   \         
                    create TCB  |     | delete TCB         \   \       
                                V     |                      \   \     
                              +---------+            CLOSE    |    \   
                              |  LISTEN |          ---------- |     |  
                              +---------+          delete TCB |     |  
                   rcv SYN      |     |     SEND              |     |  
                  -----------   |     |    -------            |     V  
 +---------+      snd SYN,ACK  /       \   snd SYN          +---------+
 |         |<-----------------           ------------------>|         |
 |   SYN   |                    rcv SYN                     |   SYN   |
 |   RCVD  |<-----------------------------------------------|   SENT  |
 |         |                    snd ACK                     |         |
 |         |------------------           -------------------|         |
 +---------+   rcv ACK of SYN  \       /  rcv SYN,ACK       +---------+
   |           --------------   |     |   -----------                  
   |                  x         |     |     snd ACK                    
   |                            V     V                                
   |  CLOSE                   +---------+                              
   | -------                  |  ESTAB  |                              
   | snd FIN                  +---------+                              
   |                   CLOSE    |     |    rcv FIN                     
   V                  -------   |     |    -------                     
 +---------+          snd FIN  /       \   snd ACK          +---------+
 |  FIN    |<-----------------           ------------------>|  CLOSE  |
 | WAIT-1  |------------------                              |   WAIT  |
 +---------+          rcv FIN  \                            +---------+
   | rcv ACK of FIN   -------   |                            CLOSE  |  
   | --------------   snd ACK   |                           ------- |  
   V        x                   V                           snd FIN V  
 +---------+                  +---------+                   +---------+
 |FINWAIT-2|                  | CLOSING |                   | LAST-ACK|
 +---------+                  +---------+                   +---------+
   |                rcv ACK of FIN |                 rcv ACK of FIN |  
   |  rcv FIN       -------------- |    Timeout=2MSL -------------- |  
   |  -------              x       V    ------------        x       V  
    \ snd ACK                 +---------+delete TCB         +---------+
     ------------------------>|TIME WAIT|------------------>| CLOSED  |
                              +---------+                   +---------+

-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to