Skip to content

Commit

Permalink
sctp: add support for MSG_MORE
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
lxin authored and davem330 committed Feb 20, 2017
1 parent b7018d0 commit 4ea0c32
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/net/sctp/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ struct sctp_datamsg {
/* Did the messenge fail to send? */
int send_error;
u8 send_failed:1,
force_delay:1,
can_delay; /* should this message be Nagle delayed */
};

Expand Down
9 changes: 3 additions & 6 deletions net/sctp/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,18 +704,15 @@ static sctp_xmit_t sctp_packet_can_append_data(struct sctp_packet *packet,
* unacknowledged.
*/

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

if (!sctp_packet_empty(packet))
/* Append to packet */
return SCTP_XMIT_OK;

if (inflight == 0)
/* Nothing unacked */
return SCTP_XMIT_OK;

if (!sctp_state(asoc, ESTABLISHED))
return SCTP_XMIT_OK;

Expand Down
1 change: 1 addition & 0 deletions net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,7 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
err = PTR_ERR(datamsg);
goto out_free;
}
datamsg->force_delay = !!(msg->msg_flags & MSG_MORE);

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

0 comments on commit 4ea0c32

Please sign in to comment.