Release 4.11 net/sctp/outqueue.c
/* SCTP kernel implementation
* (C) Copyright IBM Corp. 2001, 2004
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
* Copyright (c) 2001-2003 Intel Corp.
*
* This file is part of the SCTP kernel implementation
*
* These functions implement the sctp_outq class. The outqueue handles
* bundling and queueing of outgoing SCTP chunks.
*
* This SCTP implementation is free software;
* you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This SCTP implementation is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
* ************************
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU CC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
* Please send any bug reports or fixes you make to the
* email address(es):
* lksctp developers <linux-sctp@vger.kernel.org>
*
* Written or modified by:
* La Monte H.P. Yarroll <piggy@acm.org>
* Karl Knutson <karl@athena.chicago.il.us>
* Perry Melange <pmelange@null.cc.uic.edu>
* Xingang Guo <xingang.guo@intel.com>
* Hui Huang <hui.huang@nokia.com>
* Sridhar Samudrala <sri@us.ibm.com>
* Jon Grimm <jgrimm@us.ibm.com>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/types.h>
#include <linux/list.h> /* For struct list_head */
#include <linux/socket.h>
#include <linux/ip.h>
#include <linux/slab.h>
#include <net/sock.h> /* For skb_set_owner_w */
#include <net/sctp/sctp.h>
#include <net/sctp/sm.h>
/* Declare internal functions here. */
static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn);
static void sctp_check_transmitted(struct sctp_outq *q,
struct list_head *transmitted_queue,
struct sctp_transport *transport,
union sctp_addr *saddr,
struct sctp_sackhdr *sack,
__u32 *highest_new_tsn);
static void sctp_mark_missing(struct sctp_outq *q,
struct list_head *transmitted_queue,
struct sctp_transport *transport,
__u32 highest_new_tsn,
int count_of_newacks);
static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 sack_ctsn);
static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp);
/* Add data to the front of the queue. */
static inline void sctp_outq_head_data(struct sctp_outq *q,
struct sctp_chunk *ch)
{
list_add(&ch->list, &q->out_chunk_list);
q->out_qlen += ch->skb->len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 33 | 82.50% | 1 | 50.00% |
David S. Miller | 7 | 17.50% | 1 | 50.00% |
Total | 40 | 100.00% | 2 | 100.00% |
/* Take data from the front of the queue. */
static inline struct sctp_chunk *sctp_outq_dequeue_data(struct sctp_outq *q)
{
struct sctp_chunk *ch = NULL;
if (!list_empty(&q->out_chunk_list)) {
struct list_head *entry = q->out_chunk_list.next;
ch = list_entry(entry, struct sctp_chunk, list);
list_del_init(entry);
q->out_qlen -= ch->skb->len;
}
return ch;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 39 | 52.00% | 1 | 50.00% |
David S. Miller | 36 | 48.00% | 1 | 50.00% |
Total | 75 | 100.00% | 2 | 100.00% |
/* Add data chunk to the end of the queue. */
static inline void sctp_outq_tail_data(struct sctp_outq *q,
struct sctp_chunk *ch)
{
list_add_tail(&ch->list, &q->out_chunk_list);
q->out_qlen += ch->skb->len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 33 | 82.50% | 1 | 50.00% |
David S. Miller | 7 | 17.50% | 1 | 50.00% |
Total | 40 | 100.00% | 2 | 100.00% |
/*
* SFR-CACC algorithm:
* D) If count_of_newacks is greater than or equal to 2
* and t was not sent to the current primary then the
* sender MUST NOT increment missing report count for t.
*/
static inline int sctp_cacc_skip_3_1_d(struct sctp_transport *primary,
struct sctp_transport *transport,
int count_of_newacks)
{
if (count_of_newacks >= 2 && transport != primary)
return 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 36 | 100.00% | 1 | 100.00% |
Total | 36 | 100.00% | 1 | 100.00% |
/*
* SFR-CACC algorithm:
* F) If count_of_newacks is less than 2, let d be the
* destination to which t was sent. If cacc_saw_newack
* is 0 for destination d, then the sender MUST NOT
* increment missing report count for t.
*/
static inline int sctp_cacc_skip_3_1_f(struct sctp_transport *transport,
int count_of_newacks)
{
if (count_of_newacks < 2 &&
(transport && !transport->cacc.cacc_saw_newack))
return 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 34 | 89.47% | 1 | 50.00% |
Vladislav Yasevich | 4 | 10.53% | 1 | 50.00% |
Total | 38 | 100.00% | 2 | 100.00% |
/*
* SFR-CACC algorithm:
* 3.1) If CYCLING_CHANGEOVER is 0, the sender SHOULD
* execute steps C, D, F.
*
* C has been implemented in sctp_outq_sack
*/
static inline int sctp_cacc_skip_3_1(struct sctp_transport *primary,
struct sctp_transport *transport,
int count_of_newacks)
{
if (!primary->cacc.cycling_changeover) {
if (sctp_cacc_skip_3_1_d(primary, transport, count_of_newacks))
return 1;
if (sctp_cacc_skip_3_1_f(transport, count_of_newacks))
return 1;
return 0;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 63 | 100.00% | 1 | 100.00% |
Total | 63 | 100.00% | 1 | 100.00% |
/*
* SFR-CACC algorithm:
* 3.2) Else if CYCLING_CHANGEOVER is 1, and t is less
* than next_tsn_at_change of the current primary, then
* the sender MUST NOT increment missing report count
* for t.
*/
static inline int sctp_cacc_skip_3_2(struct sctp_transport *primary, __u32 tsn)
{
if (primary->cacc.cycling_changeover &&
TSN_lt(tsn, primary->cacc.next_tsn_at_change))
return 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 40 | 100.00% | 1 | 100.00% |
Total | 40 | 100.00% | 1 | 100.00% |
/*
* SFR-CACC algorithm:
* 3) If the missing report count for TSN t is to be
* incremented according to [RFC2960] and
* [SCTP_STEWART-2002], and CHANGEOVER_ACTIVE is set,
* then the sender MUST further execute steps 3.1 and
* 3.2 to determine if the missing report count for
* TSN t SHOULD NOT be incremented.
*
* 3.3) If 3.1 and 3.2 do not dictate that the missing
* report count for t should not be incremented, then
* the sender SHOULD increment missing report count for
* t (according to [RFC2960] and [SCTP_STEWART_2002]).
*/
static inline int sctp_cacc_skip(struct sctp_transport *primary,
struct sctp_transport *transport,
int count_of_newacks,
__u32 tsn)
{
if (primary->cacc.changeover_active &&
(sctp_cacc_skip_3_1(primary, transport, count_of_newacks) ||
sctp_cacc_skip_3_2(primary, tsn)))
return 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 55 | 100.00% | 1 | 100.00% |
Total | 55 | 100.00% | 1 | 100.00% |
/* Initialize an existing sctp_outq. This does the boring stuff.
* You still need to define handlers if you really want to DO
* something with this structure...
*/
void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
{
memset(q, 0, sizeof(struct sctp_outq));
q->asoc = asoc;
INIT_LIST_HEAD(&q->out_chunk_list);
INIT_LIST_HEAD(&q->control_chunk_list);
INIT_LIST_HEAD(&q->retransmit);
INIT_LIST_HEAD(&q->sacked);
INIT_LIST_HEAD(&q->abandoned);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 48 | 64.86% | 3 | 42.86% |
Neil Horman | 13 | 17.57% | 1 | 14.29% |
Sridhar Samudrala | 8 | 10.81% | 1 | 14.29% |
David S. Miller | 5 | 6.76% | 2 | 28.57% |
Total | 74 | 100.00% | 7 | 100.00% |
/* Free the outqueue structure and any related pending chunks.
*/
static void __sctp_outq_teardown(struct sctp_outq *q)
{
struct sctp_transport *transport;
struct list_head *lchunk, *temp;
struct sctp_chunk *chunk, *tmp;
/* Throw away unacknowledged chunks. */
list_for_each_entry(transport, &q->asoc->peer.transport_addr_list,
transports) {
while ((lchunk = sctp_list_dequeue(&transport->transmitted)) != NULL) {
chunk = list_entry(lchunk, struct sctp_chunk,
transmitted_list);
/* Mark as part of a failed message. */
sctp_chunk_fail(chunk, q->error);
sctp_chunk_free(chunk);
}
}
/* Throw away chunks that have been gap ACKed. */
list_for_each_safe(lchunk, temp, &q->sacked) {
list_del_init(lchunk);
chunk = list_entry(lchunk, struct sctp_chunk,
transmitted_list);
sctp_chunk_fail(chunk, q->error);
sctp_chunk_free(chunk);
}
/* Throw away any chunks in the retransmit queue. */
list_for_each_safe(lchunk, temp, &q->retransmit) {
list_del_init(lchunk);
chunk = list_entry(lchunk, struct sctp_chunk,
transmitted_list);
sctp_chunk_fail(chunk, q->error);
sctp_chunk_free(chunk);
}
/* Throw away any chunks that are in the abandoned queue. */
list_for_each_safe(lchunk, temp, &q->abandoned) {
list_del_init(lchunk);
chunk = list_entry(lchunk, struct sctp_chunk,
transmitted_list);
sctp_chunk_fail(chunk, q->error);
sctp_chunk_free(chunk);
}
/* Throw away any leftover data chunks. */
while ((chunk = sctp_outq_dequeue_data(q)) != NULL) {
/* Mark as send failure. */
sctp_chunk_fail(chunk, q->error);
sctp_chunk_free(chunk);
}
/* Throw away any leftover control chunks. */
list_for_each_entry_safe(chunk, tmp, &q->control_chunk_list, list) {
list_del_init(&chunk->list);
sctp_chunk_free(chunk);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 154 | 56.83% | 11 | 57.89% |
Sridhar Samudrala | 85 | 31.37% | 2 | 10.53% |
David S. Miller | 20 | 7.38% | 2 | 10.53% |
Robert P. J. Day | 4 | 1.48% | 1 | 5.26% |
Andrew Morton | 4 | 1.48% | 1 | 5.26% |
Neil Horman | 2 | 0.74% | 1 | 5.26% |
Rusty Russell | 2 | 0.74% | 1 | 5.26% |
Total | 271 | 100.00% | 19 | 100.00% |
void sctp_outq_teardown(struct sctp_outq *q)
{
__sctp_outq_teardown(q);
sctp_outq_init(q->asoc, q);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Neil Horman | 24 | 100.00% | 1 | 100.00% |
Total | 24 | 100.00% | 1 | 100.00% |
/* Free the outqueue structure and any related pending chunks. */
void sctp_outq_free(struct sctp_outq *q)
{
/* Throw away leftover chunks. */
__sctp_outq_teardown(q);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 14 | 87.50% | 2 | 50.00% |
David S. Miller | 1 | 6.25% | 1 | 25.00% |
Neil Horman | 1 | 6.25% | 1 | 25.00% |
Total | 16 | 100.00% | 4 | 100.00% |
/* Put a new chunk in an sctp_outq. */
void sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk, gfp_t gfp)
{
struct net *net = sock_net(q->asoc->base.sk);
pr_debug("%s: outq:%p, chunk:%p[%s]\n", __func__, q, chunk,
chunk && chunk->chunk_hdr ?
sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)) :
"illegal chunk");
/* If it is data, queue it up, otherwise, send it
* immediately.
*/
if (sctp_chunk_is_data(chunk)) {
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_outq_tail_data(q, chunk);
if (chunk->asoc->peer.prsctp_capable &&
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);
} else {
list_add_tail(&chunk->list, &q->control_chunk_list);
SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
}
if (!q->cork)
sctp_outq_flush(q, 0, gfp);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 100 | 49.26% | 5 | 31.25% |
Xin Long | 27 | 13.30% | 3 | 18.75% |
Sridhar Samudrala | 25 | 12.32% | 1 | 6.25% |
Eric W. Biedermann | 22 | 10.84% | 1 | 6.25% |
Daniel Borkmann | 10 | 4.93% | 1 | 6.25% |
David S. Miller | 8 | 3.94% | 2 | 12.50% |
Marcelo Ricardo Leitner | 5 | 2.46% | 1 | 6.25% |
Shan Wei | 3 | 1.48% | 1 | 6.25% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 1.48% | 1 | 6.25% |
Total | 203 | 100.00% | 16 | 100.00% |
/* Insert a chunk into the sorted list based on the TSNs. The retransmit list
* and the abandoned list are in ascending order.
*/
static void sctp_insert_list(struct list_head *head, struct list_head *new)
{
struct list_head *pos;
struct sctp_chunk *nchunk, *lchunk;
__u32 ntsn, ltsn;
int done = 0;
nchunk = list_entry(new, struct sctp_chunk, transmitted_list);
ntsn = ntohl(nchunk->subh.data_hdr->tsn);
list_for_each(pos, head) {
lchunk = list_entry(pos, struct sctp_chunk, transmitted_list);
ltsn = ntohl(lchunk->subh.data_hdr->tsn);
if (TSN_lt(ntsn, ltsn)) {
list_add(new, pos->prev);
done = 1;
break;
}
}
if (!done)
list_add_tail(new, head);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daisy Chang | 75 | 55.97% | 1 | 14.29% |
Jon Grimm | 32 | 23.88% | 3 | 42.86% |
Sridhar Samudrala | 26 | 19.40% | 2 | 28.57% |
David S. Miller | 1 | 0.75% | 1 | 14.29% |
Total | 134 | 100.00% | 7 | 100.00% |
static int sctp_prsctp_prune_sent(struct sctp_association *asoc,
struct sctp_sndrcvinfo *sinfo,
struct list_head *queue, int msg_len)
{
struct sctp_chunk *chk, *temp;
list_for_each_entry_safe(chk, temp, queue, transmitted_list) {
if (!SCTP_PR_PRIO_ENABLED(chk->sinfo.sinfo_flags) ||
chk->sinfo.sinfo_timetolive <= sinfo->sinfo_timetolive)
continue;
list_del_init(&chk->transmitted_list);
sctp_insert_list(&asoc->outqueue.abandoned,
&chk->transmitted_list);
asoc->sent_cnt_removable--;
asoc->abandoned_sent[SCTP_PR_INDEX(PRIO)]++;
if (!chk->tsn_gap_acked) {
if (chk->transport)
chk->transport->flight_size -=
sctp_data_size(chk);
asoc->outqueue.outstanding_bytes -= sctp_data_size(chk);
}
msg_len -= SCTP_DATA_SNDSIZE(chk) +
sizeof(struct sk_buff) +
sizeof(struct sctp_chunk);
if (msg_len <= 0)
break;
}
return msg_len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Xin Long | 172 | 100.00% | 2 | 100.00% |
Total | 172 | 100.00% | 2 | 100.00% |
static int sctp_prsctp_prune_unsent(struct sctp_association *asoc,
struct sctp_sndrcvinfo *sinfo, int msg_len)
{
struct sctp_outq *q = &asoc->outqueue;
struct sctp_chunk *chk, *temp;
list_for_each_entry_safe(chk, temp, &q->out_chunk_list, list) {
if (!SCTP_PR_PRIO_ENABLED(chk->sinfo.sinfo_flags) ||
chk->sinfo.sinfo_timetolive <= sinfo->sinfo_timetolive)
continue;
list_del_init(&chk->list);
q->out_qlen -= chk->skb->len;
asoc->sent_cnt_removable--;
asoc->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
msg_len -= SCTP_DATA_SNDSIZE(chk) +
sizeof(struct sk_buff) +
sizeof(struct sctp_chunk);
sctp_chunk_free(chk);
if (msg_len <= 0)
break;
}
return msg_len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Xin Long | 140 | 100.00% | 3 | 100.00% |
Total | 140 | 100.00% | 3 | 100.00% |
/* Abandon the chunks according their priorities */
void sctp_prsctp_prune(struct sctp_association *asoc,
struct sctp_sndrcvinfo *sinfo, int msg_len)
{
struct sctp_transport *transport;
if (!asoc->peer.prsctp_capable || !asoc->sent_cnt_removable)
return;
msg_len = sctp_prsctp_prune_sent(asoc, sinfo,
&asoc->outqueue.retransmit,
msg_len);
if (msg_len <= 0)
return;
list_for_each_entry(transport, &asoc->peer.transport_addr_list,
transports) {
msg_len = sctp_prsctp_prune_sent(asoc, sinfo,
&transport->transmitted,
msg_len);
if (msg_len <= 0)
return;
}
sctp_prsctp_prune_unsent(asoc, sinfo, msg_len);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Xin Long | 105 | 100.00% | 2 | 100.00% |
Total | 105 | 100.00% | 2 | 100.00% |
/* Mark all the eligible packets on a transport for retransmission. */
void sctp_retransmit_mark(struct sctp_outq *q,
struct sctp_transport *transport,
__u8 reason)
{
struct list_head *lchunk, *ltemp;
struct sctp_chunk *chunk;
/* Walk through the specified transmitted queue. */
list_for_each_safe(lchunk, ltemp, &transport->transmitted) {
chunk = list_entry(lchunk, struct sctp_chunk,
transmitted_list);
/* If the chunk is abandoned, move it to abandoned list. */
if (sctp_chunk_abandoned(chunk)) {
list_del_init(lchunk);
sctp_insert_list(&q->abandoned, lchunk);
/* If this chunk has not been previousely acked,
* stop considering it 'outstanding'. Our peer
* will most likely never see it since it will
* not be retransmitted
*/
if (!chunk->tsn_gap_acked) {
if (chunk->transport)
chunk->transport->flight_size -=
sctp_data_size(chunk);
q->outstanding_bytes -= sctp_data_size(chunk);
q->asoc->peer.rwnd += sctp_data_size(chunk);
}
continue;
}
/* If we are doing retransmission due to a timeout or pmtu
* discovery, only the chunks that are not yet acked should
* be added to the retransmit queue.
*/
if ((reason == SCTP_RTXR_FAST_RTX &&
(chunk->fast_retransmit == SCTP_NEED_FRTX)) ||
(reason != SCTP_RTXR_FAST_RTX && !chunk->tsn_gap_acked)) {
/* RFC 2960 6.2.1 Processing a Received SACK
*
* C) Any time a DATA chunk is marked for
* retransmission (via either T3-rtx timer expiration
* (Section 6.3.3) or via fast retransmit
* (Section 7.2.4)), add the data size of those
* chunks to the rwnd.
*/
q->asoc->peer.rwnd += sctp_data_size(chunk);
q->outstanding_bytes -= sctp_data_size(chunk);
if (chunk->transport)
transport->flight_size -= sctp_data_size(chunk);
/* sctpimpguide-05 Section 2.8.2
* M5) If a T3-rtx timer expires, the
* 'TSN.Missing.Report' of all affected TSNs is set
* to 0.
*/
chunk->tsn_missing_report = 0;
/* If a chunk that is being used for RTT measurement
* has to be retransmitted, we cannot use this chunk
* anymore for RTT measurements. Reset rto_pending so
* that a new RTT measurement is started when a new
* data chunk is sent.
*/
if (chunk->rtt_in_progress) {
chunk->rtt_in_progress = 0;
transport->rto_pending = 0;
}
/* Move the chunk to the retransmit queue. The chunks
* on the retransmit queue are always kept in order.
*/
list_del_init(lchunk);
sctp_insert_list(&q->retransmit, lchunk);
}
}
pr_debug("%s: transport:%p, reason:%d, cwnd:%d, ssthresh:%d, "
"flight_size:%d, pba:%d\n", __func__, transport, reason,
transport->cwnd, transport->ssthresh, transport->flight_size,
transport->partial_bytes_acked);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 123 | 45.72% | 6 | 35.29% |
Vladislav Yasevich | 66 | 24.54% | 4 | 23.53% |
Daisy Chang | 37 | 13.75% | 1 | 5.88% |
Sridhar Samudrala | 33 | 12.27% | 1 | 5.88% |
David S. Miller | 4 | 1.49% | 2 | 11.76% |
Daniel Borkmann | 3 | 1.12% | 1 | 5.88% |
Neil Horman | 2 | 0.74% | 1 | 5.88% |
Harvey Harrison | 1 | 0.37% | 1 | 5.88% |
Total | 269 | 100.00% | 17 | 100.00% |
/* Mark all the eligible packets on a transport for retransmission and force
* one packet out.
*/
void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
sctp_retransmit_reason_t reason)
{
struct net *net = sock_net(q->asoc->base.sk);
switch (reason) {
case SCTP_RTXR_T3_RTX:
SCTP_INC_STATS(net, SCTP_MIB_T3_RETRANSMITS);
sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_T3_RTX);
/* Update the retran path if the T3-rtx timer has expired for
* the current retran path.
*/
if (transport == transport->asoc->peer.retran_path)
sctp_assoc_update_retran_path(transport->asoc);
transport->asoc->rtx_data_chunks +=
transport->asoc->unack_data;
break;
case SCTP_RTXR_FAST_RTX:
SCTP_INC_STATS(net, SCTP_MIB_FAST_RETRANSMITS);
sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX);
q->fast_rtx = 1;
break;
case SCTP_RTXR_PMTUD:
SCTP_INC_STATS(net, SCTP_MIB_PMTUD_RETRANSMITS);
break;
case SCTP_RTXR_T1_RTX:
SCTP_INC_STATS(net, SCTP_MIB_T1_RETRANSMITS);
transport->asoc->init_retries++;
break;
default:
BUG();
}
sctp_retransmit_mark(q, transport, reason);
/* PR-SCTP A5) Any time the T3-rtx timer expires, on any destination,
* the sender SHOULD try to advance the "Advanced.Peer.Ack.Point" by
* following the procedures outlined in C1 - C5.
*/
if (reason == SCTP_RTXR_T3_RTX)
sctp_generate_fwdtsn(q, q->asoc->ctsn_ack_point);
/* Flush the queues only on timeout, since fast_rtx is only
* triggered during sack processing and the queue
* will be flushed at the end.
*/
if (reason != SCTP_RTXR_FAST_RTX)
sctp_outq_flush(q, /* rtx_timeout */ 1, GFP_ATOMIC);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sridhar Samudrala | 65 | 34.03% | 4 | 26.67% |
Jon Grimm | 52 | 27.23% | 5 | 33.33% |
Vladislav Yasevich | 29 | 15.18% | 3 | 20.00% |
Eric W. Biedermann | 24 | 12.57% | 1 | 6.67% |
Neil Horman | 19 | 9.95% | 1 | 6.67% |
Marcelo Ricardo Leitner | 2 | 1.05% | 1 | 6.67% |
Total | 191 | 100.00% | 15 | 100.00% |
/*
* Transmit DATA chunks on the retransmit queue. Upon return from
* sctp_outq_flush_rtx() the packet 'pkt' may contain chunks which
* need to be transmitted by the caller.
* We assume that pkt->transport has already been set.
*
* The return value is a normal kernel error return value.
*/
static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
int rtx_timeout, int *start_timer)
{
struct list_head *lqueue;
struct sctp_transport *transport = pkt->transport;
sctp_xmit_t status;
struct sctp_chunk *chunk, *chunk1;
int fast_rtx;
int error = 0;
int timer = 0;
int done = 0;
lqueue = &q->retransmit;
fast_rtx = q->fast_rtx;
/* This loop handles time-out retransmissions, fast retransmissions,
* and retransmissions due to opening of whindow.
*
* RFC 2960 6.3.3 Handle T3-rtx Expiration
*
* E3) Determine how many of the earliest (i.e., lowest TSN)
* outstanding DATA chunks for the address for which the
* T3-rtx has expired will fit into a single packet, subject
* to the MTU constraint for the path corresponding to the
* destination transport address to which the retransmission
* is being sent (this may be different from the address for
* which the timer expires [see Section 6.4]). Call this value
* K. Bundle and retransmit those K DATA chunks in a single
* packet to the destination endpoint.
*
* [Just to be painfully clear, if we are retransmitting
* because a timeout just happened, we should send only ONE
* packet of retransmitted data.]
*
* For fast retransmissions we also send only ONE packet. However,
* if we are just flushing the queue due to open window, we'll
* try to send as much as possible.
*/
list_for_each_entry_safe(chunk, chunk1, lqueue, transmitted_list) {
/* If the chunk is abandoned, move it to abandoned list. */
if (sctp_chunk_abandoned(chunk)) {
list_del_init(&chunk->transmitted_list);
sctp_insert_list(&q->abandoned,
&chunk->transmitted_list);
continue;
}
/* Make sure that Gap Acked TSNs are not retransmitted. A
* simple approach is just to move such TSNs out of the
* way and into a 'transmitted' queue and skip to the
* next chunk.
*/
if (chunk->tsn_gap_acked) {
list_move_tail(&chunk->transmitted_list,
&transport->transmitted);
continue;
}
/* If we are doing fast retransmit, ignore non-fast_rtransmit
* chunks
*/
if (fast_rtx && !chunk->fast_retransmit)
continue;
redo:
/* Attempt to append this chunk to the packet. */
status = sctp_packet_append_chunk(pkt, chunk);
switch (status) {
case SCTP_XMIT_PMTU_FULL:
if (!pkt->has_data && !pkt->has_cookie_echo) {
/* If this packet did not contain DATA then
* retransmission did not happen, so do it
* again. We'll ignore the error here since
* control chunks are already freed so there
* is nothing we can do.
*/
sctp_packet_transmit(pkt, GFP_ATOMIC);
goto redo;
}
/* Send this packet. */
error = sctp_packet_transmit(pkt, GFP_ATOMIC);
/* If we are retransmitting, we should only
* send a single packet.
* Otherwise, try appending this chunk again.
*/
if (rtx_timeout || fast_rtx)
done = 1;
else
goto redo;
/* Bundle next chunk in the next round. */
break;
case SCTP_XMIT_RWND_FULL:
/* Send this packet. */
error = sctp_packet_transmit(pkt, GFP_ATOMIC);
/* Stop sending DATA as there is no more room
* at the receiver.
*/
done = 1;
break;
case SCTP_XMIT_DELAY:
/* Send this packet. */
error = sctp_packet_transmit(pkt, GFP_ATOMIC);
/* Stop sending DATA because of nagle delay. */
done = 1;
break;
default:
/* The append was successful, so add this chunk to
* the transmitted list.
*/
list_move_tail(&chunk->transmitted_list,
&transport->transmitted);
/* Mark the chunk as ineligible for fast retransmit
* after it is retransmitted.
*/
if (chunk->fast_retransmit == SCTP_NEED_FRTX)
chunk->fast_retransmit = SCTP_DONT_FRTX;
q->asoc->stats.rtxchunks++;
break;
}
/* Set the timer if there were no errors */
if (!error && !timer)
timer = 1;
if (done)
break;
}
/* If we are here due to a retransmit timeout or a fast
* retransmit and if there are any chunks left in the retransmit
* queue that could not fit in the PMTU sized packet, they need
* to be marked as ineligible for a subsequent fast retransmit.
*/
if (rtx_timeout || fast_rtx) {
list_for_each_entry(chunk1, lqueue, transmitted_list) {
if (chunk1->fast_retransmit == SCTP_NEED_FRTX)
chunk1->fast_retransmit = SCTP_DONT_FRTX;
}
}
*start_timer = timer;
/* Clear fast retransmit hint */
if (fast_rtx)
q->fast_rtx = 0;
return error;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 140 | 36.94% | 7 | 30.43% |
Vladislav Yasevich | 112 | 29.55% | 4 | 17.39% |
Wei Yongjun | 59 | 15.57% | 3 | 13.04% |
Sridhar Samudrala | 40 | 10.55% | 2 | 8.70% |
Marcelo Ricardo Leitner | 8 | 2.11% | 1 | 4.35% |
Michele Baldessari | 7 | 1.85% | 1 | 4.35% |
Neil Horman | 6 | 1.58% | 1 | 4.35% |
Robert P. J. Day | 4 | 1.06% | 1 | 4.35% |
Michael Hayes | 1 | 0.26% | 1 | 4.35% |
David Laight | 1 | 0.26% | 1 | 4.35% |
Hideaki Yoshifuji / 吉藤英明 | 1 | 0.26% | 1 | 4.35% |
Total | 379 | 100.00% | 23 | 100.00% |
/* Cork the outqueue so queued chunks are really queued. */
void sctp_outq_uncork(struct sctp_outq *q, gfp_t gfp)
{
if (q->cork)
q->cork = 0;
sctp_outq_flush(q, 0, gfp);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 27 | 79.41% | 3 | 60.00% |
Marcelo Ricardo Leitner | 5 | 14.71% | 1 | 20.00% |
Xin Long | 2 | 5.88% | 1 | 20.00% |
Total | 34 | 100.00% | 5 | 100.00% |
/*
* Try to flush an outqueue.
*
* Description: Send everything in q which we legally can, subject to
* congestion limitations.
* * Note: This function can be called from multiple contexts so appropriate
* locking concerns must be made. Today we use the sock lock to protect
* this function.
*/
static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp)
{
struct sctp_packet *packet;
struct sctp_packet singleton;
struct sctp_association *asoc = q->asoc;
__u16 sport = asoc->base.bind_addr.port;
__u16 dport = asoc->peer.port;
__u32 vtag = asoc->peer.i.init_tag;
struct sctp_transport *transport = NULL;
struct sctp_transport *new_transport;
struct sctp_chunk *chunk, *tmp;
sctp_xmit_t status;
int error = 0;
int start_timer = 0;
int one_packet = 0;
/* These transports have chunks to send. */
struct list_head transport_list;
struct list_head *ltransport;
INIT_LIST_HEAD(&transport_list);
packet = NULL;
/*
* 6.10 Bundling
* ...
* When bundling control chunks with DATA chunks, an
* endpoint MUST place control chunks first in the outbound
* SCTP packet. The transmitter MUST transmit DATA chunks
* within a SCTP packet in increasing order of TSN.
* ...
*/
list_for_each_entry_safe(chunk, tmp, &q->control_chunk_list, list) {
/* RFC 5061, 5.3
* F1) This means that until such time as the ASCONF
* containing the add is acknowledged, the sender MUST
* NOT use the new IP address as a source for ANY SCTP
* packet except on carrying an ASCONF Chunk.
*/
if (asoc->src_out_of_asoc_ok &&
chunk->chunk_hdr->type != SCTP_CID_ASCONF)
continue;
list_del_init(&chunk->list);
/* Pick the right transport to use. */
new_transport = chunk->transport;
if (!new_transport) {
/*
* If we have a prior transport pointer, see if
* the destination address of the chunk
* matches the destination address of the
* current transport. If not a match, then
* try to look up the transport with a given
* destination address. We do this because
* after processing ASCONFs, we may have new
* transports created.
*/
if (transport &&
sctp_cmp_addr_exact(&chunk->dest,
&transport->ipaddr))
new_transport = transport;
else
new_transport = sctp_assoc_lookup_paddr(asoc,
&chunk->dest);
/* if we still don't have a new transport, then
* use the current active path.
*/
if (!new_transport)
new_transport = asoc->peer.active_path;
} else if ((new_transport->state == SCTP_INACTIVE) ||
(new_transport->state == SCTP_UNCONFIRMED) ||
(new_transport->state == SCTP_PF)) {
/* If the chunk is Heartbeat or Heartbeat Ack,
* send it to chunk->transport, even if it's
* inactive.
*
* 3.3.6 Heartbeat Acknowledgement:
* ...
* A HEARTBEAT ACK is always sent to the source IP
* address of the IP datagram containing the
* HEARTBEAT chunk to which this ack is responding.
* ...
*
* ASCONF_ACKs also must be sent to the source.
*/
if (chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT &&
chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT_ACK &&
chunk->chunk_hdr->type != SCTP_CID_ASCONF_ACK)
new_transport = asoc->peer.active_path;
}
/* Are we switching transports?
* Take care of transport locks.
*/
if (new_transport != transport) {
transport = new_transport;
if (list_empty(&transport->send_ready)) {
list_add_tail(&transport->send_ready,
&transport_list);
}
packet = &transport->packet;
sctp_packet_config(packet, vtag,
asoc->peer.ecn_capable);
}
switch (chunk->chunk_hdr->type) {
/*
* 6.10 Bundling
* ...
* An endpoint MUST NOT bundle INIT, INIT ACK or SHUTDOWN
* COMPLETE with any other chunks. [Send them immediately.]
*/
case SCTP_CID_INIT:
case SCTP_CID_INIT_ACK:
case SCTP_CID_SHUTDOWN_COMPLETE:
sctp_packet_init(&singleton, transport, sport, dport);
sctp_packet_config(&singleton, vtag, 0);
sctp_packet_append_chunk(&singleton, chunk);
error = sctp_packet_transmit(&singleton, gfp);
if (error < 0) {
asoc->base