Author: tuexen
Date: Thu Sep 10 11:43:23 2020
New Revision: 365561
URL: https://svnweb.freebsd.org/changeset/base/365561

Log:
  MFC r361750:
  
  Restrict enabling TCP-FASTOPEN to end-points in CLOSED or LISTEN state
  
  Enabling TCP-FASTOPEN on an end-point which is in a state other than
  CLOSED or LISTEN, is a bug in the application. So it should not work.
  Also the TCP code does not (and needs not to) handle this.
  While there, also simplify the setting of the TF_FASTOPEN flag.

Modified:
  stable/12/sys/netinet/tcp_usrreq.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/tcp_usrreq.c
==============================================================================
--- stable/12/sys/netinet/tcp_usrreq.c  Thu Sep 10 10:49:59 2020        
(r365560)
+++ stable/12/sys/netinet/tcp_usrreq.c  Thu Sep 10 11:43:23 2020        
(r365561)
@@ -2082,6 +2082,11 @@ unlock_and_done:
                                return (error);
 
                        INP_WLOCK_RECHECK(inp);
+                       if ((tp->t_state != TCPS_CLOSED) &&
+                           (tp->t_state != TCPS_LISTEN)) {
+                               error = EINVAL;
+                               goto unlock_and_done;
+                       }
                        if (tfo_optval.enable) {
                                if (tp->t_state == TCPS_LISTEN) {
                                        if (!V_tcp_fastopen_server_enable) {
@@ -2089,7 +2094,6 @@ unlock_and_done:
                                                goto unlock_and_done;
                                        }
 
-                                       tp->t_flags |= TF_FASTOPEN;
                                        if (tp->t_tfo_pending == NULL)
                                                tp->t_tfo_pending =
                                                    
tcp_fastopen_alloc_counter();
@@ -2108,8 +2112,8 @@ unlock_and_done:
                                                tp->t_tfo_client_cookie_len =
                                                    TCP_FASTOPEN_PSK_LEN;
                                        }
-                                       tp->t_flags |= TF_FASTOPEN;
                                }
+                               tp->t_flags |= TF_FASTOPEN;
                        } else
                                tp->t_flags &= ~TF_FASTOPEN;
                        goto unlock_and_done;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to