提交 4fdbb0ef 编写于 作者: M Marcelo Ricardo Leitner 提交者: David S. Miller

sctp: rework switch cases in sctp_outq_flush_data

Remove an inner one, which tended to be error prone due to the cascading
and it can be replaced by a simple if ().

Rework the outer one so that the actual flush code is not inside it. Now
we first validate if we can or cannot send data, return if not, and then
the flush code.
Suggested-by: NXin Long <lucien.xin@gmail.com>
Signed-off-by: NMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6605f694
......@@ -1058,12 +1058,19 @@ static void sctp_outq_flush_data(struct sctp_outq *q,
* chunk.
*/
if (!packet || !packet->has_cookie_echo)
break;
return;
/* fallthru */
case SCTP_STATE_ESTABLISHED:
case SCTP_STATE_SHUTDOWN_PENDING:
case SCTP_STATE_SHUTDOWN_RECEIVED:
break;
default:
/* Do nothing. */
return;
}
/*
* RFC 2960 6.1 Transmission of DATA Chunks
*
......@@ -1076,7 +1083,7 @@ static void sctp_outq_flush_data(struct sctp_outq *q,
if (!list_empty(&q->retransmit)) {
if (!sctp_outq_flush_rtx(q, _transport, transport_list,
rtx_timeout, gfp))
break;
return;
/* We may have switched current transport */
transport = *_transport;
packet = &transport->packet;
......@@ -1123,13 +1130,7 @@ static void sctp_outq_flush_data(struct sctp_outq *q,
/* Add the chunk to the packet. */
status = sctp_packet_transmit_chunk(packet, chunk, 0, gfp);
switch (status) {
case SCTP_XMIT_OK:
break;
case SCTP_XMIT_PMTU_FULL:
case SCTP_XMIT_RWND_FULL:
case SCTP_XMIT_DELAY:
if (status != SCTP_XMIT_OK) {
/* We could not append this chunk, so put
* the chunk back on the output queue.
*/
......@@ -1138,7 +1139,7 @@ static void sctp_outq_flush_data(struct sctp_outq *q,
status);
sctp_outq_head_data(q, chunk);
return;
break;
}
/* The sender is in the SHUTDOWN-PENDING state,
......@@ -1169,12 +1170,6 @@ static void sctp_outq_flush_data(struct sctp_outq *q,
if (packet->has_cookie_echo)
break;
}
break;
default:
/* Do nothing. */
break;
}
}
static void sctp_outq_flush_transports(struct sctp_outq *q,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册