Author: tuexen
Date: Fri Sep  9 13:52:37 2011
New Revision: 225462
URL: http://svn.freebsd.org/changeset/base/225462

Log:
  Improve implementation of the Nagle algorithm for SCTP:
  Don't delay the final fragment of a fragmented user message.
  
  Approved by: re
  MFC after: 4 weeks

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==============================================================================
--- head/sys/netinet/sctp_output.c      Fri Sep  9 11:59:59 2011        
(r225461)
+++ head/sys/netinet/sctp_output.c      Fri Sep  9 13:52:37 2011        
(r225462)
@@ -9821,19 +9821,22 @@ sctp_chunk_output(struct sctp_inpcb *inp
        unsigned int burst_cnt = 0;
        struct timeval now;
        int now_filled = 0;
-       int nagle_on = 0;
+       int nagle_on;
        int frag_point = sctp_get_frag_point(stcb, &stcb->asoc);
        int un_sent = 0;
        int fr_done;
        unsigned int tot_frs = 0;
 
        asoc = &stcb->asoc;
+       /* The Nagle algorithm is only applied when handling a send call. */
        if (from_where == SCTP_OUTPUT_FROM_USR_SEND) {
                if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NODELAY)) {
                        nagle_on = 0;
                } else {
                        nagle_on = 1;
                }
+       } else {
+               nagle_on = 0;
        }
        SCTP_TCB_LOCK_ASSERT(stcb);
 
@@ -10007,15 +10010,18 @@ sctp_chunk_output(struct sctp_inpcb *inp
                        }
                }
                if (nagle_on) {
-                       /*-
-                        * When nagle is on, we look at how much is un_sent, 
then
-                        * if its smaller than an MTU and we have data in
-                        * flight we stop.
+                       /*
+                        * When the Nagle algorithm is used, look at how
+                        * much is unsent, then if its smaller than an MTU
+                        * and we have data in flight we stop, except if we
+                        * are handling a fragmented user message.
                         */
                        un_sent = ((stcb->asoc.total_output_queue_size - 
stcb->asoc.total_flight) +
                            (stcb->asoc.stream_queue_cnt * sizeof(struct 
sctp_data_chunk)));
                        if ((un_sent < (int)(stcb->asoc.smallest_mtu - 
SCTP_MIN_OVERHEAD)) &&
-                           (stcb->asoc.total_flight > 0)) {
+                           (stcb->asoc.total_flight > 0) &&
+                           ((stcb->asoc.locked_on_sending == NULL) ||
+                           sctp_is_feature_on(inp, 
SCTP_PCB_FLAGS_EXPLICIT_EOR))) {
                                break;
                        }
                }
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to