Commit 4fdbb0ef authored by Marcelo Ricardo Leitner's avatar Marcelo Ricardo Leitner Committed by 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: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment