sctp: Correctly track if AUTH has been bundled.
[safe/jmp/linux-2.6] / net / sctp / output.c
index d0b84f6..e47398c 100644 (file)
@@ -136,6 +136,17 @@ struct sctp_packet *sctp_packet_init(struct sctp_packet *packet,
        return packet;
 }
 
+static void sctp_packet_reset(struct sctp_packet *packet)
+{
+       packet->size = packet->overhead;
+       packet->has_cookie_echo = 0;
+       packet->has_sack = 0;
+       packet->has_data = 0;
+       packet->has_auth = 0;
+       packet->ipfragok = 0;
+       packet->auth = NULL;
+}
+
 /* Free a packet.  */
 void sctp_packet_free(struct sctp_packet *packet)
 {
@@ -209,7 +220,7 @@ static sctp_xmit_t sctp_packet_bundle_auth(struct sctp_packet *pkt,
        /* See if this is an auth chunk we are bundling or if
         * auth is already bundled.
         */
-       if (chunk->chunk_hdr->type == SCTP_CID_AUTH || pkt->auth)
+       if (chunk->chunk_hdr->type == SCTP_CID_AUTH || pkt->has_auth)
                return retval;
 
        /* if the peer did not request this chunk to be authenticated,
@@ -576,7 +587,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
        (*tp->af_specific->sctp_xmit)(nskb, tp);
 
 out:
-       packet->size = packet->overhead;
+       sctp_packet_reset(packet);
        return err;
 no_route:
        kfree_skb(nskb);
@@ -703,8 +714,10 @@ static sctp_xmit_t sctp_packet_can_append_data(struct sctp_packet *packet,
                /* Check whether this chunk and all the rest of pending
                 * data will fit or delay in hopes of bundling a full
                 * sized packet.
+                * Don't delay large message writes that may have been
+                * fragmeneted into small peices.
                 */
-               if (len < max) {
+               if ((len < max) && (chunk->msg->msg_size < max)) {
                        retval = SCTP_XMIT_NAGLE_DELAY;
                        goto finish;
                }