]> Pileus Git - ~andy/linux/commitdiff
sctp: Fix piggybacked ACKs
authorDoug Graham <dgraham@nortel.com>
Wed, 29 Jul 2009 16:05:57 +0000 (12:05 -0400)
committerVlad Yasevich <vladislav.yasevich@hp.com>
Fri, 4 Sep 2009 22:20:55 +0000 (18:20 -0400)
This patch corrects the conditions under which a SACK will be piggybacked
on a DATA packet.  The previous condition was incorrect due to a
misinterpretation of RFC 4960 and/or RFC 2960.  Specifically, the
following paragraph from section 6.2 had not been implemented correctly:

   Before an endpoint transmits a DATA chunk, if any received DATA
   chunks have not been acknowledged (e.g., due to delayed ack), the
   sender should create a SACK and bundle it with the outbound DATA
   chunk, as long as the size of the final SCTP packet does not exceed
   the current MTU.  See Section 6.2.

When about to send a DATA chunk, the code now checks to see if the SACK
timer is running.  If it is, we know we have a SACK to send to the
peer, so we append the SACK (assuming available space in the packet)
and turn off the timer.  For a simple request-response scenario, this
will result in the SACK being bundled with the response, meaning the
the SACK is received quickly by the client, and also meaning that no
separate SACK packet needs to be sent by the server to acknowledge the
request.  Prior to this patch, a separate SACK packet would have been
sent by the server SCTP only after its delayed-ACK timer had expired
(usually 200ms).  This is wasteful of bandwidth, and can also have a
major negative impact on performance due the interaction of delayed ACKs
with the Nagle algorithm.

Signed-off-by: Doug Graham <dgraham@nortel.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
net/sctp/output.c

index b94c2119056661aaa61073a29bd429f069f7923f..94c110dcaf1d10151d0a69a11bdf3fb6c68e2cbc 100644 (file)
@@ -234,18 +234,19 @@ static sctp_xmit_t sctp_packet_bundle_sack(struct sctp_packet *pkt,
        if (sctp_chunk_is_data(chunk) && !pkt->has_sack &&
            !pkt->has_cookie_echo) {
                struct sctp_association *asoc;
+               struct timer_list *timer;
                asoc = pkt->transport->asoc;
+               timer = &asoc->timers[SCTP_EVENT_TIMEOUT_SACK];
 
-               if (asoc->a_rwnd > asoc->rwnd) {
+               /* If the SACK timer is running, we have a pending SACK */
+               if (timer_pending(timer)) {
                        struct sctp_chunk *sack;
                        asoc->a_rwnd = asoc->rwnd;
                        sack = sctp_make_sack(asoc);
                        if (sack) {
-                               struct timer_list *timer;
                                retval = sctp_packet_append_chunk(pkt, sack);
                                asoc->peer.sack_needed = 0;
-                               timer = &asoc->timers[SCTP_EVENT_TIMEOUT_SACK];
-                               if (timer_pending(timer) && del_timer(timer))
+                               if (del_timer(timer))
                                        sctp_association_put(asoc);
                        }
                }