Commit 2c89791e authored by Xin Long's avatar Xin Long Committed by David S. Miller

sctp: remove the unnecessary state check in sctp_outq_tail

Data Chunks are only sent by sctp_primitive_SEND, in which sctp checks
the asoc's state through statetable before calling sctp_outq_tail. So
there's no need to check the asoc's state again in sctp_outq_tail.

Besides, sctp_do_sm is protected by lock_sock, even if sending msg is
interrupted by timer events, the event's processes still need to acquire
lock_sock first. It means no others CMDs can be enqueue into side effect
list before CMD_SEND_MSG to change asoc->state, so it's safe to remove it.

This patch is to remove redundant asoc->state check from sctp_outq_tail.
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fd9527f4
...@@ -299,50 +299,25 @@ int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk, gfp_t gfp) ...@@ -299,50 +299,25 @@ int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk, gfp_t gfp)
* immediately. * immediately.
*/ */
if (sctp_chunk_is_data(chunk)) { if (sctp_chunk_is_data(chunk)) {
/* Is it OK to queue data chunks? */ pr_debug("%s: outqueueing: outq:%p, chunk:%p[%s])\n",
/* From 9. Termination of Association __func__, q, chunk, chunk && chunk->chunk_hdr ?
* sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)) :
* When either endpoint performs a shutdown, the "illegal chunk");
* association on each peer will stop accepting new
* data from its user and only deliver data in queue sctp_chunk_hold(chunk);
* at the time of sending or receiving the SHUTDOWN sctp_outq_tail_data(q, chunk);
* chunk. if (chunk->asoc->prsctp_enable &&
*/ SCTP_PR_PRIO_ENABLED(chunk->sinfo.sinfo_flags))
switch (q->asoc->state) { chunk->asoc->sent_cnt_removable++;
case SCTP_STATE_CLOSED: if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED)
case SCTP_STATE_SHUTDOWN_PENDING: SCTP_INC_STATS(net, SCTP_MIB_OUTUNORDERCHUNKS);
case SCTP_STATE_SHUTDOWN_SENT: else
case SCTP_STATE_SHUTDOWN_RECEIVED: SCTP_INC_STATS(net, SCTP_MIB_OUTORDERCHUNKS);
case SCTP_STATE_SHUTDOWN_ACK_SENT:
/* Cannot send after transport endpoint shutdown */
error = -ESHUTDOWN;
break;
default:
pr_debug("%s: outqueueing: outq:%p, chunk:%p[%s])\n",
__func__, q, chunk, chunk && chunk->chunk_hdr ?
sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)) :
"illegal chunk");
sctp_chunk_hold(chunk);
sctp_outq_tail_data(q, chunk);
if (chunk->asoc->prsctp_enable &&
SCTP_PR_PRIO_ENABLED(chunk->sinfo.sinfo_flags))
chunk->asoc->sent_cnt_removable++;
if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED)
SCTP_INC_STATS(net, SCTP_MIB_OUTUNORDERCHUNKS);
else
SCTP_INC_STATS(net, SCTP_MIB_OUTORDERCHUNKS);
break;
}
} else { } else {
list_add_tail(&chunk->list, &q->control_chunk_list); list_add_tail(&chunk->list, &q->control_chunk_list);
SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
} }
if (error < 0)
return error;
if (!q->cork) if (!q->cork)
error = sctp_outq_flush(q, 0, gfp); error = sctp_outq_flush(q, 0, gfp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment