2019-05-23 17:14:41 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-01-11 22:57:09 +08:00
|
|
|
/* SCTP kernel implementation
|
2005-04-17 06:20:36 +08:00
|
|
|
* (C) Copyright IBM Corp. 2001, 2004
|
|
|
|
* Copyright (c) 1999-2000 Cisco, Inc.
|
|
|
|
* Copyright (c) 1999-2001 Motorola, Inc.
|
|
|
|
* Copyright (c) 2001-2003 Intel Corp.
|
|
|
|
*
|
2008-01-11 22:57:09 +08:00
|
|
|
* This file is part of the SCTP kernel implementation
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* These functions implement the sctp_outq class. The outqueue handles
|
|
|
|
* bundling and queueing of outgoing SCTP chunks.
|
|
|
|
*
|
|
|
|
* Please send any bug reports or fixes you make to the
|
|
|
|
* email address(es):
|
2013-07-23 20:51:47 +08:00
|
|
|
* lksctp developers <linux-sctp@vger.kernel.org>
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
*/
|
|
|
|
|
2010-08-24 21:21:08 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/list.h> /* For struct list_head */
|
|
|
|
#include <linux/socket.h>
|
|
|
|
#include <linux/ip.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <net/sock.h> /* For skb_set_owner_w */
|
|
|
|
|
|
|
|
#include <net/sctp/sctp.h>
|
|
|
|
#include <net/sctp/sm.h>
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
#include <net/sctp/stream_sched.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* 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,
|
2012-10-03 13:43:22 +08:00
|
|
|
union sctp_addr *saddr,
|
2005-04-17 06:20:36 +08:00
|
|
|
struct sctp_sackhdr *sack,
|
2010-05-01 10:41:10 +08:00
|
|
|
__u32 *highest_new_tsn);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2016-09-14 02:04:22 +08:00
|
|
|
static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp);
|
2008-07-23 05:20:45 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Add data to the front of the queue. */
|
|
|
|
static inline void sctp_outq_head_data(struct sctp_outq *q,
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
struct sctp_chunk *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
struct sctp_stream_out_ext *oute;
|
|
|
|
__u16 stream;
|
|
|
|
|
2005-07-09 12:47:49 +08:00
|
|
|
list_add(&ch->list, &q->out_chunk_list);
|
2005-04-17 06:20:36 +08:00
|
|
|
q->out_qlen += ch->skb->len;
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
|
|
|
|
stream = sctp_chunk_stream_no(ch);
|
2018-08-11 01:11:42 +08:00
|
|
|
oute = SCTP_SO(&q->asoc->stream, stream)->ext;
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
list_add(&ch->stream_list, &oute->outq);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Take data from the front of the queue. */
|
|
|
|
static inline struct sctp_chunk *sctp_outq_dequeue_data(struct sctp_outq *q)
|
|
|
|
{
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
return q->sched->dequeue(q);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
|
2005-04-17 06:20:36 +08: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)
|
|
|
|
{
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
struct sctp_stream_out_ext *oute;
|
|
|
|
__u16 stream;
|
|
|
|
|
2005-07-09 12:47:49 +08:00
|
|
|
list_add_tail(&ch->list, &q->out_chunk_list);
|
2005-04-17 06:20:36 +08:00
|
|
|
q->out_qlen += ch->skb->len;
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
|
|
|
|
stream = sctp_chunk_stream_no(ch);
|
2018-08-11 01:11:42 +08:00
|
|
|
oute = SCTP_SO(&q->asoc->stream, stream)->ext;
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
list_add_tail(&ch->stream_list, &oute->outq);
|
2005-04-17 06:20:36 +08: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)
|
|
|
|
{
|
2013-12-23 12:16:50 +08:00
|
|
|
if (count_of_newacks >= 2 && transport != primary)
|
2005-04-17 06:20:36 +08:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
2011-04-19 03:13:56 +08:00
|
|
|
if (count_of_newacks < 2 &&
|
|
|
|
(transport && !transport->cacc.cacc_saw_newack))
|
2005-04-17 06:20:36 +08:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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,
|
2011-03-31 09:57:33 +08:00
|
|
|
* then the sender MUST further execute steps 3.1 and
|
2005-04-17 06:20:36 +08:00
|
|
|
* 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
|
2011-03-31 09:57:33 +08:00
|
|
|
* the sender SHOULD increment missing report count for
|
2005-04-17 06:20:36 +08:00
|
|
|
* 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 &&
|
2009-11-30 08:55:45 +08:00
|
|
|
(sctp_cacc_skip_3_1(primary, transport, count_of_newacks) ||
|
|
|
|
sctp_cacc_skip_3_2(primary, tsn)))
|
2005-04-17 06:20:36 +08:00
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2013-06-13 02:26:44 +08:00
|
|
|
memset(q, 0, sizeof(struct sctp_outq));
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
q->asoc = asoc;
|
2005-07-09 12:47:49 +08:00
|
|
|
INIT_LIST_HEAD(&q->out_chunk_list);
|
|
|
|
INIT_LIST_HEAD(&q->control_chunk_list);
|
2005-04-17 06:20:36 +08:00
|
|
|
INIT_LIST_HEAD(&q->retransmit);
|
|
|
|
INIT_LIST_HEAD(&q->sacked);
|
|
|
|
INIT_LIST_HEAD(&q->abandoned);
|
2019-01-28 15:08:46 +08:00
|
|
|
sctp_sched_set_sched(asoc, sctp_sk(asoc->base.sk)->default_ss);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the outqueue structure and any related pending chunks.
|
|
|
|
*/
|
2013-01-17 19:15:08 +08:00
|
|
|
static void __sctp_outq_teardown(struct sctp_outq *q)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct sctp_transport *transport;
|
2008-04-13 09:54:24 +08:00
|
|
|
struct list_head *lchunk, *temp;
|
2005-07-09 12:47:49 +08:00
|
|
|
struct sctp_chunk *chunk, *tmp;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Throw away unacknowledged chunks. */
|
2008-04-13 09:54:24 +08:00
|
|
|
list_for_each_entry(transport, &q->asoc->peer.transport_addr_list,
|
|
|
|
transports) {
|
2005-04-17 06:20:36 +08:00
|
|
|
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) {
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
sctp_sched_dequeue_done(q, chunk);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Mark as send failure. */
|
|
|
|
sctp_chunk_fail(chunk, q->error);
|
|
|
|
sctp_chunk_free(chunk);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Throw away any leftover control chunks. */
|
2005-07-09 12:47:49 +08:00
|
|
|
list_for_each_entry_safe(chunk, tmp, &q->control_chunk_list, list) {
|
|
|
|
list_del_init(&chunk->list);
|
2005-04-17 06:20:36 +08:00
|
|
|
sctp_chunk_free(chunk);
|
2005-07-09 12:47:49 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2013-01-17 19:15:08 +08:00
|
|
|
void sctp_outq_teardown(struct sctp_outq *q)
|
|
|
|
{
|
|
|
|
__sctp_outq_teardown(q);
|
|
|
|
sctp_outq_init(q->asoc, q);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Free the outqueue structure and any related pending chunks. */
|
|
|
|
void sctp_outq_free(struct sctp_outq *q)
|
|
|
|
{
|
|
|
|
/* Throw away leftover chunks. */
|
2013-01-17 19:15:08 +08:00
|
|
|
__sctp_outq_teardown(q);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Put a new chunk in an sctp_outq. */
|
2016-09-14 02:04:22 +08:00
|
|
|
void sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk, gfp_t gfp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2012-08-06 16:47:55 +08:00
|
|
|
struct net *net = sock_net(q->asoc->base.sk);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
net: sctp: rework debugging framework to use pr_debug and friends
We should get rid of all own SCTP debug printk macros and use the ones
that the kernel offers anyway instead. This makes the code more readable
and conform to the kernel code, and offers all the features of dynamic
debbuging that pr_debug() et al has, such as only turning on/off portions
of debug messages at runtime through debugfs. The runtime cost of having
CONFIG_DYNAMIC_DEBUG enabled, but none of the debug statements printing,
is negligible [1]. If kernel debugging is completly turned off, then these
statements will also compile into "empty" functions.
While we're at it, we also need to change the Kconfig option as it /now/
only refers to the ifdef'ed code portions in outqueue.c that enable further
debugging/tracing of SCTP transaction fields. Also, since SCTP_ASSERT code
was enabled with this Kconfig option and has now been removed, we
transform those code parts into WARNs resp. where appropriate BUG_ONs so
that those bugs can be more easily detected as probably not many people
have SCTP debugging permanently turned on.
To turn on all SCTP debugging, the following steps are needed:
# mount -t debugfs none /sys/kernel/debug
# echo -n 'module sctp +p' > /sys/kernel/debug/dynamic_debug/control
This can be done more fine-grained on a per file, per line basis and others
as described in [2].
[1] https://www.kernel.org/doc/ols/2009/ols2009-pages-39-46.pdf
[2] Documentation/dynamic-debug-howto.txt
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-29 01:49:40 +08:00
|
|
|
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");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* If it is data, queue it up, otherwise, send it
|
|
|
|
* immediately.
|
|
|
|
*/
|
2010-05-01 10:41:09 +08:00
|
|
|
if (sctp_chunk_is_data(chunk)) {
|
2016-09-14 02:04:18 +08:00
|
|
|
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);
|
2016-10-03 09:17:07 +08:00
|
|
|
if (chunk->asoc->peer.prsctp_capable &&
|
2016-09-14 02:04:18 +08:00
|
|
|
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);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
2005-07-09 12:47:49 +08:00
|
|
|
list_add_tail(&chunk->list, &q->control_chunk_list);
|
2012-08-06 16:47:55 +08:00
|
|
|
SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!q->cork)
|
2016-09-14 02:04:22 +08:00
|
|
|
sctp_outq_flush(q, 0, gfp);
|
2005-04-17 06:20:36 +08: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)
|
2007-02-09 22:25:18 +08:00
|
|
|
list_add_tail(new, head);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08: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) {
|
2017-04-01 17:07:46 +08:00
|
|
|
struct sctp_stream_out *streamout;
|
|
|
|
|
2017-11-25 21:18:35 +08:00
|
|
|
if (!chk->msg->abandoned &&
|
|
|
|
(!SCTP_PR_PRIO_ENABLED(chk->sinfo.sinfo_flags) ||
|
|
|
|
chk->sinfo.sinfo_timetolive <= sinfo->sinfo_timetolive))
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
continue;
|
|
|
|
|
2017-11-25 21:18:35 +08:00
|
|
|
chk->msg->abandoned = 1;
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
list_del_init(&chk->transmitted_list);
|
|
|
|
sctp_insert_list(&asoc->outqueue.abandoned,
|
|
|
|
&chk->transmitted_list);
|
|
|
|
|
2018-08-11 01:11:42 +08:00
|
|
|
streamout = SCTP_SO(&asoc->stream, chk->sinfo.sinfo_stream);
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
asoc->sent_cnt_removable--;
|
|
|
|
asoc->abandoned_sent[SCTP_PR_INDEX(PRIO)]++;
|
2017-10-04 06:20:11 +08:00
|
|
|
streamout->ext->abandoned_sent[SCTP_PR_INDEX(PRIO)]++;
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
|
2017-11-25 21:18:34 +08:00
|
|
|
if (queue != &asoc->outqueue.retransmit &&
|
|
|
|
!chk->tsn_gap_acked) {
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
if (chk->transport)
|
|
|
|
chk->transport->flight_size -=
|
|
|
|
sctp_data_size(chk);
|
|
|
|
asoc->outqueue.outstanding_bytes -= sctp_data_size(chk);
|
|
|
|
}
|
|
|
|
|
2018-10-17 03:07:50 +08:00
|
|
|
msg_len -= chk->skb->truesize + sizeof(struct sctp_chunk);
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
if (msg_len <= 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return msg_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sctp_prsctp_prune_unsent(struct sctp_association *asoc,
|
2017-03-18 20:03:59 +08:00
|
|
|
struct sctp_sndrcvinfo *sinfo, int msg_len)
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
{
|
2017-03-18 20:03:59 +08:00
|
|
|
struct sctp_outq *q = &asoc->outqueue;
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
struct sctp_chunk *chk, *temp;
|
|
|
|
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
q->sched->unsched_all(&asoc->stream);
|
|
|
|
|
2017-03-18 20:03:59 +08:00
|
|
|
list_for_each_entry_safe(chk, temp, &q->out_chunk_list, list) {
|
2017-11-25 21:18:35 +08:00
|
|
|
if (!chk->msg->abandoned &&
|
2017-11-25 21:18:36 +08:00
|
|
|
(!(chk->chunk_hdr->flags & SCTP_DATA_FIRST_FRAG) ||
|
|
|
|
!SCTP_PR_PRIO_ENABLED(chk->sinfo.sinfo_flags) ||
|
2017-11-25 21:18:35 +08:00
|
|
|
chk->sinfo.sinfo_timetolive <= sinfo->sinfo_timetolive))
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
continue;
|
|
|
|
|
2017-11-25 21:18:35 +08:00
|
|
|
chk->msg->abandoned = 1;
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
sctp_sched_dequeue_common(q, chk);
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
asoc->sent_cnt_removable--;
|
|
|
|
asoc->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
|
2017-05-31 16:36:31 +08:00
|
|
|
if (chk->sinfo.sinfo_stream < asoc->stream.outcnt) {
|
2017-04-01 17:07:46 +08:00
|
|
|
struct sctp_stream_out *streamout =
|
2018-08-11 01:11:42 +08:00
|
|
|
SCTP_SO(&asoc->stream, chk->sinfo.sinfo_stream);
|
2017-04-01 17:07:46 +08:00
|
|
|
|
2017-10-04 06:20:11 +08:00
|
|
|
streamout->ext->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
|
2017-04-01 17:07:46 +08:00
|
|
|
}
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
|
2018-10-17 03:07:50 +08:00
|
|
|
msg_len -= chk->skb->truesize + sizeof(struct sctp_chunk);
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
sctp_chunk_free(chk);
|
|
|
|
if (msg_len <= 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
sctp: introduce stream scheduler foundations
This patch introduces the hooks necessary to do stream scheduling, as
per RFC Draft ndata. It also introduces the first scheduler, which is
what we do today but now factored out: first come first served (FCFS).
With stream scheduling now we have to track which chunk was enqueued on
which stream and be able to select another other than the in front of
the main outqueue. So we introduce a list on sctp_stream_out_ext
structure for this purpose.
We reuse sctp_chunk->transmitted_list space for the list above, as the
chunk cannot belong to the two lists at the same time. By using the
union in there, we can have distinct names for these moments.
sctp_sched_ops are the operations expected to be implemented by each
scheduler. The dequeueing is a bit particular to this implementation but
it is to match how we dequeue packets today. We first dequeue and then
check if it fits the packet and if not, we requeue it at head. Thus why
we don't have a peek operation but have dequeue_done instead, which is
called once the chunk can be safely considered as transmitted.
The check removed from sctp_outq_flush is now performed by
sctp_stream_outq_migrate, which is only called during assoc setup.
(sctp_sendmsg() also checks for it)
The only operation that is foreseen but not yet added here is a way to
signalize that a new packet is starting or that the packet is done, for
round robin scheduler per packet, but is intentionally left to the
patch that actually implements it.
Support for I-DATA chunks, also described in this RFC, with user message
interleaving is straightforward as it just requires the schedulers to
probe for the feature and ignore datamsg boundaries when dequeueing.
See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-04 06:20:13 +08:00
|
|
|
q->sched->sched_all(&asoc->stream);
|
|
|
|
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
return msg_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2016-09-29 02:37:28 +08:00
|
|
|
if (!asoc->peer.prsctp_capable || !asoc->sent_cnt_removable)
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-03-18 20:03:59 +08:00
|
|
|
sctp_prsctp_prune_unsent(asoc, sinfo, msg_len);
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Mark all the eligible packets on a transport for retransmission. */
|
|
|
|
void sctp_retransmit_mark(struct sctp_outq *q,
|
|
|
|
struct sctp_transport *transport,
|
2007-10-25 03:59:16 +08:00
|
|
|
__u8 reason)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
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);
|
2007-02-21 18:06:04 +08:00
|
|
|
|
|
|
|
/* 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) {
|
2009-09-05 06:21:00 +08:00
|
|
|
if (chunk->transport)
|
|
|
|
chunk->transport->flight_size -=
|
|
|
|
sctp_data_size(chunk);
|
2007-02-21 18:06:04 +08:00
|
|
|
q->outstanding_bytes -= sctp_data_size(chunk);
|
2011-12-19 12:11:40 +08:00
|
|
|
q->asoc->peer.rwnd += sctp_data_size(chunk);
|
2007-02-21 18:06:04 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-10-25 03:59:16 +08:00
|
|
|
/* 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.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2007-10-25 03:59:16 +08:00
|
|
|
if ((reason == SCTP_RTXR_FAST_RTX &&
|
2008-07-26 00:44:09 +08:00
|
|
|
(chunk->fast_retransmit == SCTP_NEED_FRTX)) ||
|
2007-10-25 03:59:16 +08:00
|
|
|
(reason != SCTP_RTXR_FAST_RTX && !chunk->tsn_gap_acked)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* 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.
|
|
|
|
*/
|
2011-12-19 12:11:40 +08:00
|
|
|
q->asoc->peer.rwnd += sctp_data_size(chunk);
|
2005-04-17 06:20:36 +08:00
|
|
|
q->outstanding_bytes -= sctp_data_size(chunk);
|
2009-09-05 06:21:00 +08:00
|
|
|
if (chunk->transport)
|
|
|
|
transport->flight_size -= sctp_data_size(chunk);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
net: sctp: rework debugging framework to use pr_debug and friends
We should get rid of all own SCTP debug printk macros and use the ones
that the kernel offers anyway instead. This makes the code more readable
and conform to the kernel code, and offers all the features of dynamic
debbuging that pr_debug() et al has, such as only turning on/off portions
of debug messages at runtime through debugfs. The runtime cost of having
CONFIG_DYNAMIC_DEBUG enabled, but none of the debug statements printing,
is negligible [1]. If kernel debugging is completly turned off, then these
statements will also compile into "empty" functions.
While we're at it, we also need to change the Kconfig option as it /now/
only refers to the ifdef'ed code portions in outqueue.c that enable further
debugging/tracing of SCTP transaction fields. Also, since SCTP_ASSERT code
was enabled with this Kconfig option and has now been removed, we
transform those code parts into WARNs resp. where appropriate BUG_ONs so
that those bugs can be more easily detected as probably not many people
have SCTP debugging permanently turned on.
To turn on all SCTP debugging, the following steps are needed:
# mount -t debugfs none /sys/kernel/debug
# echo -n 'module sctp +p' > /sys/kernel/debug/dynamic_debug/control
This can be done more fine-grained on a per file, per line basis and others
as described in [2].
[1] https://www.kernel.org/doc/ols/2009/ols2009-pages-39-46.pdf
[2] Documentation/dynamic-debug-howto.txt
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-29 01:49:40 +08:00
|
|
|
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);
|
2005-04-17 06:20:36 +08: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,
|
2017-08-05 19:59:52 +08:00
|
|
|
enum sctp_retransmit_reason reason)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2012-08-06 16:47:55 +08:00
|
|
|
struct net *net = sock_net(q->asoc->base.sk);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-12-23 12:16:50 +08:00
|
|
|
switch (reason) {
|
2005-04-17 06:20:36 +08:00
|
|
|
case SCTP_RTXR_T3_RTX:
|
2012-08-06 16:47:55 +08:00
|
|
|
SCTP_INC_STATS(net, SCTP_MIB_T3_RETRANSMITS);
|
2005-04-17 06:20:36 +08:00
|
|
|
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);
|
2008-03-01 03:40:56 +08:00
|
|
|
transport->asoc->rtx_data_chunks +=
|
|
|
|
transport->asoc->unack_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case SCTP_RTXR_FAST_RTX:
|
2012-08-06 16:47:55 +08:00
|
|
|
SCTP_INC_STATS(net, SCTP_MIB_FAST_RETRANSMITS);
|
2005-04-17 06:20:36 +08:00
|
|
|
sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX);
|
2008-06-05 03:39:11 +08:00
|
|
|
q->fast_rtx = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case SCTP_RTXR_PMTUD:
|
2012-08-06 16:47:55 +08:00
|
|
|
SCTP_INC_STATS(net, SCTP_MIB_PMTUD_RETRANSMITS);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2007-10-25 03:59:16 +08:00
|
|
|
case SCTP_RTXR_T1_RTX:
|
2012-08-06 16:47:55 +08:00
|
|
|
SCTP_INC_STATS(net, SCTP_MIB_T1_RETRANSMITS);
|
2008-03-01 03:40:56 +08:00
|
|
|
transport->asoc->init_retries++;
|
2007-10-25 03:59:16 +08:00
|
|
|
break;
|
2006-08-22 15:15:33 +08:00
|
|
|
default:
|
|
|
|
BUG();
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-10-25 03:59:16 +08:00
|
|
|
sctp_retransmit_mark(q, transport, reason);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2008-06-05 03:39:36 +08:00
|
|
|
if (reason == SCTP_RTXR_T3_RTX)
|
2017-12-15 00:41:26 +08:00
|
|
|
q->asoc->stream.si->generate_ftsn(q, q->asoc->ctsn_ack_point);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-06-05 03:39:36 +08:00
|
|
|
/* 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: save transmit error to sk_err in sctp_outq_flush
Every time when sctp calls sctp_outq_flush, it sends out the chunks of
control queue, retransmit queue and data queue. Even if some trunks are
failed to transmit, it still has to flush all the transports, as it's
the only chance to clean that transmit_list.
So the latest transmit error here should be returned back. This transmit
error is an internal error of sctp stack.
I checked all the places where it uses the transmit error (the return
value of sctp_outq_flush), most of them are actually just save it to
sk_err.
Except for sctp_assoc/endpoint_bh_rcv, they will drop the chunk if
it's failed to send a REPLY, which is actually incorrect, as we can't
be sure the error that sctp_outq_flush returns is from sending that
REPLY.
So it's meaningless for sctp_outq_flush to return error back.
This patch is to save transmit error to sk_err in sctp_outq_flush, the
new error can update the old value. Eventually, sctp_wait_for_* would
check for it.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-09-14 02:04:21 +08:00
|
|
|
sctp_outq_flush(q, /* rtx_timeout */ 1, GFP_ATOMIC);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Transmit DATA chunks on the retransmit queue. Upon return from
|
2018-05-15 01:34:39 +08:00
|
|
|
* __sctp_outq_flush_rtx() the packet 'pkt' may contain chunks which
|
2005-04-17 06:20:36 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
2018-05-15 01:34:39 +08:00
|
|
|
static int __sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
|
2018-05-15 01:34:42 +08:00
|
|
|
int rtx_timeout, int *start_timer, gfp_t gfp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct sctp_transport *transport = pkt->transport;
|
|
|
|
struct sctp_chunk *chunk, *chunk1;
|
2017-08-05 19:59:57 +08:00
|
|
|
struct list_head *lqueue;
|
|
|
|
enum sctp_xmit status;
|
2005-04-17 06:20:36 +08:00
|
|
|
int error = 0;
|
2008-06-05 03:39:11 +08:00
|
|
|
int timer = 0;
|
2008-06-05 03:39:36 +08:00
|
|
|
int done = 0;
|
2017-08-05 19:59:57 +08:00
|
|
|
int fast_rtx;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
lqueue = &q->retransmit;
|
2008-06-05 03:39:11 +08:00
|
|
|
fast_rtx = q->fast_rtx;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-06-05 03:39:36 +08:00
|
|
|
/* This loop handles time-out retransmissions, fast retransmissions,
|
|
|
|
* and retransmissions due to opening of whindow.
|
|
|
|
*
|
|
|
|
* RFC 2960 6.3.3 Handle T3-rtx Expiration
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* 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.]
|
2008-06-05 03:39:36 +08:00
|
|
|
*
|
|
|
|
* 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.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2008-06-05 03:39:36 +08:00
|
|
|
list_for_each_entry_safe(chunk, chunk1, lqueue, transmitted_list) {
|
2011-04-20 05:32:28 +08:00
|
|
|
/* 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;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* 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) {
|
2012-09-04 07:58:16 +08:00
|
|
|
list_move_tail(&chunk->transmitted_list,
|
|
|
|
&transport->transmitted);
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-06-05 03:39:36 +08:00
|
|
|
/* If we are doing fast retransmit, ignore non-fast_rtransmit
|
|
|
|
* chunks
|
|
|
|
*/
|
|
|
|
if (fast_rtx && !chunk->fast_retransmit)
|
|
|
|
continue;
|
|
|
|
|
2010-05-01 10:38:53 +08:00
|
|
|
redo:
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Attempt to append this chunk to the packet. */
|
|
|
|
status = sctp_packet_append_chunk(pkt, chunk);
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case SCTP_XMIT_PMTU_FULL:
|
2010-05-01 10:38:53 +08:00
|
|
|
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.
|
|
|
|
*/
|
2018-05-15 01:34:42 +08:00
|
|
|
sctp_packet_transmit(pkt, gfp);
|
2010-05-01 10:38:53 +08:00
|
|
|
goto redo;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Send this packet. */
|
2018-05-15 01:34:42 +08:00
|
|
|
error = sctp_packet_transmit(pkt, gfp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* If we are retransmitting, we should only
|
|
|
|
* send a single packet.
|
2011-04-19 03:13:56 +08:00
|
|
|
* Otherwise, try appending this chunk again.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2008-06-05 03:39:36 +08:00
|
|
|
if (rtx_timeout || fast_rtx)
|
|
|
|
done = 1;
|
2011-04-19 03:13:56 +08:00
|
|
|
else
|
|
|
|
goto redo;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-06-05 03:39:36 +08:00
|
|
|
/* Bundle next chunk in the next round. */
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_XMIT_RWND_FULL:
|
2007-02-09 22:25:18 +08:00
|
|
|
/* Send this packet. */
|
2018-05-15 01:34:42 +08:00
|
|
|
error = sctp_packet_transmit(pkt, gfp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Stop sending DATA as there is no more room
|
|
|
|
* at the receiver.
|
|
|
|
*/
|
2008-06-05 03:39:36 +08:00
|
|
|
done = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2014-07-22 16:59:14 +08:00
|
|
|
case SCTP_XMIT_DELAY:
|
2007-02-09 22:25:18 +08:00
|
|
|
/* Send this packet. */
|
2018-05-15 01:34:42 +08:00
|
|
|
error = sctp_packet_transmit(pkt, gfp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Stop sending DATA because of nagle delay. */
|
2008-06-05 03:39:36 +08:00
|
|
|
done = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* The append was successful, so add this chunk to
|
|
|
|
* the transmitted list.
|
|
|
|
*/
|
2012-09-04 07:58:16 +08:00
|
|
|
list_move_tail(&chunk->transmitted_list,
|
|
|
|
&transport->transmitted);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-09 22:25:18 +08:00
|
|
|
/* Mark the chunk as ineligible for fast retransmit
|
2005-04-17 06:20:36 +08:00
|
|
|
* after it is retransmitted.
|
|
|
|
*/
|
2008-07-26 00:44:09 +08:00
|
|
|
if (chunk->fast_retransmit == SCTP_NEED_FRTX)
|
|
|
|
chunk->fast_retransmit = SCTP_DONT_FRTX;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-12-01 12:49:42 +08:00
|
|
|
q->asoc->stats.rtxchunks++;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2007-04-21 08:09:22 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-06-05 03:39:11 +08:00
|
|
|
/* Set the timer if there were no errors */
|
|
|
|
if (!error && !timer)
|
|
|
|
timer = 1;
|
|
|
|
|
2008-06-05 03:39:36 +08:00
|
|
|
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) {
|
2008-07-26 00:44:09 +08:00
|
|
|
if (chunk1->fast_retransmit == SCTP_NEED_FRTX)
|
|
|
|
chunk1->fast_retransmit = SCTP_DONT_FRTX;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-05 03:39:11 +08:00
|
|
|
*start_timer = timer;
|
|
|
|
|
|
|
|
/* Clear fast retransmit hint */
|
|
|
|
if (fast_rtx)
|
|
|
|
q->fast_rtx = 0;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cork the outqueue so queued chunks are really queued. */
|
2016-09-14 02:04:22 +08:00
|
|
|
void sctp_outq_uncork(struct sctp_outq *q, gfp_t gfp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-11-10 00:43:41 +08:00
|
|
|
if (q->cork)
|
2005-04-17 06:20:36 +08:00
|
|
|
q->cork = 0;
|
2013-04-16 19:07:14 +08:00
|
|
|
|
2016-09-14 02:04:22 +08:00
|
|
|
sctp_outq_flush(q, 0, gfp);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2018-05-15 01:34:36 +08:00
|
|
|
static int sctp_packet_singleton(struct sctp_transport *transport,
|
|
|
|
struct sctp_chunk *chunk, gfp_t gfp)
|
|
|
|
{
|
|
|
|
const struct sctp_association *asoc = transport->asoc;
|
|
|
|
const __u16 sport = asoc->base.bind_addr.port;
|
|
|
|
const __u16 dport = asoc->peer.port;
|
|
|
|
const __u32 vtag = asoc->peer.i.init_tag;
|
|
|
|
struct sctp_packet singleton;
|
|
|
|
|
|
|
|
sctp_packet_init(&singleton, transport, sport, dport);
|
|
|
|
sctp_packet_config(&singleton, vtag, 0);
|
|
|
|
sctp_packet_append_chunk(&singleton, chunk);
|
|
|
|
return sctp_packet_transmit(&singleton, gfp);
|
|
|
|
}
|
2008-06-20 07:08:18 +08:00
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
/* Struct to hold the context during sctp outq flush */
|
|
|
|
struct sctp_flush_ctx {
|
|
|
|
struct sctp_outq *q;
|
|
|
|
/* Current transport being used. It's NOT the same as curr active one */
|
|
|
|
struct sctp_transport *transport;
|
|
|
|
/* These transports have chunks to send. */
|
|
|
|
struct list_head transport_list;
|
2018-05-15 01:35:19 +08:00
|
|
|
struct sctp_association *asoc;
|
|
|
|
/* Packet on the current transport above */
|
|
|
|
struct sctp_packet *packet;
|
2018-05-15 01:35:18 +08:00
|
|
|
gfp_t gfp;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* transport: current transport */
|
2018-05-15 01:35:19 +08:00
|
|
|
static void sctp_outq_select_transport(struct sctp_flush_ctx *ctx,
|
2018-05-15 01:35:18 +08:00
|
|
|
struct sctp_chunk *chunk)
|
2018-05-15 01:34:37 +08:00
|
|
|
{
|
|
|
|
struct sctp_transport *new_transport = chunk->transport;
|
|
|
|
|
|
|
|
if (!new_transport) {
|
|
|
|
if (!sctp_chunk_is_data(chunk)) {
|
2018-05-15 01:35:20 +08:00
|
|
|
/* If we have a prior transport pointer, see if
|
2018-05-15 01:34:37 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
2018-05-15 01:35:18 +08:00
|
|
|
if (ctx->transport && sctp_cmp_addr_exact(&chunk->dest,
|
|
|
|
&ctx->transport->ipaddr))
|
|
|
|
new_transport = ctx->transport;
|
2018-05-15 01:34:37 +08:00
|
|
|
else
|
2018-05-15 01:35:19 +08:00
|
|
|
new_transport = sctp_assoc_lookup_paddr(ctx->asoc,
|
2018-05-15 01:34:37 +08:00
|
|
|
&chunk->dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we still don't have a new transport, then
|
|
|
|
* use the current active path.
|
|
|
|
*/
|
|
|
|
if (!new_transport)
|
2018-05-15 01:35:19 +08:00
|
|
|
new_transport = ctx->asoc->peer.active_path;
|
2018-05-15 01:34:37 +08:00
|
|
|
} else {
|
|
|
|
__u8 type;
|
|
|
|
|
|
|
|
switch (new_transport->state) {
|
|
|
|
case SCTP_INACTIVE:
|
|
|
|
case SCTP_UNCONFIRMED:
|
|
|
|
case 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.
|
|
|
|
*/
|
|
|
|
type = chunk->chunk_hdr->type;
|
|
|
|
if (type != SCTP_CID_HEARTBEAT &&
|
|
|
|
type != SCTP_CID_HEARTBEAT_ACK &&
|
|
|
|
type != SCTP_CID_ASCONF_ACK)
|
2018-05-15 01:35:19 +08:00
|
|
|
new_transport = ctx->asoc->peer.active_path;
|
2018-05-15 01:34:37 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Are we switching transports? Take care of transport locks. */
|
2018-05-15 01:35:18 +08:00
|
|
|
if (new_transport != ctx->transport) {
|
|
|
|
ctx->transport = new_transport;
|
2018-05-15 01:35:19 +08:00
|
|
|
ctx->packet = &ctx->transport->packet;
|
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
if (list_empty(&ctx->transport->send_ready))
|
|
|
|
list_add_tail(&ctx->transport->send_ready,
|
|
|
|
&ctx->transport_list);
|
2018-05-15 01:34:37 +08:00
|
|
|
|
2018-05-15 01:35:19 +08:00
|
|
|
sctp_packet_config(ctx->packet,
|
|
|
|
ctx->asoc->peer.i.init_tag,
|
|
|
|
ctx->asoc->peer.ecn_capable);
|
2018-05-15 01:34:37 +08:00
|
|
|
/* We've switched transports, so apply the
|
|
|
|
* Burst limit to the new transport.
|
|
|
|
*/
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_transport_burst_limited(ctx->transport);
|
2018-05-15 01:34:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
static void sctp_outq_flush_ctrl(struct sctp_flush_ctx *ctx)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-07-09 12:47:49 +08:00
|
|
|
struct sctp_chunk *chunk, *tmp;
|
2017-08-05 19:59:57 +08:00
|
|
|
enum sctp_xmit status;
|
2018-05-15 01:34:38 +08:00
|
|
|
int one_packet, error;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
list_for_each_entry_safe(chunk, tmp, &ctx->q->control_chunk_list, list) {
|
2018-05-15 01:34:38 +08:00
|
|
|
one_packet = 0;
|
|
|
|
|
2011-04-26 19:19:36 +08:00
|
|
|
/* 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.
|
|
|
|
*/
|
2018-05-15 01:35:19 +08:00
|
|
|
if (ctx->asoc->src_out_of_asoc_ok &&
|
2011-04-26 19:19:36 +08:00
|
|
|
chunk->chunk_hdr->type != SCTP_CID_ASCONF)
|
|
|
|
continue;
|
|
|
|
|
2005-07-09 12:47:49 +08:00
|
|
|
list_del_init(&chunk->list);
|
|
|
|
|
2018-05-15 01:34:37 +08:00
|
|
|
/* Pick the right transport to use. Should always be true for
|
|
|
|
* the first chunk as we don't have a transport by then.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2018-05-15 01:35:19 +08:00
|
|
|
sctp_outq_select_transport(ctx, chunk);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
switch (chunk->chunk_hdr->type) {
|
2018-05-15 01:35:20 +08:00
|
|
|
/* 6.10 Bundling
|
2005-04-17 06:20:36 +08:00
|
|
|
* ...
|
|
|
|
* 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:
|
2018-05-15 01:35:18 +08:00
|
|
|
error = sctp_packet_singleton(ctx->transport, chunk,
|
|
|
|
ctx->gfp);
|
sctp: save transmit error to sk_err in sctp_outq_flush
Every time when sctp calls sctp_outq_flush, it sends out the chunks of
control queue, retransmit queue and data queue. Even if some trunks are
failed to transmit, it still has to flush all the transports, as it's
the only chance to clean that transmit_list.
So the latest transmit error here should be returned back. This transmit
error is an internal error of sctp stack.
I checked all the places where it uses the transmit error (the return
value of sctp_outq_flush), most of them are actually just save it to
sk_err.
Except for sctp_assoc/endpoint_bh_rcv, they will drop the chunk if
it's failed to send a REPLY, which is actually incorrect, as we can't
be sure the error that sctp_outq_flush returns is from sending that
REPLY.
So it's meaningless for sctp_outq_flush to return error back.
This patch is to save transmit error to sk_err in sctp_outq_flush, the
new error can update the old value. Eventually, sctp_wait_for_* would
check for it.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-09-14 02:04:21 +08:00
|
|
|
if (error < 0) {
|
2018-05-15 01:35:19 +08:00
|
|
|
ctx->asoc->base.sk->sk_err = -error;
|
2016-09-14 02:04:22 +08:00
|
|
|
return;
|
sctp: save transmit error to sk_err in sctp_outq_flush
Every time when sctp calls sctp_outq_flush, it sends out the chunks of
control queue, retransmit queue and data queue. Even if some trunks are
failed to transmit, it still has to flush all the transports, as it's
the only chance to clean that transmit_list.
So the latest transmit error here should be returned back. This transmit
error is an internal error of sctp stack.
I checked all the places where it uses the transmit error (the return
value of sctp_outq_flush), most of them are actually just save it to
sk_err.
Except for sctp_assoc/endpoint_bh_rcv, they will drop the chunk if
it's failed to send a REPLY, which is actually incorrect, as we can't
be sure the error that sctp_outq_flush returns is from sending that
REPLY.
So it's meaningless for sctp_outq_flush to return error back.
This patch is to save transmit error to sk_err in sctp_outq_flush, the
new error can update the old value. Eventually, sctp_wait_for_* would
check for it.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-09-14 02:04:21 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CID_ABORT:
|
2018-01-12 00:22:06 +08:00
|
|
|
if (sctp_test_T_bit(chunk))
|
2018-05-15 01:35:19 +08:00
|
|
|
ctx->packet->vtag = ctx->asoc->c.my_vtag;
|
2018-01-12 00:22:06 +08:00
|
|
|
/* fallthru */
|
2018-05-15 01:34:38 +08:00
|
|
|
|
2008-06-20 07:08:18 +08:00
|
|
|
/* The following chunks are "response" chunks, i.e.
|
|
|
|
* they are generated in response to something we
|
|
|
|
* received. If we are sending these, then we can
|
|
|
|
* send only 1 packet containing these chunks.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
case SCTP_CID_HEARTBEAT_ACK:
|
|
|
|
case SCTP_CID_SHUTDOWN_ACK:
|
|
|
|
case SCTP_CID_COOKIE_ACK:
|
2008-06-20 07:08:18 +08:00
|
|
|
case SCTP_CID_COOKIE_ECHO:
|
|
|
|
case SCTP_CID_ERROR:
|
2005-04-17 06:20:36 +08:00
|
|
|
case SCTP_CID_ECN_CWR:
|
|
|
|
case SCTP_CID_ASCONF_ACK:
|
2008-06-20 07:08:18 +08:00
|
|
|
one_packet = 1;
|
2011-03-31 09:57:33 +08:00
|
|
|
/* Fall through */
|
2008-06-20 07:08:18 +08:00
|
|
|
|
|
|
|
case SCTP_CID_SACK:
|
|
|
|
case SCTP_CID_HEARTBEAT:
|
|
|
|
case SCTP_CID_SHUTDOWN:
|
|
|
|
case SCTP_CID_ECN_ECNE:
|
|
|
|
case SCTP_CID_ASCONF:
|
2005-04-17 06:20:36 +08:00
|
|
|
case SCTP_CID_FWD_TSN:
|
2017-12-15 00:41:26 +08:00
|
|
|
case SCTP_CID_I_FWD_TSN:
|
2017-01-18 00:44:47 +08:00
|
|
|
case SCTP_CID_RECONF:
|
2018-05-15 01:35:19 +08:00
|
|
|
status = sctp_packet_transmit_chunk(ctx->packet, chunk,
|
2018-05-15 01:35:18 +08:00
|
|
|
one_packet, ctx->gfp);
|
2018-05-15 01:34:38 +08:00
|
|
|
if (status != SCTP_XMIT_OK) {
|
2008-06-20 07:08:18 +08:00
|
|
|
/* put the chunk back */
|
2018-05-15 01:35:18 +08:00
|
|
|
list_add(&chunk->list, &ctx->q->control_chunk_list);
|
2017-01-18 00:44:47 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-05-15 01:35:19 +08:00
|
|
|
ctx->asoc->stats.octrlchunks++;
|
2017-01-18 00:44:47 +08:00
|
|
|
/* PR-SCTP C5) If a FORWARD TSN is sent, the
|
|
|
|
* sender MUST assure that at least one T3-rtx
|
|
|
|
* timer is running.
|
|
|
|
*/
|
2017-12-15 00:41:26 +08:00
|
|
|
if (chunk->chunk_hdr->type == SCTP_CID_FWD_TSN ||
|
|
|
|
chunk->chunk_hdr->type == SCTP_CID_I_FWD_TSN) {
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_transport_reset_t3_rtx(ctx->transport);
|
|
|
|
ctx->transport->last_time_sent = jiffies;
|
2008-06-20 07:08:18 +08:00
|
|
|
}
|
2017-01-18 00:44:47 +08:00
|
|
|
|
2018-05-15 01:35:19 +08:00
|
|
|
if (chunk == ctx->asoc->strreset_chunk)
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_transport_reset_reconf_timer(ctx->transport);
|
2017-01-18 00:44:47 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* We built a chunk with an illegal type! */
|
|
|
|
BUG();
|
2007-04-21 08:09:22 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2018-05-15 01:34:38 +08:00
|
|
|
}
|
|
|
|
|
2018-05-15 01:34:39 +08:00
|
|
|
/* Returns false if new data shouldn't be sent */
|
2018-05-15 01:35:18 +08:00
|
|
|
static bool sctp_outq_flush_rtx(struct sctp_flush_ctx *ctx,
|
|
|
|
int rtx_timeout)
|
2018-05-15 01:34:39 +08:00
|
|
|
{
|
|
|
|
int error, start_timer = 0;
|
|
|
|
|
2018-05-15 01:35:19 +08:00
|
|
|
if (ctx->asoc->peer.retran_path->state == SCTP_UNCONFIRMED)
|
2018-05-15 01:34:39 +08:00
|
|
|
return false;
|
|
|
|
|
2018-05-15 01:35:19 +08:00
|
|
|
if (ctx->transport != ctx->asoc->peer.retran_path) {
|
2018-05-15 01:34:39 +08:00
|
|
|
/* Switch transports & prepare the packet. */
|
2018-05-15 01:35:19 +08:00
|
|
|
ctx->transport = ctx->asoc->peer.retran_path;
|
|
|
|
ctx->packet = &ctx->transport->packet;
|
2018-05-15 01:34:39 +08:00
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
if (list_empty(&ctx->transport->send_ready))
|
|
|
|
list_add_tail(&ctx->transport->send_ready,
|
|
|
|
&ctx->transport_list);
|
2018-05-15 01:34:39 +08:00
|
|
|
|
2018-05-15 01:35:19 +08:00
|
|
|
sctp_packet_config(ctx->packet, ctx->asoc->peer.i.init_tag,
|
|
|
|
ctx->asoc->peer.ecn_capable);
|
2018-05-15 01:34:39 +08:00
|
|
|
}
|
|
|
|
|
2018-05-15 01:35:19 +08:00
|
|
|
error = __sctp_outq_flush_rtx(ctx->q, ctx->packet, rtx_timeout,
|
|
|
|
&start_timer, ctx->gfp);
|
2018-05-15 01:34:39 +08:00
|
|
|
if (error < 0)
|
2018-05-15 01:35:19 +08:00
|
|
|
ctx->asoc->base.sk->sk_err = -error;
|
2018-05-15 01:34:39 +08:00
|
|
|
|
|
|
|
if (start_timer) {
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_transport_reset_t3_rtx(ctx->transport);
|
|
|
|
ctx->transport->last_time_sent = jiffies;
|
2018-05-15 01:34:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This can happen on COOKIE-ECHO resend. Only
|
|
|
|
* one chunk can get bundled with a COOKIE-ECHO.
|
|
|
|
*/
|
2018-05-15 01:35:19 +08:00
|
|
|
if (ctx->packet->has_cookie_echo)
|
2018-05-15 01:34:39 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Don't send new data if there is still data
|
|
|
|
* waiting to retransmit.
|
|
|
|
*/
|
2018-05-15 01:35:18 +08:00
|
|
|
if (!list_empty(&ctx->q->retransmit))
|
2018-05-15 01:34:39 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-05-15 01:34:40 +08:00
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
static void sctp_outq_flush_data(struct sctp_flush_ctx *ctx,
|
|
|
|
int rtx_timeout)
|
2018-05-15 01:34:38 +08:00
|
|
|
{
|
|
|
|
struct sctp_chunk *chunk;
|
|
|
|
enum sctp_xmit status;
|
2011-04-26 19:19:36 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Is it OK to send data chunks? */
|
2018-05-15 01:35:19 +08:00
|
|
|
switch (ctx->asoc->state) {
|
2005-04-17 06:20:36 +08:00
|
|
|
case SCTP_STATE_COOKIE_ECHOED:
|
|
|
|
/* Only allow bundling when this packet has a COOKIE-ECHO
|
|
|
|
* chunk.
|
|
|
|
*/
|
2018-05-15 01:35:19 +08:00
|
|
|
if (!ctx->packet || !ctx->packet->has_cookie_echo)
|
2018-05-15 01:34:43 +08:00
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-10-03 18:45:56 +08:00
|
|
|
/* fall through */
|
2005-04-17 06:20:36 +08:00
|
|
|
case SCTP_STATE_ESTABLISHED:
|
|
|
|
case SCTP_STATE_SHUTDOWN_PENDING:
|
|
|
|
case SCTP_STATE_SHUTDOWN_RECEIVED:
|
2018-05-15 01:34:43 +08:00
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-15 01:34:43 +08:00
|
|
|
default:
|
|
|
|
/* Do nothing. */
|
|
|
|
return;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-15 01:35:20 +08:00
|
|
|
/* RFC 2960 6.1 Transmission of DATA Chunks
|
2018-05-15 01:34:43 +08:00
|
|
|
*
|
|
|
|
* C) When the time comes for the sender to transmit,
|
|
|
|
* before sending new DATA chunks, the sender MUST
|
|
|
|
* first transmit any outstanding DATA chunks which
|
|
|
|
* are marked for retransmission (limited by the
|
|
|
|
* current cwnd).
|
|
|
|
*/
|
2018-05-15 01:35:19 +08:00
|
|
|
if (!list_empty(&ctx->q->retransmit) &&
|
|
|
|
!sctp_outq_flush_rtx(ctx, rtx_timeout))
|
|
|
|
return;
|
2017-01-18 00:44:47 +08:00
|
|
|
|
2018-05-15 01:34:43 +08:00
|
|
|
/* Apply Max.Burst limitation to the current transport in
|
|
|
|
* case it will be used for new data. We are going to
|
|
|
|
* rest it before we return, but we want to apply the limit
|
|
|
|
* to the currently queued data.
|
|
|
|
*/
|
2018-05-15 01:35:18 +08:00
|
|
|
if (ctx->transport)
|
|
|
|
sctp_transport_burst_limited(ctx->transport);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-15 01:34:43 +08:00
|
|
|
/* Finally, transmit new packets. */
|
2018-05-15 01:35:18 +08:00
|
|
|
while ((chunk = sctp_outq_dequeue_data(ctx->q)) != NULL) {
|
2018-05-15 01:34:43 +08:00
|
|
|
__u32 sid = ntohs(chunk->subh.data_hdr->stream);
|
2018-08-11 01:11:42 +08:00
|
|
|
__u8 stream_state = SCTP_SO(&ctx->asoc->stream, sid)->state;
|
2018-05-15 01:34:40 +08:00
|
|
|
|
2018-05-15 01:34:43 +08:00
|
|
|
/* Has this chunk expired? */
|
|
|
|
if (sctp_chunk_abandoned(chunk)) {
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_sched_dequeue_done(ctx->q, chunk);
|
2018-05-15 01:34:43 +08:00
|
|
|
sctp_chunk_fail(chunk, 0);
|
|
|
|
sctp_chunk_free(chunk);
|
|
|
|
continue;
|
|
|
|
}
|
net: sctp: rework debugging framework to use pr_debug and friends
We should get rid of all own SCTP debug printk macros and use the ones
that the kernel offers anyway instead. This makes the code more readable
and conform to the kernel code, and offers all the features of dynamic
debbuging that pr_debug() et al has, such as only turning on/off portions
of debug messages at runtime through debugfs. The runtime cost of having
CONFIG_DYNAMIC_DEBUG enabled, but none of the debug statements printing,
is negligible [1]. If kernel debugging is completly turned off, then these
statements will also compile into "empty" functions.
While we're at it, we also need to change the Kconfig option as it /now/
only refers to the ifdef'ed code portions in outqueue.c that enable further
debugging/tracing of SCTP transaction fields. Also, since SCTP_ASSERT code
was enabled with this Kconfig option and has now been removed, we
transform those code parts into WARNs resp. where appropriate BUG_ONs so
that those bugs can be more easily detected as probably not many people
have SCTP debugging permanently turned on.
To turn on all SCTP debugging, the following steps are needed:
# mount -t debugfs none /sys/kernel/debug
# echo -n 'module sctp +p' > /sys/kernel/debug/dynamic_debug/control
This can be done more fine-grained on a per file, per line basis and others
as described in [2].
[1] https://www.kernel.org/doc/ols/2009/ols2009-pages-39-46.pdf
[2] Documentation/dynamic-debug-howto.txt
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-29 01:49:40 +08:00
|
|
|
|
2018-08-11 01:11:42 +08:00
|
|
|
if (stream_state == SCTP_STREAM_CLOSED) {
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_outq_head_data(ctx->q, chunk);
|
2018-05-15 01:34:43 +08:00
|
|
|
break;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-15 01:35:19 +08:00
|
|
|
sctp_outq_select_transport(ctx, chunk);
|
2018-05-15 01:34:40 +08:00
|
|
|
|
2018-05-15 01:35:20 +08:00
|
|
|
pr_debug("%s: outq:%p, chunk:%p[%s], tx-tsn:0x%x skb->head:%p skb->users:%d\n",
|
2018-05-15 01:35:18 +08:00
|
|
|
__func__, ctx->q, chunk, chunk && chunk->chunk_hdr ?
|
2018-05-15 01:34:43 +08:00
|
|
|
sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)) :
|
|
|
|
"illegal chunk", ntohl(chunk->subh.data_hdr->tsn),
|
|
|
|
chunk->skb ? chunk->skb->head : NULL, chunk->skb ?
|
|
|
|
refcount_read(&chunk->skb->users) : -1);
|
|
|
|
|
|
|
|
/* Add the chunk to the packet. */
|
2018-05-15 01:35:19 +08:00
|
|
|
status = sctp_packet_transmit_chunk(ctx->packet, chunk, 0,
|
|
|
|
ctx->gfp);
|
2018-05-15 01:34:43 +08:00
|
|
|
if (status != SCTP_XMIT_OK) {
|
|
|
|
/* We could not append this chunk, so put
|
|
|
|
* the chunk back on the output queue.
|
2018-05-15 01:34:40 +08:00
|
|
|
*/
|
2018-05-15 01:34:43 +08:00
|
|
|
pr_debug("%s: could not transmit tsn:0x%x, status:%d\n",
|
|
|
|
__func__, ntohl(chunk->subh.data_hdr->tsn),
|
|
|
|
status);
|
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_outq_head_data(ctx->q, chunk);
|
2018-05-15 01:34:43 +08:00
|
|
|
break;
|
|
|
|
}
|
2018-05-15 01:34:40 +08:00
|
|
|
|
2018-05-15 01:34:43 +08:00
|
|
|
/* The sender is in the SHUTDOWN-PENDING state,
|
|
|
|
* The sender MAY set the I-bit in the DATA
|
|
|
|
* chunk header.
|
|
|
|
*/
|
2018-05-15 01:35:19 +08:00
|
|
|
if (ctx->asoc->state == SCTP_STATE_SHUTDOWN_PENDING)
|
2018-05-15 01:34:43 +08:00
|
|
|
chunk->chunk_hdr->flags |= SCTP_DATA_SACK_IMM;
|
|
|
|
if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED)
|
2018-05-15 01:35:19 +08:00
|
|
|
ctx->asoc->stats.ouodchunks++;
|
2018-05-15 01:34:43 +08:00
|
|
|
else
|
2018-05-15 01:35:19 +08:00
|
|
|
ctx->asoc->stats.oodchunks++;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-15 01:34:43 +08:00
|
|
|
/* Only now it's safe to consider this
|
|
|
|
* chunk as sent, sched-wise.
|
|
|
|
*/
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_sched_dequeue_done(ctx->q, chunk);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-15 01:34:43 +08:00
|
|
|
list_add_tail(&chunk->transmitted_list,
|
2018-05-15 01:35:18 +08:00
|
|
|
&ctx->transport->transmitted);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_transport_reset_t3_rtx(ctx->transport);
|
|
|
|
ctx->transport->last_time_sent = jiffies;
|
2018-05-15 01:34:43 +08:00
|
|
|
|
|
|
|
/* Only let one DATA chunk get bundled with a
|
|
|
|
* COOKIE-ECHO chunk.
|
|
|
|
*/
|
2018-05-15 01:35:19 +08:00
|
|
|
if (ctx->packet->has_cookie_echo)
|
2018-05-15 01:34:43 +08:00
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2018-05-15 01:34:40 +08:00
|
|
|
}
|
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
static void sctp_outq_flush_transports(struct sctp_flush_ctx *ctx)
|
2018-05-15 01:34:41 +08:00
|
|
|
{
|
|
|
|
struct list_head *ltransport;
|
|
|
|
struct sctp_packet *packet;
|
|
|
|
struct sctp_transport *t;
|
|
|
|
int error = 0;
|
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
while ((ltransport = sctp_list_dequeue(&ctx->transport_list)) != NULL) {
|
2018-05-15 01:34:41 +08:00
|
|
|
t = list_entry(ltransport, struct sctp_transport, send_ready);
|
|
|
|
packet = &t->packet;
|
|
|
|
if (!sctp_packet_empty(packet)) {
|
2018-05-15 01:35:18 +08:00
|
|
|
error = sctp_packet_transmit(packet, ctx->gfp);
|
2018-05-15 01:34:41 +08:00
|
|
|
if (error < 0)
|
2018-05-15 01:35:18 +08:00
|
|
|
ctx->q->asoc->base.sk->sk_err = -error;
|
2018-05-15 01:34:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the burst limited state, if any */
|
|
|
|
sctp_transport_burst_reset(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-15 01:35:20 +08:00
|
|
|
/* Try to flush an outqueue.
|
2018-05-15 01:34:40 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2018-05-15 01:35:18 +08:00
|
|
|
|
2018-05-15 01:34:40 +08:00
|
|
|
static void sctp_outq_flush(struct sctp_outq *q, int rtx_timeout, gfp_t gfp)
|
|
|
|
{
|
2018-05-15 01:35:18 +08:00
|
|
|
struct sctp_flush_ctx ctx = {
|
|
|
|
.q = q,
|
|
|
|
.transport = NULL,
|
|
|
|
.transport_list = LIST_HEAD_INIT(ctx.transport_list),
|
2018-05-15 01:35:19 +08:00
|
|
|
.asoc = q->asoc,
|
|
|
|
.packet = NULL,
|
2018-05-15 01:35:18 +08:00
|
|
|
.gfp = gfp,
|
|
|
|
};
|
2018-05-15 01:34:40 +08:00
|
|
|
|
2018-05-15 01:35:20 +08:00
|
|
|
/* 6.10 Bundling
|
2018-05-15 01:34:40 +08:00
|
|
|
* ...
|
|
|
|
* 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.
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_outq_flush_ctrl(&ctx);
|
2018-05-15 01:34:40 +08:00
|
|
|
|
|
|
|
if (q->asoc->src_out_of_asoc_ok)
|
|
|
|
goto sctp_flush_out;
|
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_outq_flush_data(&ctx, rtx_timeout);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
sctp_flush_out:
|
|
|
|
|
2018-05-15 01:35:18 +08:00
|
|
|
sctp_outq_flush_transports(&ctx);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update unack_data based on the incoming SACK chunk */
|
|
|
|
static void sctp_sack_update_unack_data(struct sctp_association *assoc,
|
|
|
|
struct sctp_sackhdr *sack)
|
|
|
|
{
|
2017-07-23 09:34:31 +08:00
|
|
|
union sctp_sack_variable *frags;
|
2005-04-17 06:20:36 +08:00
|
|
|
__u16 unack_data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
unack_data = assoc->next_tsn - assoc->ctsn_ack_point - 1;
|
|
|
|
|
|
|
|
frags = sack->variable;
|
|
|
|
for (i = 0; i < ntohs(sack->num_gap_ack_blocks); i++) {
|
|
|
|
unack_data -= ((ntohs(frags[i].gab.end) -
|
|
|
|
ntohs(frags[i].gab.start) + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
assoc->unack_data = unack_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is where we REALLY process a SACK.
|
|
|
|
*
|
|
|
|
* Process the SACK against the outqueue. Mostly, this just frees
|
|
|
|
* things off the transmitted queue.
|
|
|
|
*/
|
2012-10-03 13:43:22 +08:00
|
|
|
int sctp_outq_sack(struct sctp_outq *q, struct sctp_chunk *chunk)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct sctp_association *asoc = q->asoc;
|
2012-10-03 13:43:22 +08:00
|
|
|
struct sctp_sackhdr *sack = chunk->subh.sack_hdr;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct sctp_transport *transport;
|
|
|
|
struct sctp_chunk *tchunk = NULL;
|
2008-04-13 09:54:24 +08:00
|
|
|
struct list_head *lchunk, *transport_list, *temp;
|
2017-07-23 09:34:31 +08:00
|
|
|
union sctp_sack_variable *frags = sack->variable;
|
2005-04-17 06:20:36 +08:00
|
|
|
__u32 sack_ctsn, ctsn, tsn;
|
|
|
|
__u32 highest_tsn, highest_new_tsn;
|
|
|
|
__u32 sack_a_rwnd;
|
2012-04-15 13:58:06 +08:00
|
|
|
unsigned int outstanding;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct sctp_transport *primary = asoc->peer.primary_path;
|
|
|
|
int count_of_newacks = 0;
|
2008-06-20 05:59:13 +08:00
|
|
|
int gap_ack_blocks;
|
2010-05-01 10:41:10 +08:00
|
|
|
u8 accum_moved = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Grab the association's destination address list. */
|
|
|
|
transport_list = &asoc->peer.transport_addr_list;
|
|
|
|
|
|
|
|
sack_ctsn = ntohl(sack->cum_tsn_ack);
|
2008-06-20 05:59:13 +08:00
|
|
|
gap_ack_blocks = ntohs(sack->num_gap_ack_blocks);
|
2012-12-01 12:49:42 +08:00
|
|
|
asoc->stats.gapcnt += gap_ack_blocks;
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* SFR-CACC algorithm:
|
|
|
|
* On receipt of a SACK the sender SHOULD execute the
|
|
|
|
* following statements.
|
|
|
|
*
|
|
|
|
* 1) If the cumulative ack in the SACK passes next tsn_at_change
|
|
|
|
* on the current primary, the CHANGEOVER_ACTIVE flag SHOULD be
|
|
|
|
* cleared. The CYCLING_CHANGEOVER flag SHOULD also be cleared for
|
|
|
|
* all destinations.
|
|
|
|
* 2) If the SACK contains gap acks and the flag CHANGEOVER_ACTIVE
|
|
|
|
* is set the receiver of the SACK MUST take the following actions:
|
|
|
|
*
|
|
|
|
* A) Initialize the cacc_saw_newack to 0 for all destination
|
|
|
|
* addresses.
|
2008-06-20 06:17:24 +08:00
|
|
|
*
|
|
|
|
* Only bother if changeover_active is set. Otherwise, this is
|
|
|
|
* totally suboptimal to do on every SACK.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2008-06-20 06:17:24 +08:00
|
|
|
if (primary->cacc.changeover_active) {
|
|
|
|
u8 clear_cycling = 0;
|
|
|
|
|
|
|
|
if (TSN_lte(primary->cacc.next_tsn_at_change, sack_ctsn)) {
|
|
|
|
primary->cacc.changeover_active = 0;
|
|
|
|
clear_cycling = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clear_cycling || gap_ack_blocks) {
|
|
|
|
list_for_each_entry(transport, transport_list,
|
|
|
|
transports) {
|
|
|
|
if (clear_cycling)
|
|
|
|
transport->cacc.cycling_changeover = 0;
|
|
|
|
if (gap_ack_blocks)
|
|
|
|
transport->cacc.cacc_saw_newack = 0;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the highest TSN in the sack. */
|
|
|
|
highest_tsn = sack_ctsn;
|
2008-06-20 05:59:13 +08:00
|
|
|
if (gap_ack_blocks)
|
|
|
|
highest_tsn += ntohs(frags[gap_ack_blocks - 1].gab.end);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-05-01 10:41:10 +08:00
|
|
|
if (TSN_lt(asoc->highest_sacked, highest_tsn))
|
2005-04-17 06:20:36 +08:00
|
|
|
asoc->highest_sacked = highest_tsn;
|
|
|
|
|
2010-05-01 10:41:10 +08:00
|
|
|
highest_new_tsn = sack_ctsn;
|
2008-06-20 05:59:13 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Run through the retransmit queue. Credit bytes received
|
|
|
|
* and free those chunks that we can.
|
|
|
|
*/
|
2012-10-03 13:43:22 +08:00
|
|
|
sctp_check_transmitted(q, &q->retransmit, NULL, NULL, sack, &highest_new_tsn);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Run through the transmitted queue.
|
|
|
|
* Credit bytes received and free those chunks which we can.
|
|
|
|
*
|
|
|
|
* This is a MASSIVE candidate for optimization.
|
|
|
|
*/
|
2008-04-13 09:54:24 +08:00
|
|
|
list_for_each_entry(transport, transport_list, transports) {
|
2005-04-17 06:20:36 +08:00
|
|
|
sctp_check_transmitted(q, &transport->transmitted,
|
2012-10-03 13:43:22 +08:00
|
|
|
transport, &chunk->source, sack,
|
|
|
|
&highest_new_tsn);
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* SFR-CACC algorithm:
|
|
|
|
* C) Let count_of_newacks be the number of
|
|
|
|
* destinations for which cacc_saw_newack is set.
|
|
|
|
*/
|
|
|
|
if (transport->cacc.cacc_saw_newack)
|
2013-12-23 12:16:50 +08:00
|
|
|
count_of_newacks++;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2010-05-01 10:41:10 +08:00
|
|
|
/* Move the Cumulative TSN Ack Point if appropriate. */
|
|
|
|
if (TSN_lt(asoc->ctsn_ack_point, sack_ctsn)) {
|
|
|
|
asoc->ctsn_ack_point = sack_ctsn;
|
|
|
|
accum_moved = 1;
|
|
|
|
}
|
|
|
|
|
2008-06-20 05:59:13 +08:00
|
|
|
if (gap_ack_blocks) {
|
2010-05-01 10:41:10 +08:00
|
|
|
|
|
|
|
if (asoc->fast_recovery && accum_moved)
|
|
|
|
highest_new_tsn = highest_tsn;
|
|
|
|
|
2008-06-20 05:59:13 +08:00
|
|
|
list_for_each_entry(transport, transport_list, transports)
|
|
|
|
sctp_mark_missing(q, &transport->transmitted, transport,
|
|
|
|
highest_new_tsn, count_of_newacks);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update unack_data field in the assoc. */
|
|
|
|
sctp_sack_update_unack_data(asoc, sack);
|
|
|
|
|
|
|
|
ctsn = asoc->ctsn_ack_point;
|
|
|
|
|
|
|
|
/* Throw away stuff rotting on the sack queue. */
|
|
|
|
list_for_each_safe(lchunk, temp, &q->sacked) {
|
|
|
|
tchunk = list_entry(lchunk, struct sctp_chunk,
|
|
|
|
transmitted_list);
|
|
|
|
tsn = ntohl(tchunk->subh.data_hdr->tsn);
|
2008-02-06 03:23:44 +08:00
|
|
|
if (TSN_lte(tsn, ctsn)) {
|
|
|
|
list_del_init(&tchunk->transmitted_list);
|
2016-09-29 02:37:28 +08:00
|
|
|
if (asoc->peer.prsctp_capable &&
|
sctp: implement prsctp PRIO policy
prsctp PRIO policy is a policy to abandon lower priority chunks when
asoc doesn't have enough snd buffer, so that the current chunk with
higher priority can be queued successfully.
Similar to TTL/RTX policy, we will set the priority of the chunk to
prsctp_param with sinfo->sinfo_timetolive in sctp_set_prsctp_policy().
So if PRIO policy is enabled, msg->expire_at won't work.
asoc->sent_cnt_removable will record how many chunks can be checked to
remove. If priority policy is enabled, when the chunk is queued into
the out_queue, we will increase sent_cnt_removable. When the chunk is
moved to abandon_queue or dequeue and free, we will decrease
sent_cnt_removable.
In sctp_sendmsg, we will check if there is enough snd buffer for current
msg and if sent_cnt_removable is not 0. Then try to abandon chunks in
sctp_prune_prsctp when sendmsg from the retransmit/transmited queue, and
free chunks from out_queue in right order until the abandon+free size >
msg_len - sctp_wfree. For the abandon size, we have to wait until it
sends FORWARD TSN, receives the sack and the chunks are really freed.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-09 19:47:45 +08:00
|
|
|
SCTP_PR_PRIO_ENABLED(chunk->sinfo.sinfo_flags))
|
|
|
|
asoc->sent_cnt_removable--;
|
2005-04-17 06:20:36 +08:00
|
|
|
sctp_chunk_free(tchunk);
|
2008-02-06 03:23:44 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ii) Set rwnd equal to the newly received a_rwnd minus the
|
|
|
|
* number of bytes still outstanding after processing the
|
|
|
|
* Cumulative TSN Ack and the Gap Ack Blocks.
|
|
|
|
*/
|
|
|
|
|
|
|
|
sack_a_rwnd = ntohl(sack->a_rwnd);
|
sctp: start t5 timer only when peer rwnd is 0 and local state is SHUTDOWN_PENDING
when A sends a data to B, then A close() and enter into SHUTDOWN_PENDING
state, if B neither claim his rwnd is 0 nor send SACK for this data, A
will keep retransmitting this data until t5 timeout, Max.Retrans times
can't work anymore, which is bad.
if B's rwnd is not 0, it should send abort after Max.Retrans times, only
when B's rwnd == 0 and A's retransmitting beyonds Max.Retrans times, A
will start t5 timer, which is also commit f8d960524328 ("sctp: Enforce
retransmission limit during shutdown") means, but it lacks the condition
peer rwnd == 0.
so fix it by adding a bit (zero_window_announced) in peer to record if
the last rwnd is 0. If it was, zero_window_announced will be set. and use
this bit to decide if start t5 timer when local.state is SHUTDOWN_PENDING.
Fixes: commit f8d960524328 ("sctp: Enforce retransmission limit during shutdown")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-12-05 15:35:36 +08:00
|
|
|
asoc->peer.zero_window_announced = !sack_a_rwnd;
|
2005-04-17 06:20:36 +08:00
|
|
|
outstanding = q->outstanding_bytes;
|
|
|
|
|
|
|
|
if (outstanding < sack_a_rwnd)
|
|
|
|
sack_a_rwnd -= outstanding;
|
|
|
|
else
|
|
|
|
sack_a_rwnd = 0;
|
|
|
|
|
|
|
|
asoc->peer.rwnd = sack_a_rwnd;
|
|
|
|
|
2017-12-15 00:41:26 +08:00
|
|
|
asoc->stream.si->generate_ftsn(q, sack_ctsn);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
net: sctp: rework debugging framework to use pr_debug and friends
We should get rid of all own SCTP debug printk macros and use the ones
that the kernel offers anyway instead. This makes the code more readable
and conform to the kernel code, and offers all the features of dynamic
debbuging that pr_debug() et al has, such as only turning on/off portions
of debug messages at runtime through debugfs. The runtime cost of having
CONFIG_DYNAMIC_DEBUG enabled, but none of the debug statements printing,
is negligible [1]. If kernel debugging is completly turned off, then these
statements will also compile into "empty" functions.
While we're at it, we also need to change the Kconfig option as it /now/
only refers to the ifdef'ed code portions in outqueue.c that enable further
debugging/tracing of SCTP transaction fields. Also, since SCTP_ASSERT code
was enabled with this Kconfig option and has now been removed, we
transform those code parts into WARNs resp. where appropriate BUG_ONs so
that those bugs can be more easily detected as probably not many people
have SCTP debugging permanently turned on.
To turn on all SCTP debugging, the following steps are needed:
# mount -t debugfs none /sys/kernel/debug
# echo -n 'module sctp +p' > /sys/kernel/debug/dynamic_debug/control
This can be done more fine-grained on a per file, per line basis and others
as described in [2].
[1] https://www.kernel.org/doc/ols/2009/ols2009-pages-39-46.pdf
[2] Documentation/dynamic-debug-howto.txt
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-29 01:49:40 +08:00
|
|
|
pr_debug("%s: sack cumulative tsn ack:0x%x\n", __func__, sack_ctsn);
|
|
|
|
pr_debug("%s: cumulative tsn ack of assoc:%p is 0x%x, "
|
|
|
|
"advertised peer ack point:0x%x\n", __func__, asoc, ctsn,
|
|
|
|
asoc->adv_peer_ack_point);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-01-03 03:39:44 +08:00
|
|
|
return sctp_outq_is_empty(q);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2014-01-03 03:39:44 +08:00
|
|
|
/* Is the outqueue empty?
|
|
|
|
* The queue is empty when we have not pending data, no in-flight data
|
|
|
|
* and nothing pending retransmissions.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
int sctp_outq_is_empty(const struct sctp_outq *q)
|
|
|
|
{
|
2014-01-03 03:39:44 +08:00
|
|
|
return q->out_qlen == 0 && q->outstanding_bytes == 0 &&
|
|
|
|
list_empty(&q->retransmit);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* 2nd Level Abstractions
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
/* Go through a transport's transmitted list or the association's retransmit
|
|
|
|
* list and move chunks that are acked by the Cumulative TSN Ack to q->sacked.
|
|
|
|
* The retransmit list will not have an associated transport.
|
|
|
|
*
|
|
|
|
* I added coherent debug information output. --xguo
|
|
|
|
*
|
|
|
|
* Instead of printing 'sacked' or 'kept' for each TSN on the
|
|
|
|
* transmitted_queue, we print a range: SACKED: TSN1-TSN2, TSN3, TSN4-TSN5.
|
|
|
|
* KEPT TSN6-TSN7, etc.
|
|
|
|
*/
|
|
|
|
static void sctp_check_transmitted(struct sctp_outq *q,
|
|
|
|
struct list_head *transmitted_queue,
|
|
|
|
struct sctp_transport *transport,
|
2012-10-03 13:43:22 +08:00
|
|
|
union sctp_addr *saddr,
|
2005-04-17 06:20:36 +08:00
|
|
|
struct sctp_sackhdr *sack,
|
2010-05-01 10:41:10 +08:00
|
|
|
__u32 *highest_new_tsn_in_sack)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct list_head *lchunk;
|
|
|
|
struct sctp_chunk *tchunk;
|
|
|
|
struct list_head tlist;
|
|
|
|
__u32 tsn;
|
|
|
|
__u32 sack_ctsn;
|
|
|
|
__u32 rtt;
|
|
|
|
__u8 restart_timer = 0;
|
|
|
|
int bytes_acked = 0;
|
2009-09-05 06:21:00 +08:00
|
|
|
int migrate_bytes = 0;
|
2013-07-09 22:17:04 +08:00
|
|
|
bool forward_progress = false;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
sack_ctsn = ntohl(sack->cum_tsn_ack);
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&tlist);
|
|
|
|
|
|
|
|
/* The while loop will skip empty transmitted queues. */
|
|
|
|
while (NULL != (lchunk = sctp_list_dequeue(transmitted_queue))) {
|
|
|
|
tchunk = list_entry(lchunk, struct sctp_chunk,
|
|
|
|
transmitted_list);
|
|
|
|
|
|
|
|
if (sctp_chunk_abandoned(tchunk)) {
|
|
|
|
/* Move the chunk to abandoned list. */
|
|
|
|
sctp_insert_list(&q->abandoned, lchunk);
|
2007-02-21 18:06:04 +08:00
|
|
|
|
|
|
|
/* If this chunk has not been acked, stop
|
|
|
|
* considering it as 'outstanding'.
|
|
|
|
*/
|
2017-11-25 21:18:34 +08:00
|
|
|
if (transmitted_queue != &q->retransmit &&
|
|
|
|
!tchunk->tsn_gap_acked) {
|
2009-09-05 06:21:00 +08:00
|
|
|
if (tchunk->transport)
|
|
|
|
tchunk->transport->flight_size -=
|
|
|
|
sctp_data_size(tchunk);
|
2007-02-21 18:06:04 +08:00
|
|
|
q->outstanding_bytes -= sctp_data_size(tchunk);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
tsn = ntohl(tchunk->subh.data_hdr->tsn);
|
|
|
|
if (sctp_acked(sack, tsn)) {
|
|
|
|
/* If this queue is the retransmit queue, the
|
|
|
|
* retransmit timer has already reclaimed
|
|
|
|
* the outstanding bytes for this chunk, so only
|
|
|
|
* count bytes associated with a transport.
|
|
|
|
*/
|
2018-04-25 05:17:35 +08:00
|
|
|
if (transport && !tchunk->tsn_gap_acked) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* If this chunk is being used for RTT
|
|
|
|
* measurement, calculate the RTT and update
|
|
|
|
* the RTO using this value.
|
|
|
|
*
|
|
|
|
* 6.3.1 C5) Karn's algorithm: RTT measurements
|
|
|
|
* MUST NOT be made using packets that were
|
|
|
|
* retransmitted (and thus for which it is
|
|
|
|
* ambiguous whether the reply was for the
|
|
|
|
* first instance of the packet or a later
|
|
|
|
* instance).
|
|
|
|
*/
|
2018-04-25 05:17:35 +08:00
|
|
|
if (!sctp_chunk_retransmitted(tchunk) &&
|
2005-04-17 06:20:36 +08:00
|
|
|
tchunk->rtt_in_progress) {
|
2006-06-18 13:56:08 +08:00
|
|
|
tchunk->rtt_in_progress = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
rtt = jiffies - tchunk->sent_at;
|
|
|
|
sctp_transport_update_rto(transport,
|
|
|
|
rtt);
|
|
|
|
}
|
2018-04-25 05:17:35 +08:00
|
|
|
|
|
|
|
if (TSN_lte(tsn, sack_ctsn)) {
|
|
|
|
/*
|
|
|
|
* SFR-CACC algorithm:
|
|
|
|
* 2) If the SACK contains gap acks
|
|
|
|
* and the flag CHANGEOVER_ACTIVE is
|
|
|
|
* set the receiver of the SACK MUST
|
|
|
|
* take the following action:
|
|
|
|
*
|
|
|
|
* B) For each TSN t being acked that
|
|
|
|
* has not been acked in any SACK so
|
|
|
|
* far, set cacc_saw_newack to 1 for
|
|
|
|
* the destination that the TSN was
|
|
|
|
* sent to.
|
|
|
|
*/
|
|
|
|
if (sack->num_gap_ack_blocks &&
|
|
|
|
q->asoc->peer.primary_path->cacc.
|
|
|
|
changeover_active)
|
|
|
|
transport->cacc.cacc_saw_newack
|
|
|
|
= 1;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2009-09-05 06:21:00 +08:00
|
|
|
|
|
|
|
/* If the chunk hasn't been marked as ACKED,
|
|
|
|
* mark it and account bytes_acked if the
|
|
|
|
* chunk had a valid transport (it will not
|
|
|
|
* have a transport if ASCONF had deleted it
|
|
|
|
* while DATA was outstanding).
|
|
|
|
*/
|
|
|
|
if (!tchunk->tsn_gap_acked) {
|
|
|
|
tchunk->tsn_gap_acked = 1;
|
2013-11-22 05:56:28 +08:00
|
|
|
if (TSN_lt(*highest_new_tsn_in_sack, tsn))
|
|
|
|
*highest_new_tsn_in_sack = tsn;
|
2009-09-05 06:21:00 +08:00
|
|
|
bytes_acked += sctp_data_size(tchunk);
|
|
|
|
if (!tchunk->transport)
|
|
|
|
migrate_bytes += sctp_data_size(tchunk);
|
2013-07-09 22:17:04 +08:00
|
|
|
forward_progress = true;
|
2009-09-05 06:21:00 +08:00
|
|
|
}
|
|
|
|
|
2007-02-09 22:25:18 +08:00
|
|
|
if (TSN_lte(tsn, sack_ctsn)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* RFC 2960 6.3.2 Retransmission Timer Rules
|
|
|
|
*
|
|
|
|
* R3) Whenever a SACK is received
|
|
|
|
* that acknowledges the DATA chunk
|
|
|
|
* with the earliest outstanding TSN
|
|
|
|
* for that address, restart T3-rtx
|
|
|
|
* timer for that address with its
|
|
|
|
* current RTO.
|
|
|
|
*/
|
|
|
|
restart_timer = 1;
|
2013-07-09 22:17:04 +08:00
|
|
|
forward_progress = true;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
list_add_tail(&tchunk->transmitted_list,
|
|
|
|
&q->sacked);
|
|
|
|
} else {
|
|
|
|
/* RFC2960 7.2.4, sctpimpguide-05 2.8.2
|
|
|
|
* M2) Each time a SACK arrives reporting
|
|
|
|
* 'Stray DATA chunk(s)' record the highest TSN
|
|
|
|
* reported as newly acknowledged, call this
|
|
|
|
* value 'HighestTSNinSack'. A newly
|
|
|
|
* acknowledged DATA chunk is one not
|
|
|
|
* previously acknowledged in a SACK.
|
|
|
|
*
|
|
|
|
* When the SCTP sender of data receives a SACK
|
|
|
|
* chunk that acknowledges, for the first time,
|
|
|
|
* the receipt of a DATA chunk, all the still
|
|
|
|
* unacknowledged DATA chunks whose TSN is
|
|
|
|
* older than that newly acknowledged DATA
|
|
|
|
* chunk, are qualified as 'Stray DATA chunks'.
|
|
|
|
*/
|
|
|
|
list_add_tail(lchunk, &tlist);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (tchunk->tsn_gap_acked) {
|
net: sctp: rework debugging framework to use pr_debug and friends
We should get rid of all own SCTP debug printk macros and use the ones
that the kernel offers anyway instead. This makes the code more readable
and conform to the kernel code, and offers all the features of dynamic
debbuging that pr_debug() et al has, such as only turning on/off portions
of debug messages at runtime through debugfs. The runtime cost of having
CONFIG_DYNAMIC_DEBUG enabled, but none of the debug statements printing,
is negligible [1]. If kernel debugging is completly turned off, then these
statements will also compile into "empty" functions.
While we're at it, we also need to change the Kconfig option as it /now/
only refers to the ifdef'ed code portions in outqueue.c that enable further
debugging/tracing of SCTP transaction fields. Also, since SCTP_ASSERT code
was enabled with this Kconfig option and has now been removed, we
transform those code parts into WARNs resp. where appropriate BUG_ONs so
that those bugs can be more easily detected as probably not many people
have SCTP debugging permanently turned on.
To turn on all SCTP debugging, the following steps are needed:
# mount -t debugfs none /sys/kernel/debug
# echo -n 'module sctp +p' > /sys/kernel/debug/dynamic_debug/control
This can be done more fine-grained on a per file, per line basis and others
as described in [2].
[1] https://www.kernel.org/doc/ols/2009/ols2009-pages-39-46.pdf
[2] Documentation/dynamic-debug-howto.txt
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-29 01:49:40 +08:00
|
|
|
pr_debug("%s: receiver reneged on data TSN:0x%x\n",
|
|
|
|
__func__, tsn);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
tchunk->tsn_gap_acked = 0;
|
|
|
|
|
2009-09-05 06:21:00 +08:00
|
|
|
if (tchunk->transport)
|
|
|
|
bytes_acked -= sctp_data_size(tchunk);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* RFC 2960 6.3.2 Retransmission Timer Rules
|
|
|
|
*
|
|
|
|
* R4) Whenever a SACK is received missing a
|
|
|
|
* TSN that was previously acknowledged via a
|
|
|
|
* Gap Ack Block, start T3-rtx for the
|
|
|
|
* destination address to which the DATA
|
|
|
|
* chunk was originally
|
|
|
|
* transmitted if it is not already running.
|
|
|
|
*/
|
|
|
|
restart_timer = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
list_add_tail(lchunk, &tlist);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transport) {
|
|
|
|
if (bytes_acked) {
|
2011-07-07 08:28:35 +08:00
|
|
|
struct sctp_association *asoc = transport->asoc;
|
|
|
|
|
2009-09-05 06:21:00 +08:00
|
|
|
/* We may have counted DATA that was migrated
|
|
|
|
* to this transport due to DEL-IP operation.
|
|
|
|
* Subtract those bytes, since the were never
|
|
|
|
* send on this transport and shouldn't be
|
|
|
|
* credited to this transport.
|
|
|
|
*/
|
|
|
|
bytes_acked -= migrate_bytes;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* 8.2. When an outstanding TSN is acknowledged,
|
|
|
|
* the endpoint shall clear the error counter of
|
|
|
|
* the destination transport address to which the
|
|
|
|
* DATA chunk was last sent.
|
|
|
|
* The association's overall error counter is
|
|
|
|
* also cleared.
|
|
|
|
*/
|
|
|
|
transport->error_count = 0;
|
|
|
|
transport->asoc->overall_error_count = 0;
|
2013-07-09 22:17:04 +08:00
|
|
|
forward_progress = true;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2011-07-07 08:28:35 +08:00
|
|
|
/*
|
|
|
|
* While in SHUTDOWN PENDING, we may have started
|
|
|
|
* the T5 shutdown guard timer after reaching the
|
|
|
|
* retransmission limit. Stop that timer as soon
|
|
|
|
* as the receiver acknowledged any data.
|
|
|
|
*/
|
|
|
|
if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING &&
|
|
|
|
del_timer(&asoc->timers
|
|
|
|
[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD]))
|
|
|
|
sctp_association_put(asoc);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Mark the destination transport address as
|
|
|
|
* active if it is not so marked.
|
|
|
|
*/
|
2012-10-03 13:43:22 +08:00
|
|
|
if ((transport->state == SCTP_INACTIVE ||
|
|
|
|
transport->state == SCTP_UNCONFIRMED) &&
|
|
|
|
sctp_cmp_addr_exact(&transport->ipaddr, saddr)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
sctp_assoc_control_transport(
|
|
|
|
transport->asoc,
|
|
|
|
transport,
|
|
|
|
SCTP_TRANSPORT_UP,
|
|
|
|
SCTP_RECEIVED_SACK);
|
|
|
|
}
|
|
|
|
|
|
|
|
sctp_transport_raise_cwnd(transport, sack_ctsn,
|
|
|
|
bytes_acked);
|
|
|
|
|
|
|
|
transport->flight_size -= bytes_acked;
|
2008-04-18 05:22:18 +08:00
|
|
|
if (transport->flight_size == 0)
|
|
|
|
transport->partial_bytes_acked = 0;
|
2009-09-05 06:21:00 +08:00
|
|
|
q->outstanding_bytes -= bytes_acked + migrate_bytes;
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
/* RFC 2960 6.1, sctpimpguide-06 2.15.2
|
|
|
|
* When a sender is doing zero window probing, it
|
|
|
|
* should not timeout the association if it continues
|
|
|
|
* to receive new packets from the receiver. The
|
|
|
|
* reason is that the receiver MAY keep its window
|
|
|
|
* closed for an indefinite time.
|
|
|
|
* A sender is doing zero window probing when the
|
|
|
|
* receiver's advertised window is zero, and there is
|
|
|
|
* only one data chunk in flight to the receiver.
|
2011-07-07 08:28:35 +08:00
|
|
|
*
|
|
|
|
* Allow the association to timeout while in SHUTDOWN
|
|
|
|
* PENDING or SHUTDOWN RECEIVED in case the receiver
|
|
|
|
* stays in zero window mode forever.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
if (!q->asoc->peer.rwnd &&
|
|
|
|
!list_empty(&tlist) &&
|
2011-07-07 08:28:35 +08:00
|
|
|
(sack_ctsn+2 == q->asoc->next_tsn) &&
|
|
|
|
q->asoc->state < SCTP_STATE_SHUTDOWN_PENDING) {
|
net: sctp: rework debugging framework to use pr_debug and friends
We should get rid of all own SCTP debug printk macros and use the ones
that the kernel offers anyway instead. This makes the code more readable
and conform to the kernel code, and offers all the features of dynamic
debbuging that pr_debug() et al has, such as only turning on/off portions
of debug messages at runtime through debugfs. The runtime cost of having
CONFIG_DYNAMIC_DEBUG enabled, but none of the debug statements printing,
is negligible [1]. If kernel debugging is completly turned off, then these
statements will also compile into "empty" functions.
While we're at it, we also need to change the Kconfig option as it /now/
only refers to the ifdef'ed code portions in outqueue.c that enable further
debugging/tracing of SCTP transaction fields. Also, since SCTP_ASSERT code
was enabled with this Kconfig option and has now been removed, we
transform those code parts into WARNs resp. where appropriate BUG_ONs so
that those bugs can be more easily detected as probably not many people
have SCTP debugging permanently turned on.
To turn on all SCTP debugging, the following steps are needed:
# mount -t debugfs none /sys/kernel/debug
# echo -n 'module sctp +p' > /sys/kernel/debug/dynamic_debug/control
This can be done more fine-grained on a per file, per line basis and others
as described in [2].
[1] https://www.kernel.org/doc/ols/2009/ols2009-pages-39-46.pdf
[2] Documentation/dynamic-debug-howto.txt
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-29 01:49:40 +08:00
|
|
|
pr_debug("%s: sack received for zero window "
|
|
|
|
"probe:%u\n", __func__, sack_ctsn);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
q->asoc->overall_error_count = 0;
|
|
|
|
transport->error_count = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* RFC 2960 6.3.2 Retransmission Timer Rules
|
|
|
|
*
|
|
|
|
* R2) Whenever all outstanding data sent to an address have
|
|
|
|
* been acknowledged, turn off the T3-rtx timer of that
|
|
|
|
* address.
|
|
|
|
*/
|
|
|
|
if (!transport->flight_size) {
|
2013-02-04 04:32:57 +08:00
|
|
|
if (del_timer(&transport->T3_rtx_timer))
|
2005-04-17 06:20:36 +08:00
|
|
|
sctp_transport_put(transport);
|
|
|
|
} else if (restart_timer) {
|
|
|
|
if (!mod_timer(&transport->T3_rtx_timer,
|
|
|
|
jiffies + transport->rto))
|
|
|
|
sctp_transport_hold(transport);
|
|
|
|
}
|
2013-07-09 22:17:04 +08:00
|
|
|
|
|
|
|
if (forward_progress) {
|
|
|
|
if (transport->dst)
|
2017-02-07 05:14:13 +08:00
|
|
|
sctp_transport_dst_confirm(transport);
|
2013-07-09 22:17:04 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
list_splice(&tlist, transmitted_queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mark chunks as missing and consequently may get retransmitted. */
|
|
|
|
static void sctp_mark_missing(struct sctp_outq *q,
|
|
|
|
struct list_head *transmitted_queue,
|
|
|
|
struct sctp_transport *transport,
|
|
|
|
__u32 highest_new_tsn_in_sack,
|
|
|
|
int count_of_newacks)
|
|
|
|
{
|
|
|
|
struct sctp_chunk *chunk;
|
|
|
|
__u32 tsn;
|
|
|
|
char do_fast_retransmit = 0;
|
2010-05-01 10:41:10 +08:00
|
|
|
struct sctp_association *asoc = q->asoc;
|
|
|
|
struct sctp_transport *primary = asoc->peer.primary_path;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-13 09:54:24 +08:00
|
|
|
list_for_each_entry(chunk, transmitted_queue, transmitted_list) {
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
tsn = ntohl(chunk->subh.data_hdr->tsn);
|
|
|
|
|
|
|
|
/* RFC 2960 7.2.4, sctpimpguide-05 2.8.2 M3) Examine all
|
|
|
|
* 'Unacknowledged TSN's', if the TSN number of an
|
|
|
|
* 'Unacknowledged TSN' is smaller than the 'HighestTSNinSack'
|
|
|
|
* value, increment the 'TSN.Missing.Report' count on that
|
|
|
|
* chunk if it has NOT been fast retransmitted or marked for
|
|
|
|
* fast retransmit already.
|
|
|
|
*/
|
2008-07-26 00:44:09 +08:00
|
|
|
if (chunk->fast_retransmit == SCTP_CAN_FRTX &&
|
2005-04-17 06:20:36 +08:00
|
|
|
!chunk->tsn_gap_acked &&
|
|
|
|
TSN_lt(tsn, highest_new_tsn_in_sack)) {
|
|
|
|
|
|
|
|
/* SFR-CACC may require us to skip marking
|
|
|
|
* this chunk as missing.
|
|
|
|
*/
|
2011-04-19 03:13:56 +08:00
|
|
|
if (!transport || !sctp_cacc_skip(primary,
|
|
|
|
chunk->transport,
|
|
|
|
count_of_newacks, tsn)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
chunk->tsn_missing_report++;
|
|
|
|
|
net: sctp: rework debugging framework to use pr_debug and friends
We should get rid of all own SCTP debug printk macros and use the ones
that the kernel offers anyway instead. This makes the code more readable
and conform to the kernel code, and offers all the features of dynamic
debbuging that pr_debug() et al has, such as only turning on/off portions
of debug messages at runtime through debugfs. The runtime cost of having
CONFIG_DYNAMIC_DEBUG enabled, but none of the debug statements printing,
is negligible [1]. If kernel debugging is completly turned off, then these
statements will also compile into "empty" functions.
While we're at it, we also need to change the Kconfig option as it /now/
only refers to the ifdef'ed code portions in outqueue.c that enable further
debugging/tracing of SCTP transaction fields. Also, since SCTP_ASSERT code
was enabled with this Kconfig option and has now been removed, we
transform those code parts into WARNs resp. where appropriate BUG_ONs so
that those bugs can be more easily detected as probably not many people
have SCTP debugging permanently turned on.
To turn on all SCTP debugging, the following steps are needed:
# mount -t debugfs none /sys/kernel/debug
# echo -n 'module sctp +p' > /sys/kernel/debug/dynamic_debug/control
This can be done more fine-grained on a per file, per line basis and others
as described in [2].
[1] https://www.kernel.org/doc/ols/2009/ols2009-pages-39-46.pdf
[2] Documentation/dynamic-debug-howto.txt
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-29 01:49:40 +08:00
|
|
|
pr_debug("%s: tsn:0x%x missing counter:%d\n",
|
|
|
|
__func__, tsn, chunk->tsn_missing_report);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* M4) If any DATA chunk is found to have a
|
|
|
|
* 'TSN.Missing.Report'
|
2006-02-03 08:57:31 +08:00
|
|
|
* value larger than or equal to 3, mark that chunk for
|
2005-04-17 06:20:36 +08:00
|
|
|
* retransmission and start the fast retransmit procedure.
|
|
|
|
*/
|
|
|
|
|
2006-02-03 08:57:31 +08:00
|
|
|
if (chunk->tsn_missing_report >= 3) {
|
2008-07-26 00:44:09 +08:00
|
|
|
chunk->fast_retransmit = SCTP_NEED_FRTX;
|
2005-04-17 06:20:36 +08:00
|
|
|
do_fast_retransmit = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transport) {
|
|
|
|
if (do_fast_retransmit)
|
|
|
|
sctp_retransmit(q, transport, SCTP_RTXR_FAST_RTX);
|
|
|
|
|
net: sctp: rework debugging framework to use pr_debug and friends
We should get rid of all own SCTP debug printk macros and use the ones
that the kernel offers anyway instead. This makes the code more readable
and conform to the kernel code, and offers all the features of dynamic
debbuging that pr_debug() et al has, such as only turning on/off portions
of debug messages at runtime through debugfs. The runtime cost of having
CONFIG_DYNAMIC_DEBUG enabled, but none of the debug statements printing,
is negligible [1]. If kernel debugging is completly turned off, then these
statements will also compile into "empty" functions.
While we're at it, we also need to change the Kconfig option as it /now/
only refers to the ifdef'ed code portions in outqueue.c that enable further
debugging/tracing of SCTP transaction fields. Also, since SCTP_ASSERT code
was enabled with this Kconfig option and has now been removed, we
transform those code parts into WARNs resp. where appropriate BUG_ONs so
that those bugs can be more easily detected as probably not many people
have SCTP debugging permanently turned on.
To turn on all SCTP debugging, the following steps are needed:
# mount -t debugfs none /sys/kernel/debug
# echo -n 'module sctp +p' > /sys/kernel/debug/dynamic_debug/control
This can be done more fine-grained on a per file, per line basis and others
as described in [2].
[1] https://www.kernel.org/doc/ols/2009/ols2009-pages-39-46.pdf
[2] Documentation/dynamic-debug-howto.txt
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-29 01:49:40 +08:00
|
|
|
pr_debug("%s: transport:%p, cwnd:%d, ssthresh:%d, "
|
|
|
|
"flight_size:%d, pba:%d\n", __func__, transport,
|
|
|
|
transport->cwnd, transport->ssthresh,
|
|
|
|
transport->flight_size, transport->partial_bytes_acked);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is the given TSN acked by this packet? */
|
|
|
|
static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn)
|
|
|
|
{
|
|
|
|
__u32 ctsn = ntohl(sack->cum_tsn_ack);
|
2017-07-23 09:34:31 +08:00
|
|
|
union sctp_sack_variable *frags;
|
|
|
|
__u16 tsn_offset, blocks;
|
|
|
|
int i;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-09 22:25:18 +08:00
|
|
|
if (TSN_lte(tsn, ctsn))
|
2005-04-17 06:20:36 +08:00
|
|
|
goto pass;
|
|
|
|
|
2018-05-15 01:35:20 +08:00
|
|
|
/* 3.3.4 Selective Acknowledgment (SACK) (3):
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Gap Ack Blocks:
|
|
|
|
* These fields contain the Gap Ack Blocks. They are repeated
|
|
|
|
* for each Gap Ack Block up to the number of Gap Ack Blocks
|
|
|
|
* defined in the Number of Gap Ack Blocks field. All DATA
|
|
|
|
* chunks with TSNs greater than or equal to (Cumulative TSN
|
|
|
|
* Ack + Gap Ack Block Start) and less than or equal to
|
|
|
|
* (Cumulative TSN Ack + Gap Ack Block End) of each Gap Ack
|
|
|
|
* Block are assumed to have been received correctly.
|
|
|
|
*/
|
|
|
|
|
|
|
|
frags = sack->variable;
|
2016-09-21 05:19:13 +08:00
|
|
|
blocks = ntohs(sack->num_gap_ack_blocks);
|
|
|
|
tsn_offset = tsn - ctsn;
|
|
|
|
for (i = 0; i < blocks; ++i) {
|
|
|
|
if (tsn_offset >= ntohs(frags[i].gab.start) &&
|
|
|
|
tsn_offset <= ntohs(frags[i].gab.end))
|
2005-04-17 06:20:36 +08:00
|
|
|
goto pass;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
pass:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sctp_get_skip_pos(struct sctp_fwdtsn_skip *skiplist,
|
2006-11-21 09:26:34 +08:00
|
|
|
int nskips, __be16 stream)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < nskips; i++) {
|
|
|
|
if (skiplist[i].stream == stream)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create and add a fwdtsn chunk to the outq's control queue if needed. */
|
2017-12-15 00:41:26 +08:00
|
|
|
void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 ctsn)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct sctp_association *asoc = q->asoc;
|
|
|
|
struct sctp_chunk *ftsn_chunk = NULL;
|
|
|
|
struct sctp_fwdtsn_skip ftsn_skip_arr[10];
|
|
|
|
int nskips = 0;
|
|
|
|
int skip_pos = 0;
|
|
|
|
__u32 tsn;
|
|
|
|
struct sctp_chunk *chunk;
|
|
|
|
struct list_head *lchunk, *temp;
|
|
|
|
|
2009-03-12 17:49:19 +08:00
|
|
|
if (!asoc->peer.prsctp_capable)
|
|
|
|
return;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* PR-SCTP C1) Let SackCumAck be the Cumulative TSN ACK carried in the
|
|
|
|
* received SACK.
|
2007-02-09 22:25:18 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* If (Advanced.Peer.Ack.Point < SackCumAck), then update
|
|
|
|
* Advanced.Peer.Ack.Point to be equal to SackCumAck.
|
|
|
|
*/
|
|
|
|
if (TSN_lt(asoc->adv_peer_ack_point, ctsn))
|
|
|
|
asoc->adv_peer_ack_point = ctsn;
|
|
|
|
|
|
|
|
/* PR-SCTP C2) Try to further advance the "Advanced.Peer.Ack.Point"
|
|
|
|
* locally, that is, to move "Advanced.Peer.Ack.Point" up as long as
|
|
|
|
* the chunk next in the out-queue space is marked as "abandoned" as
|
|
|
|
* shown in the following example:
|
|
|
|
*
|
|
|
|
* Assuming that a SACK arrived with the Cumulative TSN ACK 102
|
|
|
|
* and the Advanced.Peer.Ack.Point is updated to this value:
|
2007-02-09 22:25:18 +08:00
|
|
|
*
|
2005-04-17 06:20:36 +08:00
|
|
|
* out-queue at the end of ==> out-queue after Adv.Ack.Point
|
|
|
|
* normal SACK processing local advancement
|
|
|
|
* ... ...
|
|
|
|
* Adv.Ack.Pt-> 102 acked 102 acked
|
|
|
|
* 103 abandoned 103 abandoned
|
|
|
|
* 104 abandoned Adv.Ack.P-> 104 abandoned
|
|
|
|
* 105 105
|
|
|
|
* 106 acked 106 acked
|
|
|
|
* ... ...
|
|
|
|
*
|
|
|
|
* In this example, the data sender successfully advanced the
|
|
|
|
* "Advanced.Peer.Ack.Point" from 102 to 104 locally.
|
|
|
|
*/
|
|
|
|
list_for_each_safe(lchunk, temp, &q->abandoned) {
|
|
|
|
chunk = list_entry(lchunk, struct sctp_chunk,
|
|
|
|
transmitted_list);
|
|
|
|
tsn = ntohl(chunk->subh.data_hdr->tsn);
|
|
|
|
|
|
|
|
/* Remove any chunks in the abandoned queue that are acked by
|
|
|
|
* the ctsn.
|
2007-02-09 22:25:18 +08:00
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (TSN_lte(tsn, ctsn)) {
|
|
|
|
list_del_init(lchunk);
|
|
|
|
sctp_chunk_free(chunk);
|
|
|
|
} else {
|
|
|
|
if (TSN_lte(tsn, asoc->adv_peer_ack_point+1)) {
|
|
|
|
asoc->adv_peer_ack_point = tsn;
|
|
|
|
if (chunk->chunk_hdr->flags &
|
|
|
|
SCTP_DATA_UNORDERED)
|
|
|
|
continue;
|
|
|
|
skip_pos = sctp_get_skip_pos(&ftsn_skip_arr[0],
|
|
|
|
nskips,
|
|
|
|
chunk->subh.data_hdr->stream);
|
|
|
|
ftsn_skip_arr[skip_pos].stream =
|
|
|
|
chunk->subh.data_hdr->stream;
|
|
|
|
ftsn_skip_arr[skip_pos].ssn =
|
|
|
|
chunk->subh.data_hdr->ssn;
|
|
|
|
if (skip_pos == nskips)
|
|
|
|
nskips++;
|
|
|
|
if (nskips == 10)
|
|
|
|
break;
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PR-SCTP C3) If, after step C1 and C2, the "Advanced.Peer.Ack.Point"
|
|
|
|
* is greater than the Cumulative TSN ACK carried in the received
|
|
|
|
* SACK, the data sender MUST send the data receiver a FORWARD TSN
|
|
|
|
* chunk containing the latest value of the
|
|
|
|
* "Advanced.Peer.Ack.Point".
|
|
|
|
*
|
|
|
|
* C4) For each "abandoned" TSN the sender of the FORWARD TSN SHOULD
|
|
|
|
* list each stream and sequence number in the forwarded TSN. This
|
|
|
|
* information will enable the receiver to easily find any
|
|
|
|
* stranded TSN's waiting on stream reorder queues. Each stream
|
|
|
|
* SHOULD only be reported once; this means that if multiple
|
|
|
|
* abandoned messages occur in the same stream then only the
|
|
|
|
* highest abandoned stream sequence number is reported. If the
|
|
|
|
* total size of the FORWARD TSN does NOT fit in a single MTU then
|
|
|
|
* the sender of the FORWARD TSN SHOULD lower the
|
|
|
|
* Advanced.Peer.Ack.Point to the last TSN that will fit in a
|
|
|
|
* single MTU.
|
|
|
|
*/
|
|
|
|
if (asoc->adv_peer_ack_point > ctsn)
|
|
|
|
ftsn_chunk = sctp_make_fwdtsn(asoc, asoc->adv_peer_ack_point,
|
2007-02-09 22:25:18 +08:00
|
|
|
nskips, &ftsn_skip_arr[0]);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (ftsn_chunk) {
|
2005-07-09 12:47:49 +08:00
|
|
|
list_add_tail(&ftsn_chunk->list, &q->control_chunk_list);
|
2012-08-06 16:47:55 +08:00
|
|
|
SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_OUTCTRLCHUNKS);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|