Skip to content

Commit 4ea0c32

Browse files
lxindavem330
authored andcommitted
sctp: add support for MSG_MORE
This patch is to add support for MSG_MORE on sctp. It adds force_delay in sctp_datamsg to save MSG_MORE, and sets it after creating datamsg according to the send flag. sctp_packet_can_append_data then uses it to decide if the chunks of this msg will be sent at once or delay it. Note that unlike [1], this patch saves MSG_MORE in datamsg, instead of in assoc. As sctp enqueues the chunks first, then dequeue them one by one. If it's saved in assoc,the current msg's send flag (MSG_MORE) may affect other chunks' bundling. Since last patch, sctp flush out queue once assoc state falls into SHUTDOWN_PENDING, the close block problem mentioned in [1] has been solved as well. [1] https://patchwork.ozlabs.org/patch/372404/ Signed-off-by: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b7018d0 commit 4ea0c32

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

include/net/sctp/structs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ struct sctp_datamsg {
497497
/* Did the messenge fail to send? */
498498
int send_error;
499499
u8 send_failed:1,
500+
force_delay:1,
500501
can_delay; /* should this message be Nagle delayed */
501502
};
502503

net/sctp/output.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -704,18 +704,15 @@ static sctp_xmit_t sctp_packet_can_append_data(struct sctp_packet *packet,
704704
* unacknowledged.
705705
*/
706706

707-
if (sctp_sk(asoc->base.sk)->nodelay)
708-
/* Nagle disabled */
707+
if ((sctp_sk(asoc->base.sk)->nodelay || inflight == 0) &&
708+
!chunk->msg->force_delay)
709+
/* Nothing unacked */
709710
return SCTP_XMIT_OK;
710711

711712
if (!sctp_packet_empty(packet))
712713
/* Append to packet */
713714
return SCTP_XMIT_OK;
714715

715-
if (inflight == 0)
716-
/* Nothing unacked */
717-
return SCTP_XMIT_OK;
718-
719716
if (!sctp_state(asoc, ESTABLISHED))
720717
return SCTP_XMIT_OK;
721718

net/sctp/socket.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,6 +1964,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
19641964
err = PTR_ERR(datamsg);
19651965
goto out_free;
19661966
}
1967+
datamsg->force_delay = !!(msg->msg_flags & MSG_MORE);
19671968

19681969
/* Now send the (possibly) fragmented message. */
19691970
list_for_each_entry(chunk, &datamsg->chunks, frag_list) {

0 commit comments

Comments
 (0)