commit c7be5d98b7b760dcd071415f018ee31312372ef5 Author: Vlad Yasevich Date: Tue Sep 8 14:39:47 2009 -0400 sctp: Tag messages that can be Nagle delayed at creation. When we create the sctp_datamsg and fragment the user data, we know exactly if we are sending full segments or not and how they might be bundled. During this time, we can mark messages a Nagle capable or not. This makes the check at transmit time much simpler. Signed-off-by: Vlad Yasevich diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 42d00ce..103e748 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -645,9 +645,9 @@ struct sctp_datamsg { unsigned long expires_at; /* Did the messenge fail to send? */ int send_error; - char send_failed; - /* Control whether chunks from this message can be abandoned. */ - char can_abandon; + u8 send_failed:1, + can_abandon:1, /* can chunks from this message can be abandoned. */ + can_delay; /* should this message be Nagle delayed */ }; struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *, diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c index acf7c4d..9de8643 100644 --- a/net/sctp/chunk.c +++ b/net/sctp/chunk.c @@ -57,6 +57,7 @@ static void sctp_datamsg_init(struct sctp_datamsg *msg) msg->send_failed = 0; msg->send_error = 0; msg->can_abandon = 0; + msg->can_delay = 1; msg->expires_at = 0; INIT_LIST_HEAD(&msg->chunks); msg->msg_size = 0; @@ -230,8 +231,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc, */ if (timer_pending(&asoc->timers[SCTP_EVENT_TIMEOUT_SACK]) && asoc->outqueue.out_qlen == 0 && - list_empty(&asoc->outqueue.retransmit) && - msg_len > max) + list_empty(&asoc->outqueue.retransmit)) max_data -= WORD_ROUND(sizeof(sctp_sack_chunk_t)); /* Encourage Cookie-ECHO bundling. */ @@ -246,6 +246,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc, if (msg_len >= first_len) { msg_len -= first_len; whole = 1; + msg->can_delay = 0; } /* How many full sized? How many bytes leftover? */ diff --git a/net/sctp/output.c b/net/sctp/output.c index 5cbda8f..36bd0fd 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c @@ -706,7 +706,7 @@ static sctp_xmit_t sctp_packet_can_append_data(struct sctp_packet *packet, * Don't delay large message writes that may have been * fragmeneted into small peices. */ - if ((len < max) && (chunk->msg->msg_size < max)) { + if ((len < max) && chunk->msg->can_delay) { retval = SCTP_XMIT_NAGLE_DELAY; goto finish; }