Author: tuexen
Date: Sat Aug 29 06:55:10 2020
New Revision: 364948
URL: https://svnweb.freebsd.org/changeset/base/364948

Log:
  MFC r364937:
  Fix a regression with the explicit EOR mode I introduced in r364268.

Modified:
  stable/11/sys/netinet/sctp_output.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netinet/sctp_output.c
==============================================================================
--- stable/11/sys/netinet/sctp_output.c Sat Aug 29 06:54:39 2020        
(r364947)
+++ stable/11/sys/netinet/sctp_output.c Sat Aug 29 06:55:10 2020        
(r364948)
@@ -13202,11 +13202,10 @@ skip_preblock:
                        error = EINVAL;
                        goto out;
                }
-               SCTP_TCB_SEND_UNLOCK(stcb);
-
                strm = &stcb->asoc.strmout[srcv->sinfo_stream];
                if (strm->last_msg_incomplete == 0) {
        do_a_copy_in:
+                       SCTP_TCB_SEND_UNLOCK(stcb);
                        sp = sctp_copy_it_in(stcb, asoc, srcv, uio, net, 
max_len, user_marks_eor, &error);
                        if (error) {
                                goto out;
@@ -13235,19 +13234,8 @@ skip_preblock:
                        sp->processing = 1;
                        TAILQ_INSERT_TAIL(&strm->outqueue, sp, next);
                        stcb->asoc.ss_functions.sctp_ss_add_to_stream(stcb, 
asoc, strm, sp, 1);
-                       SCTP_TCB_SEND_UNLOCK(stcb);
                } else {
-                       SCTP_TCB_SEND_LOCK(stcb);
                        sp = TAILQ_LAST(&strm->outqueue, sctp_streamhead);
-                       if (sp->processing) {
-                               SCTP_TCB_SEND_UNLOCK(stcb);
-                               SCTP_LTRACE_ERR_RET(inp, stcb, net, 
SCTP_FROM_SCTP_OUTPUT, EINVAL);
-                               error = EINVAL;
-                               goto out;
-                       } else {
-                               sp->processing = 1;
-                       }
-                       SCTP_TCB_SEND_UNLOCK(stcb);
                        if (sp == NULL) {
                                /* ???? Huh ??? last msg is gone */
 #ifdef INVARIANTS
@@ -13259,7 +13247,16 @@ skip_preblock:
                                goto do_a_copy_in;
 
                        }
+                       if (sp->processing) {
+                               SCTP_TCB_SEND_UNLOCK(stcb);
+                               SCTP_LTRACE_ERR_RET(inp, stcb, net, 
SCTP_FROM_SCTP_OUTPUT, EINVAL);
+                               error = EINVAL;
+                               goto out;
+                       } else {
+                               sp->processing = 1;
+                       }
                }
+               SCTP_TCB_SEND_UNLOCK(stcb);
                while (uio->uio_resid > 0) {
                        /* How much room do we have? */
                        struct mbuf *new_tail, *mm;
@@ -13284,6 +13281,11 @@ skip_preblock:
                                        if (mm) {
                                                sctp_m_freem(mm);
                                        }
+                                       SCTP_TCB_SEND_LOCK(stcb);
+                                       if (sp != NULL) {
+                                               sp->processing = 0;
+                                       }
+                                       SCTP_TCB_SEND_UNLOCK(stcb);
                                        goto out;
                                }
                                /* Update the mbuf and count */
@@ -13299,6 +13301,9 @@ skip_preblock:
                                                SCTP_LTRACE_ERR_RET(NULL, stcb, 
NULL, SCTP_FROM_SCTP_OUTPUT, ECONNRESET);
                                                error = ECONNRESET;
                                        }
+                                       if (sp != NULL) {
+                                               sp->processing = 0;
+                                       }
                                        SCTP_TCB_SEND_UNLOCK(stcb);
                                        goto out;
                                }
@@ -13358,6 +13363,11 @@ skip_preblock:
                        /* wait for space now */
                        if (non_blocking) {
                                /* Non-blocking io in place out */
+                               SCTP_TCB_SEND_LOCK(stcb);
+                               if (sp != NULL) {
+                                       sp->processing = 0;
+                               }
+                               SCTP_TCB_SEND_UNLOCK(stcb);
                                goto skip_out_eof;
                        }
                        /* What about the INIT, send it maybe */
@@ -13481,6 +13491,11 @@ skip_preblock:
                                                }
                                        }
                                        SOCKBUF_UNLOCK(&so->so_snd);
+                                       SCTP_TCB_SEND_LOCK(stcb);
+                                       if (sp != NULL) {
+                                               sp->processing = 0;
+                                       }
+                                       SCTP_TCB_SEND_UNLOCK(stcb);
                                        goto out_unlocked;
                                }
 
@@ -13490,9 +13505,15 @@ skip_preblock:
                                }
                        }
                        SOCKBUF_UNLOCK(&so->so_snd);
+                       SCTP_TCB_SEND_LOCK(stcb);
                        if (stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) {
+                               if (sp != NULL) {
+                                       sp->processing = 0;
+                               }
+                               SCTP_TCB_SEND_UNLOCK(stcb);
                                goto out_unlocked;
                        }
+                       SCTP_TCB_SEND_UNLOCK(stcb);
                }
                SCTP_TCB_SEND_LOCK(stcb);
                if ((stcb->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) ||
_______________________________________________
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