2008-01-11 21:57:09 +07:00
|
|
|
/* SCTP kernel implementation
|
2005-04-17 05:20:36 +07:00
|
|
|
* (C) Copyright IBM Corp. 2001, 2004
|
|
|
|
* Copyright (c) 1999 Cisco, Inc.
|
|
|
|
* Copyright (c) 1999-2001 Motorola, Inc.
|
|
|
|
*
|
2008-01-11 21:57:09 +07:00
|
|
|
* This file is part of the SCTP kernel implementation
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
* These functions work with the state functions in sctp_sm_statefuns.c
|
|
|
|
* to implement that state operations. These functions implement the
|
|
|
|
* steps which require modifying existing data structures.
|
|
|
|
*
|
2008-01-11 21:57:09 +07:00
|
|
|
* This SCTP implementation is free software;
|
2005-04-17 05:20:36 +07:00
|
|
|
* you can redistribute it and/or modify it under the terms of
|
|
|
|
* the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
2008-01-11 21:57:09 +07:00
|
|
|
* This SCTP implementation is distributed in the hope that it
|
2005-04-17 05:20:36 +07:00
|
|
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* ************************
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2013-12-06 21:28:48 +07:00
|
|
|
* along with GNU CC; see the file COPYING. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
* Please send any bug reports or fixes you make to the
|
|
|
|
* email address(es):
|
2013-07-23 19:51:47 +07:00
|
|
|
* lksctp developers <linux-sctp@vger.kernel.org>
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
* Written or modified by:
|
|
|
|
* La Monte H.P. Yarroll <piggy@acm.org>
|
|
|
|
* Karl Knutson <karl@athena.chicago.il.us>
|
|
|
|
* Jon Grimm <jgrimm@austin.ibm.com>
|
|
|
|
* Hui Huang <hui.huang@nokia.com>
|
|
|
|
* Dajiang Zhang <dajiang.zhang@nokia.com>
|
|
|
|
* Daisy Chang <daisyc@us.ibm.com>
|
|
|
|
* Sridhar Samudrala <sri@us.ibm.com>
|
|
|
|
* Ardelle Fan <ardelle.fan@intel.com>
|
|
|
|
*/
|
|
|
|
|
2010-08-24 20:21:08 +07:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#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 15:04:11 +07:00
|
|
|
#include <linux/gfp.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <net/sock.h>
|
|
|
|
#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 05:20:13 +07:00
|
|
|
#include <net/sctp/stream_sched.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2017-08-05 19:00:03 +07:00
|
|
|
static int sctp_cmd_interpreter(enum sctp_event event_type,
|
2017-08-05 19:00:04 +07:00
|
|
|
union sctp_subtype subtype,
|
2017-08-05 18:59:59 +07:00
|
|
|
enum sctp_state state,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_endpoint *ep,
|
|
|
|
struct sctp_association *asoc,
|
|
|
|
void *event_arg,
|
2017-08-11 09:23:57 +07:00
|
|
|
enum sctp_disposition status,
|
2017-08-11 09:23:52 +07:00
|
|
|
struct sctp_cmd_seq *commands,
|
2005-10-07 13:46:04 +07:00
|
|
|
gfp_t gfp);
|
2017-08-05 19:00:04 +07:00
|
|
|
static int sctp_side_effects(enum sctp_event event_type,
|
|
|
|
union sctp_subtype subtype,
|
2017-08-05 18:59:59 +07:00
|
|
|
enum sctp_state state,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_endpoint *ep,
|
2016-01-08 20:00:54 +07:00
|
|
|
struct sctp_association **asoc,
|
2005-04-17 05:20:36 +07:00
|
|
|
void *event_arg,
|
2017-08-11 09:23:57 +07:00
|
|
|
enum sctp_disposition status,
|
2017-08-11 09:23:52 +07:00
|
|
|
struct sctp_cmd_seq *commands,
|
2005-10-07 13:46:04 +07:00
|
|
|
gfp_t gfp);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* Helper functions
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
/* A helper function for delayed processing of INET ECN CE bit. */
|
2007-02-09 21:25:18 +07:00
|
|
|
static void sctp_do_ecn_ce_work(struct sctp_association *asoc,
|
2005-04-17 05:20:36 +07:00
|
|
|
__u32 lowest_tsn)
|
|
|
|
{
|
|
|
|
/* Save the TSN away for comparison when we receive CWR */
|
|
|
|
|
|
|
|
asoc->last_ecne_tsn = lowest_tsn;
|
|
|
|
asoc->need_ecne = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function for delayed processing of SCTP ECNE chunk. */
|
|
|
|
/* RFC 2960 Appendix A
|
|
|
|
*
|
|
|
|
* RFC 2481 details a specific bit for a sender to send in
|
|
|
|
* the header of its next outbound TCP segment to indicate to
|
|
|
|
* its peer that it has reduced its congestion window. This
|
|
|
|
* is termed the CWR bit. For SCTP the same indication is made
|
|
|
|
* by including the CWR chunk. This chunk contains one data
|
|
|
|
* element, i.e. the TSN number that was sent in the ECNE chunk.
|
|
|
|
* This element represents the lowest TSN number in the datagram
|
|
|
|
* that was originally marked with the CE bit.
|
|
|
|
*/
|
|
|
|
static struct sctp_chunk *sctp_do_ecn_ecne_work(struct sctp_association *asoc,
|
2017-08-11 09:23:57 +07:00
|
|
|
__u32 lowest_tsn,
|
|
|
|
struct sctp_chunk *chunk)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct sctp_chunk *repl;
|
|
|
|
|
|
|
|
/* Our previously transmitted packet ran into some congestion
|
|
|
|
* so we should take action by reducing cwnd and ssthresh
|
|
|
|
* and then ACK our peer that we we've done so by
|
|
|
|
* sending a CWR.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* First, try to determine if we want to actually lower
|
|
|
|
* our cwnd variables. Only lower them if the ECNE looks more
|
|
|
|
* recent than the last response.
|
|
|
|
*/
|
|
|
|
if (TSN_lt(asoc->last_cwr_tsn, lowest_tsn)) {
|
|
|
|
struct sctp_transport *transport;
|
|
|
|
|
|
|
|
/* Find which transport's congestion variables
|
|
|
|
* need to be adjusted.
|
|
|
|
*/
|
|
|
|
transport = sctp_assoc_lookup_tsn(asoc, lowest_tsn);
|
|
|
|
|
|
|
|
/* Update the congestion variables. */
|
|
|
|
if (transport)
|
|
|
|
sctp_transport_lower_cwnd(transport,
|
|
|
|
SCTP_LOWER_CWND_ECNE);
|
|
|
|
asoc->last_cwr_tsn = lowest_tsn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Always try to quiet the other end. In case of lost CWR,
|
|
|
|
* resend last_cwr_tsn.
|
|
|
|
*/
|
|
|
|
repl = sctp_make_cwr(asoc, asoc->last_cwr_tsn, chunk);
|
|
|
|
|
|
|
|
/* If we run out of memory, it will look like a lost CWR. We'll
|
|
|
|
* get back in sync eventually.
|
|
|
|
*/
|
|
|
|
return repl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to do delayed processing of ECN CWR chunk. */
|
|
|
|
static void sctp_do_ecn_cwr_work(struct sctp_association *asoc,
|
|
|
|
__u32 lowest_tsn)
|
|
|
|
{
|
|
|
|
/* Turn off ECNE getting auto-prepended to every outgoing
|
|
|
|
* packet
|
|
|
|
*/
|
|
|
|
asoc->need_ecne = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate SACK if necessary. We call this at the end of a packet. */
|
|
|
|
static int sctp_gen_sack(struct sctp_association *asoc, int force,
|
2017-08-11 09:23:52 +07:00
|
|
|
struct sctp_cmd_seq *commands)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-08-11 09:23:57 +07:00
|
|
|
struct sctp_transport *trans = asoc->peer.last_data_from;
|
2005-04-17 05:20:36 +07:00
|
|
|
__u32 ctsn, max_tsn_seen;
|
|
|
|
struct sctp_chunk *sack;
|
|
|
|
int error = 0;
|
|
|
|
|
2007-02-09 21:25:18 +07:00
|
|
|
if (force ||
|
2005-12-23 02:36:46 +07:00
|
|
|
(!trans && (asoc->param_flags & SPP_SACKDELAY_DISABLE)) ||
|
|
|
|
(trans && (trans->param_flags & SPP_SACKDELAY_DISABLE)))
|
2005-04-17 05:20:36 +07:00
|
|
|
asoc->peer.sack_needed = 1;
|
|
|
|
|
|
|
|
ctsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map);
|
|
|
|
max_tsn_seen = sctp_tsnmap_get_max_tsn_seen(&asoc->peer.tsn_map);
|
|
|
|
|
|
|
|
/* From 12.2 Parameters necessary per association (i.e. the TCB):
|
|
|
|
*
|
|
|
|
* Ack State : This flag indicates if the next received packet
|
|
|
|
* : is to be responded to with a SACK. ...
|
|
|
|
* : When DATA chunks are out of order, SACK's
|
|
|
|
* : are not delayed (see Section 6).
|
|
|
|
*
|
|
|
|
* [This is actually not mentioned in Section 6, but we
|
|
|
|
* implement it here anyway. --piggy]
|
|
|
|
*/
|
2007-02-09 21:25:18 +07:00
|
|
|
if (max_tsn_seen != ctsn)
|
2005-04-17 05:20:36 +07:00
|
|
|
asoc->peer.sack_needed = 1;
|
|
|
|
|
|
|
|
/* From 6.2 Acknowledgement on Reception of DATA Chunks:
|
|
|
|
*
|
|
|
|
* Section 4.2 of [RFC2581] SHOULD be followed. Specifically,
|
|
|
|
* an acknowledgement SHOULD be generated for at least every
|
|
|
|
* second packet (not every second DATA chunk) received, and
|
|
|
|
* SHOULD be generated within 200 ms of the arrival of any
|
|
|
|
* unacknowledged DATA chunk. ...
|
|
|
|
*/
|
|
|
|
if (!asoc->peer.sack_needed) {
|
2008-05-10 05:13:26 +07:00
|
|
|
asoc->peer.sack_cnt++;
|
2005-12-23 02:36:46 +07:00
|
|
|
|
|
|
|
/* Set the SACK delay timeout based on the
|
|
|
|
* SACK delay for the last transport
|
|
|
|
* data was received from, or the default
|
|
|
|
* for the association.
|
|
|
|
*/
|
2008-05-10 05:13:26 +07:00
|
|
|
if (trans) {
|
|
|
|
/* We will need a SACK for the next packet. */
|
|
|
|
if (asoc->peer.sack_cnt >= trans->sackfreq - 1)
|
|
|
|
asoc->peer.sack_needed = 1;
|
|
|
|
|
2007-02-09 21:25:18 +07:00
|
|
|
asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
|
2005-12-23 02:36:46 +07:00
|
|
|
trans->sackdelay;
|
2008-05-10 05:13:26 +07:00
|
|
|
} else {
|
|
|
|
/* We will need a SACK for the next packet. */
|
|
|
|
if (asoc->peer.sack_cnt >= asoc->sackfreq - 1)
|
|
|
|
asoc->peer.sack_needed = 1;
|
|
|
|
|
2007-02-09 21:25:18 +07:00
|
|
|
asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
|
2005-12-23 02:36:46 +07:00
|
|
|
asoc->sackdelay;
|
2008-05-10 05:13:26 +07:00
|
|
|
}
|
2005-12-23 02:36:46 +07:00
|
|
|
|
|
|
|
/* Restart the SACK timer. */
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
|
|
|
|
SCTP_TO(SCTP_EVENT_TIMEOUT_SACK));
|
2005-04-17 05:20:36 +07:00
|
|
|
} else {
|
2016-03-19 04:39:18 +07:00
|
|
|
__u32 old_a_rwnd = asoc->a_rwnd;
|
|
|
|
|
2009-11-24 03:53:57 +07:00
|
|
|
asoc->a_rwnd = asoc->rwnd;
|
2005-04-17 05:20:36 +07:00
|
|
|
sack = sctp_make_sack(asoc);
|
2016-03-19 04:39:18 +07:00
|
|
|
if (!sack) {
|
|
|
|
asoc->a_rwnd = old_a_rwnd;
|
2005-04-17 05:20:36 +07:00
|
|
|
goto nomem;
|
2016-03-19 04:39:18 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
asoc->peer.sack_needed = 0;
|
2008-05-10 05:13:26 +07:00
|
|
|
asoc->peer.sack_cnt = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-01-16 10:20:21 +07:00
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(sack));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Stop the SACK timer. */
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
|
|
|
|
SCTP_TO(SCTP_EVENT_TIMEOUT_SACK));
|
|
|
|
}
|
2005-12-23 02:36:46 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
return error;
|
|
|
|
nomem:
|
|
|
|
error = -ENOMEM;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* When the T3-RTX timer expires, it calls this function to create the
|
|
|
|
* relevant state machine event.
|
|
|
|
*/
|
2017-10-24 15:45:31 +07:00
|
|
|
void sctp_generate_t3_rtx_event(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_transport *transport =
|
|
|
|
from_timer(transport, t, T3_rtx_timer);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc = transport->asoc;
|
2015-09-24 23:15:07 +07:00
|
|
|
struct sock *sk = asoc->base.sk;
|
|
|
|
struct net *net = sock_net(sk);
|
2017-08-11 09:23:57 +07:00
|
|
|
int error;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Check whether a task is in the sock. */
|
|
|
|
|
2015-09-24 23:15:07 +07:00
|
|
|
bh_lock_sock(sk);
|
|
|
|
if (sock_owned_by_user(sk)) {
|
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 00:49:40 +07:00
|
|
|
pr_debug("%s: sock is busy\n", __func__);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Try again later. */
|
|
|
|
if (!mod_timer(&transport->T3_rtx_timer, jiffies + (HZ/20)))
|
|
|
|
sctp_transport_hold(transport);
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Run through the state machine. */
|
2012-08-07 14:25:24 +07:00
|
|
|
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
|
2005-04-17 05:20:36 +07:00
|
|
|
SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX),
|
|
|
|
asoc->state,
|
|
|
|
asoc->ep, asoc,
|
|
|
|
transport, GFP_ATOMIC);
|
|
|
|
|
|
|
|
if (error)
|
2015-09-24 23:15:07 +07:00
|
|
|
sk->sk_err = -error;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
out_unlock:
|
2015-09-24 23:15:07 +07:00
|
|
|
bh_unlock_sock(sk);
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_transport_put(transport);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is a sa interface for producing timeout events. It works
|
|
|
|
* for timeouts which use the association as their parameter.
|
|
|
|
*/
|
|
|
|
static void sctp_generate_timeout_event(struct sctp_association *asoc,
|
2017-08-05 19:00:02 +07:00
|
|
|
enum sctp_event_timeout timeout_type)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2015-09-24 23:15:07 +07:00
|
|
|
struct sock *sk = asoc->base.sk;
|
|
|
|
struct net *net = sock_net(sk);
|
2005-04-17 05:20:36 +07:00
|
|
|
int error = 0;
|
|
|
|
|
2015-09-24 23:15:07 +07:00
|
|
|
bh_lock_sock(sk);
|
|
|
|
if (sock_owned_by_user(sk)) {
|
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 00:49:40 +07:00
|
|
|
pr_debug("%s: sock is busy: timer %d\n", __func__,
|
|
|
|
timeout_type);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Try again later. */
|
|
|
|
if (!mod_timer(&asoc->timers[timeout_type], jiffies + (HZ/20)))
|
|
|
|
sctp_association_hold(asoc);
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is this association really dead and just waiting around for
|
|
|
|
* the timer to let go of the reference?
|
|
|
|
*/
|
|
|
|
if (asoc->base.dead)
|
|
|
|
goto out_unlock;
|
|
|
|
|
|
|
|
/* Run through the state machine. */
|
2012-08-07 14:25:24 +07:00
|
|
|
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
|
2005-04-17 05:20:36 +07:00
|
|
|
SCTP_ST_TIMEOUT(timeout_type),
|
|
|
|
asoc->state, asoc->ep, asoc,
|
|
|
|
(void *)timeout_type, GFP_ATOMIC);
|
|
|
|
|
|
|
|
if (error)
|
2015-09-24 23:15:07 +07:00
|
|
|
sk->sk_err = -error;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
out_unlock:
|
2015-09-24 23:15:07 +07:00
|
|
|
bh_unlock_sock(sk);
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_association_put(asoc);
|
|
|
|
}
|
|
|
|
|
2017-10-24 15:45:31 +07:00
|
|
|
static void sctp_generate_t1_cookie_event(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_association *asoc =
|
|
|
|
from_timer(asoc, t, timers[SCTP_EVENT_TIMEOUT_T1_COOKIE]);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_T1_COOKIE);
|
|
|
|
}
|
|
|
|
|
2017-10-24 15:45:31 +07:00
|
|
|
static void sctp_generate_t1_init_event(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_association *asoc =
|
|
|
|
from_timer(asoc, t, timers[SCTP_EVENT_TIMEOUT_T1_INIT]);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_T1_INIT);
|
|
|
|
}
|
|
|
|
|
2017-10-24 15:45:31 +07:00
|
|
|
static void sctp_generate_t2_shutdown_event(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_association *asoc =
|
|
|
|
from_timer(asoc, t, timers[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN]);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_T2_SHUTDOWN);
|
|
|
|
}
|
|
|
|
|
2017-10-24 15:45:31 +07:00
|
|
|
static void sctp_generate_t4_rto_event(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_association *asoc =
|
|
|
|
from_timer(asoc, t, timers[SCTP_EVENT_TIMEOUT_T4_RTO]);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_T4_RTO);
|
|
|
|
}
|
|
|
|
|
2017-10-24 15:45:31 +07:00
|
|
|
static void sctp_generate_t5_shutdown_guard_event(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_association *asoc =
|
|
|
|
from_timer(asoc, t,
|
|
|
|
timers[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD]);
|
|
|
|
|
2007-02-09 21:25:18 +07:00
|
|
|
sctp_generate_timeout_event(asoc,
|
2005-04-17 05:20:36 +07:00
|
|
|
SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD);
|
|
|
|
|
|
|
|
} /* sctp_generate_t5_shutdown_guard_event() */
|
|
|
|
|
2017-10-24 15:45:31 +07:00
|
|
|
static void sctp_generate_autoclose_event(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_association *asoc =
|
|
|
|
from_timer(asoc, t, timers[SCTP_EVENT_TIMEOUT_AUTOCLOSE]);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_AUTOCLOSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate a heart beat event. If the sock is busy, reschedule. Make
|
|
|
|
* sure that the transport is still valid.
|
|
|
|
*/
|
2017-10-24 15:45:31 +07:00
|
|
|
void sctp_generate_heartbeat_event(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_transport *transport = from_timer(transport, t, hb_timer);
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc = transport->asoc;
|
2015-09-24 23:15:07 +07:00
|
|
|
struct sock *sk = asoc->base.sk;
|
|
|
|
struct net *net = sock_net(sk);
|
sctp: avoid refreshing heartbeat timer too often
Currently on high rate SCTP streams the heartbeat timer refresh can
consume quite a lot of resources as timer updates are costly and it
contains a random factor, which a) is also costly and b) invalidates
mod_timer() optimization for not editing a timer to the same value.
It may even cause the timer to be slightly advanced, for no good reason.
As suggested by David Laight this patch now removes this timer update
from hot path by leaving the timer on and re-evaluating upon its
expiration if the heartbeat is still needed or not, similarly to what is
done for TCP. If it's not needed anymore the timer is re-scheduled to
the new timeout, considering the time already elapsed.
For this, we now record the last tx timestamp per transport, updated in
the same spots as hb timer was restarted on tx. Also split up
sctp_transport_reset_timers into sctp_transport_reset_t3_rtx and
sctp_transport_reset_hb_timer, so we can re-arm T3 without re-arming the
heartbeat one.
On loopback with MTU of 65535 and data chunks with 1636, so that we
have a considerable amount of chunks without stressing system calls,
netperf -t SCTP_STREAM -l 30, perf looked like this before:
Samples: 103K of event 'cpu-clock', Event count (approx.): 25833000000
Overhead Command Shared Object Symbol
+ 6,15% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,43% netperf [kernel.vmlinux] [k] _raw_write_unlock_irqrestore
- _raw_write_unlock_irqrestore
- 96,54% _raw_spin_unlock_irqrestore
- 36,14% mod_timer
+ 97,24% sctp_transport_reset_timers
+ 2,76% sctp_do_sm
+ 33,65% __wake_up_sync_key
+ 28,77% sctp_ulpq_tail_event
+ 1,40% del_timer
- 1,84% mod_timer
+ 99,03% sctp_transport_reset_timers
+ 0,97% sctp_do_sm
+ 1,50% sctp_ulpq_tail_event
And after this patch, now with netperf -l 60:
Samples: 230K of event 'cpu-clock', Event count (approx.): 57707250000
Overhead Command Shared Object Symbol
+ 5,65% netperf [kernel.vmlinux] [k] memcpy_erms
+ 5,59% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,05% netperf [kernel.vmlinux] [k] _raw_spin_unlock_irqrestore
- _raw_spin_unlock_irqrestore
+ 49,89% __wake_up_sync_key
+ 45,68% sctp_ulpq_tail_event
- 2,85% mod_timer
+ 76,51% sctp_transport_reset_t3_rtx
+ 23,49% sctp_do_sm
+ 1,55% del_timer
+ 2,50% netperf [sctp] [k] sctp_datamsg_from_user
+ 2,26% netperf [sctp] [k] sctp_sendmsg
Throughput-wise, from 6800mbps without the patch to 7050mbps with it,
~3.7%.
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-07 01:15:19 +07:00
|
|
|
u32 elapsed, timeout;
|
2017-08-11 09:23:57 +07:00
|
|
|
int error = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2015-09-24 23:15:07 +07:00
|
|
|
bh_lock_sock(sk);
|
|
|
|
if (sock_owned_by_user(sk)) {
|
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 00:49:40 +07:00
|
|
|
pr_debug("%s: sock is busy\n", __func__);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Try again later. */
|
|
|
|
if (!mod_timer(&transport->hb_timer, jiffies + (HZ/20)))
|
|
|
|
sctp_transport_hold(transport);
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
sctp: avoid refreshing heartbeat timer too often
Currently on high rate SCTP streams the heartbeat timer refresh can
consume quite a lot of resources as timer updates are costly and it
contains a random factor, which a) is also costly and b) invalidates
mod_timer() optimization for not editing a timer to the same value.
It may even cause the timer to be slightly advanced, for no good reason.
As suggested by David Laight this patch now removes this timer update
from hot path by leaving the timer on and re-evaluating upon its
expiration if the heartbeat is still needed or not, similarly to what is
done for TCP. If it's not needed anymore the timer is re-scheduled to
the new timeout, considering the time already elapsed.
For this, we now record the last tx timestamp per transport, updated in
the same spots as hb timer was restarted on tx. Also split up
sctp_transport_reset_timers into sctp_transport_reset_t3_rtx and
sctp_transport_reset_hb_timer, so we can re-arm T3 without re-arming the
heartbeat one.
On loopback with MTU of 65535 and data chunks with 1636, so that we
have a considerable amount of chunks without stressing system calls,
netperf -t SCTP_STREAM -l 30, perf looked like this before:
Samples: 103K of event 'cpu-clock', Event count (approx.): 25833000000
Overhead Command Shared Object Symbol
+ 6,15% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,43% netperf [kernel.vmlinux] [k] _raw_write_unlock_irqrestore
- _raw_write_unlock_irqrestore
- 96,54% _raw_spin_unlock_irqrestore
- 36,14% mod_timer
+ 97,24% sctp_transport_reset_timers
+ 2,76% sctp_do_sm
+ 33,65% __wake_up_sync_key
+ 28,77% sctp_ulpq_tail_event
+ 1,40% del_timer
- 1,84% mod_timer
+ 99,03% sctp_transport_reset_timers
+ 0,97% sctp_do_sm
+ 1,50% sctp_ulpq_tail_event
And after this patch, now with netperf -l 60:
Samples: 230K of event 'cpu-clock', Event count (approx.): 57707250000
Overhead Command Shared Object Symbol
+ 5,65% netperf [kernel.vmlinux] [k] memcpy_erms
+ 5,59% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,05% netperf [kernel.vmlinux] [k] _raw_spin_unlock_irqrestore
- _raw_spin_unlock_irqrestore
+ 49,89% __wake_up_sync_key
+ 45,68% sctp_ulpq_tail_event
- 2,85% mod_timer
+ 76,51% sctp_transport_reset_t3_rtx
+ 23,49% sctp_do_sm
+ 1,55% del_timer
+ 2,50% netperf [sctp] [k] sctp_datamsg_from_user
+ 2,26% netperf [sctp] [k] sctp_sendmsg
Throughput-wise, from 6800mbps without the patch to 7050mbps with it,
~3.7%.
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-07 01:15:19 +07:00
|
|
|
/* Check if we should still send the heartbeat or reschedule */
|
|
|
|
elapsed = jiffies - transport->last_time_sent;
|
|
|
|
timeout = sctp_transport_timeout(transport);
|
|
|
|
if (elapsed < timeout) {
|
|
|
|
elapsed = timeout - elapsed;
|
|
|
|
if (!mod_timer(&transport->hb_timer, jiffies + elapsed))
|
|
|
|
sctp_transport_hold(transport);
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
2012-08-07 14:25:24 +07:00
|
|
|
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
|
2005-04-17 05:20:36 +07:00
|
|
|
SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_HEARTBEAT),
|
|
|
|
asoc->state, asoc->ep, asoc,
|
|
|
|
transport, GFP_ATOMIC);
|
|
|
|
|
2015-09-24 23:15:06 +07:00
|
|
|
if (error)
|
2015-09-24 23:15:07 +07:00
|
|
|
sk->sk_err = -error;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
out_unlock:
|
2015-09-24 23:15:07 +07:00
|
|
|
bh_unlock_sock(sk);
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_transport_put(transport);
|
|
|
|
}
|
|
|
|
|
2010-05-06 14:56:07 +07:00
|
|
|
/* Handle the timeout of the ICMP protocol unreachable timer. Trigger
|
|
|
|
* the correct state machine transition that will close the association.
|
|
|
|
*/
|
2017-10-24 15:45:31 +07:00
|
|
|
void sctp_generate_proto_unreach_event(struct timer_list *t)
|
2010-05-06 14:56:07 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_transport *transport =
|
|
|
|
from_timer(transport, t, proto_unreach_timer);
|
2010-05-06 14:56:07 +07:00
|
|
|
struct sctp_association *asoc = transport->asoc;
|
2015-09-24 23:15:07 +07:00
|
|
|
struct sock *sk = asoc->base.sk;
|
|
|
|
struct net *net = sock_net(sk);
|
2013-12-23 11:16:50 +07:00
|
|
|
|
2015-09-24 23:15:07 +07:00
|
|
|
bh_lock_sock(sk);
|
|
|
|
if (sock_owned_by_user(sk)) {
|
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 00:49:40 +07:00
|
|
|
pr_debug("%s: sock is busy\n", __func__);
|
2010-05-06 14:56:07 +07:00
|
|
|
|
|
|
|
/* Try again later. */
|
|
|
|
if (!mod_timer(&transport->proto_unreach_timer,
|
|
|
|
jiffies + (HZ/20)))
|
|
|
|
sctp_association_hold(asoc);
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is this structure just waiting around for us to actually
|
|
|
|
* get destroyed?
|
|
|
|
*/
|
|
|
|
if (asoc->base.dead)
|
|
|
|
goto out_unlock;
|
|
|
|
|
2012-08-07 14:25:24 +07:00
|
|
|
sctp_do_sm(net, SCTP_EVENT_T_OTHER,
|
2010-05-06 14:56:07 +07:00
|
|
|
SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),
|
|
|
|
asoc->state, asoc->ep, asoc, transport, GFP_ATOMIC);
|
|
|
|
|
|
|
|
out_unlock:
|
2015-09-24 23:15:07 +07:00
|
|
|
bh_unlock_sock(sk);
|
2010-05-06 14:56:07 +07:00
|
|
|
sctp_association_put(asoc);
|
|
|
|
}
|
|
|
|
|
2017-01-17 23:44:43 +07:00
|
|
|
/* Handle the timeout of the RE-CONFIG timer. */
|
2017-10-24 15:45:31 +07:00
|
|
|
void sctp_generate_reconf_event(struct timer_list *t)
|
2017-01-17 23:44:43 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_transport *transport =
|
|
|
|
from_timer(transport, t, reconf_timer);
|
2017-01-17 23:44:43 +07:00
|
|
|
struct sctp_association *asoc = transport->asoc;
|
|
|
|
struct sock *sk = asoc->base.sk;
|
|
|
|
struct net *net = sock_net(sk);
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
bh_lock_sock(sk);
|
|
|
|
if (sock_owned_by_user(sk)) {
|
|
|
|
pr_debug("%s: sock is busy\n", __func__);
|
|
|
|
|
|
|
|
/* Try again later. */
|
|
|
|
if (!mod_timer(&transport->reconf_timer, jiffies + (HZ / 20)))
|
|
|
|
sctp_transport_hold(transport);
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
|
|
|
|
SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_RECONF),
|
|
|
|
asoc->state, asoc->ep, asoc,
|
|
|
|
transport, GFP_ATOMIC);
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
sk->sk_err = -error;
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
bh_unlock_sock(sk);
|
|
|
|
sctp_transport_put(transport);
|
|
|
|
}
|
2010-05-06 14:56:07 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Inject a SACK Timeout event into the state machine. */
|
2017-10-24 15:45:31 +07:00
|
|
|
static void sctp_generate_sack_event(struct timer_list *t)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-10-24 15:45:31 +07:00
|
|
|
struct sctp_association *asoc =
|
|
|
|
from_timer(asoc, t, timers[SCTP_EVENT_TIMEOUT_SACK]);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
|
|
|
|
}
|
|
|
|
|
|
|
|
sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
|
2017-10-24 15:45:31 +07:00
|
|
|
[SCTP_EVENT_TIMEOUT_NONE] = NULL,
|
|
|
|
[SCTP_EVENT_TIMEOUT_T1_COOKIE] = sctp_generate_t1_cookie_event,
|
|
|
|
[SCTP_EVENT_TIMEOUT_T1_INIT] = sctp_generate_t1_init_event,
|
|
|
|
[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] = sctp_generate_t2_shutdown_event,
|
|
|
|
[SCTP_EVENT_TIMEOUT_T3_RTX] = NULL,
|
|
|
|
[SCTP_EVENT_TIMEOUT_T4_RTO] = sctp_generate_t4_rto_event,
|
|
|
|
[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD] =
|
|
|
|
sctp_generate_t5_shutdown_guard_event,
|
|
|
|
[SCTP_EVENT_TIMEOUT_HEARTBEAT] = NULL,
|
|
|
|
[SCTP_EVENT_TIMEOUT_RECONF] = NULL,
|
|
|
|
[SCTP_EVENT_TIMEOUT_SACK] = sctp_generate_sack_event,
|
|
|
|
[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = sctp_generate_autoclose_event,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* RFC 2960 8.2 Path Failure Detection
|
|
|
|
*
|
|
|
|
* When its peer endpoint is multi-homed, an endpoint should keep a
|
|
|
|
* error counter for each of the destination transport addresses of the
|
|
|
|
* peer endpoint.
|
|
|
|
*
|
|
|
|
* Each time the T3-rtx timer expires on any address, or when a
|
|
|
|
* HEARTBEAT sent to an idle address is not acknowledged within a RTO,
|
|
|
|
* the error counter of that destination address will be incremented.
|
|
|
|
* When the value in the error counter exceeds the protocol parameter
|
|
|
|
* 'Path.Max.Retrans' of that destination address, the endpoint should
|
|
|
|
* mark the destination transport address as inactive, and a
|
|
|
|
* notification SHOULD be sent to the upper layer.
|
|
|
|
*
|
|
|
|
*/
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_do_8_2_transport_strike(struct sctp_cmd_seq *commands,
|
2012-07-21 14:56:07 +07:00
|
|
|
struct sctp_association *asoc,
|
2009-03-02 16:46:14 +07:00
|
|
|
struct sctp_transport *transport,
|
|
|
|
int is_hb)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2015-12-16 12:55:04 +07:00
|
|
|
struct net *net = sock_net(asoc->base.sk);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* The check for association's overall error counter exceeding the
|
|
|
|
* threshold is done in the state function.
|
|
|
|
*/
|
2009-08-26 20:36:25 +07:00
|
|
|
/* We are here due to a timer expiration. If the timer was
|
|
|
|
* not a HEARTBEAT, then normal error tracking is done.
|
|
|
|
* If the timer was a heartbeat, we only increment error counts
|
|
|
|
* when we already have an outstanding HEARTBEAT that has not
|
|
|
|
* been acknowledged.
|
2011-03-31 08:57:33 +07:00
|
|
|
* Additionally, some tranport states inhibit error increments.
|
2006-07-22 04:48:50 +07:00
|
|
|
*/
|
2009-08-26 20:36:25 +07:00
|
|
|
if (!is_hb) {
|
2006-07-22 04:48:50 +07:00
|
|
|
asoc->overall_error_count++;
|
2009-08-26 20:36:25 +07:00
|
|
|
if (transport->state != SCTP_INACTIVE)
|
|
|
|
transport->error_count++;
|
|
|
|
} else if (transport->hb_sent) {
|
|
|
|
if (transport->state != SCTP_UNCONFIRMED)
|
|
|
|
asoc->overall_error_count++;
|
|
|
|
if (transport->state != SCTP_INACTIVE)
|
|
|
|
transport->error_count++;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-07-21 14:56:07 +07:00
|
|
|
/* If the transport error count is greater than the pf_retrans
|
net: sctp: Potentially-Failed state should not be reached from unconfirmed state
In current implementation it is possible to reach PF state from unconfirmed.
We can interpret sctp-failover-02 in a way that PF state is meant to be reached
only from active state, in the end, this is when entering PF state makes sense.
Here are few quotes from sctp-failover-02, but regardless of these, same
understanding can be reached from whole section 5:
Section 5.1, quickfailover guide:
"The PF state is an intermediate state between Active and Failed states."
"Each time the T3-rtx timer expires on an active or idle
destination, the error counter of that destination address will
be incremented. When the value in the error counter exceeds
PFMR, the endpoint should mark the destination transport address as PF."
There are several concrete reasons for such interpretation. For start, rfc4960
does not take into concern quickfailover algorithm. Therefore, quickfailover
must comply to 4960. Point where this compliance can be argued is following
behavior:
When PF is entered, association overall error counter is incremented for each
missed HB. This is contradictory to rfc4960, as address, while in unconfirmed
state, is subjected to probing, and while it is probed, it should not increment
association overall error counter. This has as a consequence that we might end
up in situation in which we drop association due path failure on unconfirmed
address, in case we have wrong configuration in a way:
Association.Max.Retrans == Path.Max.Retrans.
Another reason is that entering PF from unconfirmed will cause a loss of address
confirmed event when address is once (if) confirmed. This is fine from failover
guide point of view, but it is not consistent with behavior preceding failover
implementation and recommendation from 4960:
5.4. Path Verification
Whenever a path is confirmed, an indication MAY be given to the upper
layer.
Signed-off-by: Matija Glavinic Pecotic <matija.glavinic-pecotic.ext@nsn.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-20 20:13:04 +07:00
|
|
|
* threshold, and less than pathmaxrtx, and if the current state
|
2014-04-26 01:26:30 +07:00
|
|
|
* is SCTP_ACTIVE, then mark this transport as Partially Failed,
|
|
|
|
* see SCTP Quick Failover Draft, section 5.1
|
2012-07-21 14:56:07 +07:00
|
|
|
*/
|
2015-12-16 12:55:04 +07:00
|
|
|
if (net->sctp.pf_enable &&
|
|
|
|
(transport->state == SCTP_ACTIVE) &&
|
2012-07-21 14:56:07 +07:00
|
|
|
(asoc->pf_retrans < transport->pathmaxrxt) &&
|
|
|
|
(transport->error_count > asoc->pf_retrans)) {
|
|
|
|
|
|
|
|
sctp_assoc_control_transport(asoc, transport,
|
|
|
|
SCTP_TRANSPORT_PF,
|
|
|
|
0);
|
|
|
|
|
|
|
|
/* Update the hb timer to resend a heartbeat every rto */
|
sctp: avoid refreshing heartbeat timer too often
Currently on high rate SCTP streams the heartbeat timer refresh can
consume quite a lot of resources as timer updates are costly and it
contains a random factor, which a) is also costly and b) invalidates
mod_timer() optimization for not editing a timer to the same value.
It may even cause the timer to be slightly advanced, for no good reason.
As suggested by David Laight this patch now removes this timer update
from hot path by leaving the timer on and re-evaluating upon its
expiration if the heartbeat is still needed or not, similarly to what is
done for TCP. If it's not needed anymore the timer is re-scheduled to
the new timeout, considering the time already elapsed.
For this, we now record the last tx timestamp per transport, updated in
the same spots as hb timer was restarted on tx. Also split up
sctp_transport_reset_timers into sctp_transport_reset_t3_rtx and
sctp_transport_reset_hb_timer, so we can re-arm T3 without re-arming the
heartbeat one.
On loopback with MTU of 65535 and data chunks with 1636, so that we
have a considerable amount of chunks without stressing system calls,
netperf -t SCTP_STREAM -l 30, perf looked like this before:
Samples: 103K of event 'cpu-clock', Event count (approx.): 25833000000
Overhead Command Shared Object Symbol
+ 6,15% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,43% netperf [kernel.vmlinux] [k] _raw_write_unlock_irqrestore
- _raw_write_unlock_irqrestore
- 96,54% _raw_spin_unlock_irqrestore
- 36,14% mod_timer
+ 97,24% sctp_transport_reset_timers
+ 2,76% sctp_do_sm
+ 33,65% __wake_up_sync_key
+ 28,77% sctp_ulpq_tail_event
+ 1,40% del_timer
- 1,84% mod_timer
+ 99,03% sctp_transport_reset_timers
+ 0,97% sctp_do_sm
+ 1,50% sctp_ulpq_tail_event
And after this patch, now with netperf -l 60:
Samples: 230K of event 'cpu-clock', Event count (approx.): 57707250000
Overhead Command Shared Object Symbol
+ 5,65% netperf [kernel.vmlinux] [k] memcpy_erms
+ 5,59% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,05% netperf [kernel.vmlinux] [k] _raw_spin_unlock_irqrestore
- _raw_spin_unlock_irqrestore
+ 49,89% __wake_up_sync_key
+ 45,68% sctp_ulpq_tail_event
- 2,85% mod_timer
+ 76,51% sctp_transport_reset_t3_rtx
+ 23,49% sctp_do_sm
+ 1,55% del_timer
+ 2,50% netperf [sctp] [k] sctp_datamsg_from_user
+ 2,26% netperf [sctp] [k] sctp_sendmsg
Throughput-wise, from 6800mbps without the patch to 7050mbps with it,
~3.7%.
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-07 01:15:19 +07:00
|
|
|
sctp_transport_reset_hb_timer(transport);
|
2012-07-21 14:56:07 +07:00
|
|
|
}
|
|
|
|
|
2005-06-21 03:14:57 +07:00
|
|
|
if (transport->state != SCTP_INACTIVE &&
|
2009-08-26 20:36:25 +07:00
|
|
|
(transport->error_count > transport->pathmaxrxt)) {
|
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 00:49:40 +07:00
|
|
|
pr_debug("%s: association:%p transport addr:%pISpc failed\n",
|
|
|
|
__func__, asoc, &transport->ipaddr.sa);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_assoc_control_transport(asoc, transport,
|
|
|
|
SCTP_TRANSPORT_DOWN,
|
|
|
|
SCTP_FAILED_THRESHOLD);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* E2) For the destination address for which the timer
|
|
|
|
* expires, set RTO <- RTO * 2 ("back off the timer"). The
|
|
|
|
* maximum value discussed in rule C7 above (RTO.max) may be
|
|
|
|
* used to provide an upper bound to this doubling operation.
|
2009-02-13 15:33:43 +07:00
|
|
|
*
|
|
|
|
* Special Case: the first HB doesn't trigger exponential backoff.
|
tree-wide: Assorted spelling fixes
In particular, several occurances of funny versions of 'success',
'unknown', 'therefore', 'acknowledge', 'argument', 'achieve', 'address',
'beginning', 'desirable', 'separate' and 'necessary' are fixed.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Joe Perches <joe@perches.com>
Cc: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-03 07:01:28 +07:00
|
|
|
* The first unacknowledged HB triggers it. We do this with a flag
|
2009-02-13 15:33:43 +07:00
|
|
|
* that indicates that we have an outstanding HB.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2009-03-02 16:46:14 +07:00
|
|
|
if (!is_hb || transport->hb_sent) {
|
2009-02-13 15:33:43 +07:00
|
|
|
transport->rto = min((transport->rto * 2), transport->asoc->rto_max);
|
2012-12-01 11:49:42 +07:00
|
|
|
sctp_max_rto(asoc, transport);
|
2009-02-13 15:33:43 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Worker routine to handle INIT command failure. */
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_init_failed(struct sctp_cmd_seq *commands,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc,
|
2012-04-15 12:58:06 +07:00
|
|
|
unsigned int error)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct sctp_ulpevent *event;
|
|
|
|
|
2013-12-23 11:16:50 +07:00
|
|
|
event = sctp_ulpevent_make_assoc_change(asoc, 0, SCTP_CANT_STR_ASSOC,
|
2007-03-24 01:34:08 +07:00
|
|
|
(__u16)error, 0, 0, NULL,
|
2005-04-17 05:20:36 +07:00
|
|
|
GFP_ATOMIC);
|
|
|
|
|
|
|
|
if (event)
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
|
|
|
|
SCTP_ULPEVENT(event));
|
|
|
|
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
|
|
|
|
SCTP_STATE(SCTP_STATE_CLOSED));
|
|
|
|
|
|
|
|
/* SEND_FAILED sent later when cleaning up the association. */
|
|
|
|
asoc->outqueue.error = error;
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Worker routine to handle SCTP_CMD_ASSOC_FAILED. */
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_assoc_failed(struct sctp_cmd_seq *commands,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc,
|
2017-08-05 19:00:03 +07:00
|
|
|
enum sctp_event event_type,
|
2017-08-05 19:00:04 +07:00
|
|
|
union sctp_subtype subtype,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_chunk *chunk,
|
2012-04-15 12:58:06 +07:00
|
|
|
unsigned int error)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct sctp_ulpevent *event;
|
2012-11-20 17:14:30 +07:00
|
|
|
struct sctp_chunk *abort;
|
2017-08-11 09:23:57 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Cancel any partial delivery in progress. */
|
2017-12-08 20:04:08 +07:00
|
|
|
asoc->stream.si->abort_pd(&asoc->ulpq, GFP_ATOMIC);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-03-24 01:34:08 +07:00
|
|
|
if (event_type == SCTP_EVENT_T_CHUNK && subtype.chunk == SCTP_CID_ABORT)
|
|
|
|
event = sctp_ulpevent_make_assoc_change(asoc, 0, SCTP_COMM_LOST,
|
|
|
|
(__u16)error, 0, 0, chunk,
|
|
|
|
GFP_ATOMIC);
|
|
|
|
else
|
|
|
|
event = sctp_ulpevent_make_assoc_change(asoc, 0, SCTP_COMM_LOST,
|
|
|
|
(__u16)error, 0, 0, NULL,
|
2005-04-17 05:20:36 +07:00
|
|
|
GFP_ATOMIC);
|
|
|
|
if (event)
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
|
|
|
|
SCTP_ULPEVENT(event));
|
|
|
|
|
2012-11-20 17:14:30 +07:00
|
|
|
if (asoc->overall_error_count >= asoc->max_retrans) {
|
|
|
|
abort = sctp_make_violation_max_retrans(asoc, chunk);
|
|
|
|
if (abort)
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
|
|
|
|
SCTP_CHUNK(abort));
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
|
|
|
|
SCTP_STATE(SCTP_STATE_CLOSED));
|
|
|
|
|
|
|
|
/* SEND_FAILED sent later when cleaning up the association. */
|
|
|
|
asoc->outqueue.error = error;
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Process an init chunk (may be real INIT/INIT-ACK or an embedded INIT
|
|
|
|
* inside the cookie. In reality, this is only used for INIT-ACK processing
|
|
|
|
* since all other cases use "temporary" associations and can do all
|
|
|
|
* their work in statefuns directly.
|
|
|
|
*/
|
2017-08-11 09:23:52 +07:00
|
|
|
static int sctp_cmd_process_init(struct sctp_cmd_seq *commands,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc,
|
|
|
|
struct sctp_chunk *chunk,
|
2017-06-30 10:52:22 +07:00
|
|
|
struct sctp_init_chunk *peer_init,
|
2005-10-07 13:46:04 +07:00
|
|
|
gfp_t gfp)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* We only process the init as a sideeffect in a single
|
|
|
|
* case. This is when we process the INIT-ACK. If we
|
|
|
|
* fail during INIT processing (due to malloc problems),
|
|
|
|
* just return the error and stop processing the stack.
|
|
|
|
*/
|
2011-04-20 04:30:51 +07:00
|
|
|
if (!sctp_process_init(asoc, chunk, sctp_source(chunk), peer_init, gfp))
|
2005-04-17 05:20:36 +07:00
|
|
|
error = -ENOMEM;
|
|
|
|
else
|
|
|
|
error = 0;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to break out starting up of heartbeat timers. */
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_hb_timers_start(struct sctp_cmd_seq *cmds,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc)
|
|
|
|
{
|
|
|
|
struct sctp_transport *t;
|
|
|
|
|
|
|
|
/* Start a heartbeat timer for each transport on the association.
|
|
|
|
* hold a reference on the transport to make sure none of
|
|
|
|
* the needed data structures go away.
|
|
|
|
*/
|
sctp: avoid refreshing heartbeat timer too often
Currently on high rate SCTP streams the heartbeat timer refresh can
consume quite a lot of resources as timer updates are costly and it
contains a random factor, which a) is also costly and b) invalidates
mod_timer() optimization for not editing a timer to the same value.
It may even cause the timer to be slightly advanced, for no good reason.
As suggested by David Laight this patch now removes this timer update
from hot path by leaving the timer on and re-evaluating upon its
expiration if the heartbeat is still needed or not, similarly to what is
done for TCP. If it's not needed anymore the timer is re-scheduled to
the new timeout, considering the time already elapsed.
For this, we now record the last tx timestamp per transport, updated in
the same spots as hb timer was restarted on tx. Also split up
sctp_transport_reset_timers into sctp_transport_reset_t3_rtx and
sctp_transport_reset_hb_timer, so we can re-arm T3 without re-arming the
heartbeat one.
On loopback with MTU of 65535 and data chunks with 1636, so that we
have a considerable amount of chunks without stressing system calls,
netperf -t SCTP_STREAM -l 30, perf looked like this before:
Samples: 103K of event 'cpu-clock', Event count (approx.): 25833000000
Overhead Command Shared Object Symbol
+ 6,15% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,43% netperf [kernel.vmlinux] [k] _raw_write_unlock_irqrestore
- _raw_write_unlock_irqrestore
- 96,54% _raw_spin_unlock_irqrestore
- 36,14% mod_timer
+ 97,24% sctp_transport_reset_timers
+ 2,76% sctp_do_sm
+ 33,65% __wake_up_sync_key
+ 28,77% sctp_ulpq_tail_event
+ 1,40% del_timer
- 1,84% mod_timer
+ 99,03% sctp_transport_reset_timers
+ 0,97% sctp_do_sm
+ 1,50% sctp_ulpq_tail_event
And after this patch, now with netperf -l 60:
Samples: 230K of event 'cpu-clock', Event count (approx.): 57707250000
Overhead Command Shared Object Symbol
+ 5,65% netperf [kernel.vmlinux] [k] memcpy_erms
+ 5,59% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,05% netperf [kernel.vmlinux] [k] _raw_spin_unlock_irqrestore
- _raw_spin_unlock_irqrestore
+ 49,89% __wake_up_sync_key
+ 45,68% sctp_ulpq_tail_event
- 2,85% mod_timer
+ 76,51% sctp_transport_reset_t3_rtx
+ 23,49% sctp_do_sm
+ 1,55% del_timer
+ 2,50% netperf [sctp] [k] sctp_datamsg_from_user
+ 2,26% netperf [sctp] [k] sctp_sendmsg
Throughput-wise, from 6800mbps without the patch to 7050mbps with it,
~3.7%.
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-07 01:15:19 +07:00
|
|
|
list_for_each_entry(t, &asoc->peer.transport_addr_list, transports)
|
|
|
|
sctp_transport_reset_hb_timer(t);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_hb_timers_stop(struct sctp_cmd_seq *cmds,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc)
|
|
|
|
{
|
|
|
|
struct sctp_transport *t;
|
|
|
|
|
|
|
|
/* Stop all heartbeat timers. */
|
|
|
|
|
2008-04-13 08:54:24 +07:00
|
|
|
list_for_each_entry(t, &asoc->peer.transport_addr_list,
|
|
|
|
transports) {
|
2005-04-17 05:20:36 +07:00
|
|
|
if (del_timer(&t->hb_timer))
|
|
|
|
sctp_transport_put(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to stop any pending T3-RTX timers */
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_t3_rtx_timers_stop(struct sctp_cmd_seq *cmds,
|
2007-02-09 21:25:18 +07:00
|
|
|
struct sctp_association *asoc)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct sctp_transport *t;
|
|
|
|
|
2008-04-13 08:54:24 +07:00
|
|
|
list_for_each_entry(t, &asoc->peer.transport_addr_list,
|
|
|
|
transports) {
|
2013-02-04 03:32:57 +07:00
|
|
|
if (del_timer(&t->T3_rtx_timer))
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_transport_put(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Helper function to handle the reception of an HEARTBEAT ACK. */
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_transport_on(struct sctp_cmd_seq *cmds,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc,
|
|
|
|
struct sctp_transport *t,
|
|
|
|
struct sctp_chunk *chunk)
|
|
|
|
{
|
2017-08-11 09:23:46 +07:00
|
|
|
struct sctp_sender_hb_info *hbinfo;
|
2011-06-17 09:22:35 +07:00
|
|
|
int was_unconfirmed = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* 8.3 Upon the receipt of the HEARTBEAT ACK, the sender of the
|
|
|
|
* HEARTBEAT should clear the error counter of the destination
|
|
|
|
* transport address to which the HEARTBEAT was sent.
|
|
|
|
*/
|
|
|
|
t->error_count = 0;
|
2011-07-07 07:28:35 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Although RFC4960 specifies that the overall error count must
|
|
|
|
* be cleared when a HEARTBEAT ACK is received, we make an
|
|
|
|
* exception while in SHUTDOWN PENDING. If the peer keeps its
|
|
|
|
* window shut forever, we may never be able to transmit our
|
|
|
|
* outstanding data and rely on the retransmission limit be reached
|
|
|
|
* to shutdown the association.
|
|
|
|
*/
|
2015-08-27 03:52:20 +07:00
|
|
|
if (t->asoc->state < SCTP_STATE_SHUTDOWN_PENDING)
|
2011-07-07 07:28:35 +07:00
|
|
|
t->asoc->overall_error_count = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-02-13 15:33:43 +07:00
|
|
|
/* Clear the hb_sent flag to signal that we had a good
|
|
|
|
* acknowledgement.
|
|
|
|
*/
|
|
|
|
t->hb_sent = 0;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Mark the destination transport address as active if it is not so
|
|
|
|
* marked.
|
|
|
|
*/
|
2011-06-17 09:22:35 +07:00
|
|
|
if ((t->state == SCTP_INACTIVE) || (t->state == SCTP_UNCONFIRMED)) {
|
|
|
|
was_unconfirmed = 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP,
|
|
|
|
SCTP_HEARTBEAT_SUCCESS);
|
2011-06-17 09:22:35 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-07-21 14:56:07 +07:00
|
|
|
if (t->state == SCTP_PF)
|
|
|
|
sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP,
|
|
|
|
SCTP_HEARTBEAT_SUCCESS);
|
|
|
|
|
2013-07-09 21:17:04 +07:00
|
|
|
/* HB-ACK was received for a the proper HB. Consider this
|
|
|
|
* forward progress.
|
|
|
|
*/
|
|
|
|
if (t->dst)
|
2017-02-07 04:14:13 +07:00
|
|
|
sctp_transport_dst_confirm(t);
|
2013-07-09 21:17:04 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* The receiver of the HEARTBEAT ACK should also perform an
|
|
|
|
* RTT measurement for that destination transport address
|
|
|
|
* using the time value carried in the HEARTBEAT ACK chunk.
|
2007-01-31 05:36:14 +07:00
|
|
|
* If the transport's rto_pending variable has been cleared,
|
|
|
|
* it was most likely due to a retransmit. However, we want
|
|
|
|
* to re-enable it to properly update the rto.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2007-01-31 05:36:14 +07:00
|
|
|
if (t->rto_pending == 0)
|
|
|
|
t->rto_pending = 1;
|
|
|
|
|
2017-08-11 09:23:46 +07:00
|
|
|
hbinfo = (struct sctp_sender_hb_info *)chunk->skb->data;
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_transport_update_rto(t, (jiffies - hbinfo->sent_at));
|
2006-07-22 04:48:50 +07:00
|
|
|
|
|
|
|
/* Update the heartbeat timer. */
|
sctp: avoid refreshing heartbeat timer too often
Currently on high rate SCTP streams the heartbeat timer refresh can
consume quite a lot of resources as timer updates are costly and it
contains a random factor, which a) is also costly and b) invalidates
mod_timer() optimization for not editing a timer to the same value.
It may even cause the timer to be slightly advanced, for no good reason.
As suggested by David Laight this patch now removes this timer update
from hot path by leaving the timer on and re-evaluating upon its
expiration if the heartbeat is still needed or not, similarly to what is
done for TCP. If it's not needed anymore the timer is re-scheduled to
the new timeout, considering the time already elapsed.
For this, we now record the last tx timestamp per transport, updated in
the same spots as hb timer was restarted on tx. Also split up
sctp_transport_reset_timers into sctp_transport_reset_t3_rtx and
sctp_transport_reset_hb_timer, so we can re-arm T3 without re-arming the
heartbeat one.
On loopback with MTU of 65535 and data chunks with 1636, so that we
have a considerable amount of chunks without stressing system calls,
netperf -t SCTP_STREAM -l 30, perf looked like this before:
Samples: 103K of event 'cpu-clock', Event count (approx.): 25833000000
Overhead Command Shared Object Symbol
+ 6,15% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,43% netperf [kernel.vmlinux] [k] _raw_write_unlock_irqrestore
- _raw_write_unlock_irqrestore
- 96,54% _raw_spin_unlock_irqrestore
- 36,14% mod_timer
+ 97,24% sctp_transport_reset_timers
+ 2,76% sctp_do_sm
+ 33,65% __wake_up_sync_key
+ 28,77% sctp_ulpq_tail_event
+ 1,40% del_timer
- 1,84% mod_timer
+ 99,03% sctp_transport_reset_timers
+ 0,97% sctp_do_sm
+ 1,50% sctp_ulpq_tail_event
And after this patch, now with netperf -l 60:
Samples: 230K of event 'cpu-clock', Event count (approx.): 57707250000
Overhead Command Shared Object Symbol
+ 5,65% netperf [kernel.vmlinux] [k] memcpy_erms
+ 5,59% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,05% netperf [kernel.vmlinux] [k] _raw_spin_unlock_irqrestore
- _raw_spin_unlock_irqrestore
+ 49,89% __wake_up_sync_key
+ 45,68% sctp_ulpq_tail_event
- 2,85% mod_timer
+ 76,51% sctp_transport_reset_t3_rtx
+ 23,49% sctp_do_sm
+ 1,55% del_timer
+ 2,50% netperf [sctp] [k] sctp_datamsg_from_user
+ 2,26% netperf [sctp] [k] sctp_sendmsg
Throughput-wise, from 6800mbps without the patch to 7050mbps with it,
~3.7%.
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-07 01:15:19 +07:00
|
|
|
sctp_transport_reset_hb_timer(t);
|
2011-06-17 09:22:35 +07:00
|
|
|
|
|
|
|
if (was_unconfirmed && asoc->peer.transport_count == 1)
|
|
|
|
sctp_transport_immediate_rtx(t);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Helper function to process the process SACK command. */
|
2017-08-11 09:23:52 +07:00
|
|
|
static int sctp_cmd_process_sack(struct sctp_cmd_seq *cmds,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc,
|
2012-10-03 12:43:22 +07:00
|
|
|
struct sctp_chunk *chunk)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2008-06-20 06:08:18 +07:00
|
|
|
int err = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2012-10-03 12:43:22 +07:00
|
|
|
if (sctp_outq_sack(&asoc->outqueue, chunk)) {
|
2012-08-07 14:25:24 +07:00
|
|
|
struct net *net = sock_net(asoc->base.sk);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* There are no more TSNs awaiting SACK. */
|
2012-08-07 14:25:24 +07:00
|
|
|
err = sctp_do_sm(net, SCTP_EVENT_T_OTHER,
|
2005-04-17 05:20:36 +07:00
|
|
|
SCTP_ST_OTHER(SCTP_EVENT_NO_PENDING_TSN),
|
|
|
|
asoc->state, asoc->ep, asoc, NULL,
|
|
|
|
GFP_ATOMIC);
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to set the timeout value for T2-SHUTDOWN timer and to set
|
|
|
|
* the transport for a shutdown chunk.
|
|
|
|
*/
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_setup_t2(struct sctp_cmd_seq *cmds,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc,
|
|
|
|
struct sctp_chunk *chunk)
|
|
|
|
{
|
|
|
|
struct sctp_transport *t;
|
|
|
|
|
2010-05-01 08:42:43 +07:00
|
|
|
if (chunk->transport)
|
|
|
|
t = chunk->transport;
|
|
|
|
else {
|
|
|
|
t = sctp_assoc_choose_alter_transport(asoc,
|
2009-05-12 20:52:51 +07:00
|
|
|
asoc->shutdown_last_sent_to);
|
2010-05-01 08:42:43 +07:00
|
|
|
chunk->transport = t;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
asoc->shutdown_last_sent_to = t;
|
|
|
|
asoc->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] = t->rto;
|
|
|
|
}
|
|
|
|
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_assoc_update(struct sctp_cmd_seq *cmds,
|
2017-06-20 15:05:11 +07:00
|
|
|
struct sctp_association *asoc,
|
|
|
|
struct sctp_association *new)
|
|
|
|
{
|
|
|
|
struct net *net = sock_net(asoc->base.sk);
|
|
|
|
struct sctp_chunk *abort;
|
|
|
|
|
|
|
|
if (!sctp_assoc_update(asoc, new))
|
|
|
|
return;
|
|
|
|
|
2017-08-03 14:42:11 +07:00
|
|
|
abort = sctp_make_abort(asoc, NULL, sizeof(struct sctp_errhdr));
|
2017-06-20 15:05:11 +07:00
|
|
|
if (abort) {
|
|
|
|
sctp_init_cause(abort, SCTP_ERROR_RSRC_LOW, 0);
|
|
|
|
sctp_add_cmd_sf(cmds, SCTP_CMD_REPLY, SCTP_CHUNK(abort));
|
|
|
|
}
|
|
|
|
sctp_add_cmd_sf(cmds, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNABORTED));
|
|
|
|
sctp_add_cmd_sf(cmds, SCTP_CMD_ASSOC_FAILED,
|
|
|
|
SCTP_PERR(SCTP_ERROR_RSRC_LOW));
|
|
|
|
SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
|
|
|
|
SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Helper function to change the state of an association. */
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_new_state(struct sctp_cmd_seq *cmds,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc,
|
2017-08-05 18:59:59 +07:00
|
|
|
enum sctp_state state)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct sock *sk = asoc->base.sk;
|
|
|
|
|
|
|
|
asoc->state = state;
|
|
|
|
|
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 00:49:40 +07:00
|
|
|
pr_debug("%s: asoc:%p[%s]\n", __func__, asoc, sctp_state_tbl[state]);
|
2005-06-21 03:14:57 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
if (sctp_style(sk, TCP)) {
|
2005-06-21 03:14:57 +07:00
|
|
|
/* Change the sk->sk_state of a TCP-style socket that has
|
tree-wide: fix assorted typos all over the place
That is "success", "unknown", "through", "performance", "[re|un]mapping"
, "access", "default", "reasonable", "[con]currently", "temperature"
, "channel", "[un]used", "application", "example","hierarchy", "therefore"
, "[over|under]flow", "contiguous", "threshold", "enough" and others.
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-11-14 22:09:05 +07:00
|
|
|
* successfully completed a connect() call.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
if (sctp_state(asoc, ESTABLISHED) && sctp_sstate(sk, CLOSED))
|
2017-12-20 10:12:54 +07:00
|
|
|
inet_sk_set_state(sk, SCTP_SS_ESTABLISHED);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Set the RCV_SHUTDOWN flag when a SHUTDOWN is received. */
|
|
|
|
if (sctp_state(asoc, SHUTDOWN_RECEIVED) &&
|
2016-06-09 21:48:18 +07:00
|
|
|
sctp_sstate(sk, ESTABLISHED)) {
|
2017-12-20 10:12:54 +07:00
|
|
|
inet_sk_set_state(sk, SCTP_SS_CLOSING);
|
2005-04-17 05:20:36 +07:00
|
|
|
sk->sk_shutdown |= RCV_SHUTDOWN;
|
2016-06-09 21:48:18 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2005-06-21 03:14:57 +07:00
|
|
|
if (sctp_state(asoc, COOKIE_WAIT)) {
|
|
|
|
/* Reset init timeouts since they may have been
|
|
|
|
* increased due to timer expirations.
|
|
|
|
*/
|
|
|
|
asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] =
|
2005-11-12 07:06:16 +07:00
|
|
|
asoc->rto_initial;
|
2005-06-21 03:14:57 +07:00
|
|
|
asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE] =
|
2005-11-12 07:06:16 +07:00
|
|
|
asoc->rto_initial;
|
2005-06-21 03:14:57 +07:00
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
if (sctp_state(asoc, ESTABLISHED) ||
|
|
|
|
sctp_state(asoc, CLOSED) ||
|
|
|
|
sctp_state(asoc, SHUTDOWN_RECEIVED)) {
|
|
|
|
/* Wake up any processes waiting in the asoc's wait queue in
|
|
|
|
* sctp_wait_for_connect() or sctp_wait_for_sndbuf().
|
2007-02-09 21:25:18 +07:00
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
if (waitqueue_active(&asoc->wait))
|
|
|
|
wake_up_interruptible(&asoc->wait);
|
|
|
|
|
|
|
|
/* Wake up any processes waiting in the sk's sleep queue of
|
|
|
|
* a TCP-style or UDP-style peeled-off socket in
|
|
|
|
* sctp_wait_for_accept() or sctp_wait_for_packet().
|
|
|
|
* For a UDP-style socket, the waiters are woken up by the
|
|
|
|
* notifications.
|
|
|
|
*/
|
|
|
|
if (!sctp_style(sk, UDP))
|
|
|
|
sk->sk_state_change(sk);
|
|
|
|
}
|
2017-02-19 00:52:45 +07:00
|
|
|
|
|
|
|
if (sctp_state(asoc, SHUTDOWN_PENDING) &&
|
|
|
|
!sctp_outq_is_empty(&asoc->outqueue))
|
|
|
|
sctp_outq_uncork(&asoc->outqueue, GFP_ATOMIC);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function to delete an association. */
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_delete_tcb(struct sctp_cmd_seq *cmds,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc)
|
|
|
|
{
|
|
|
|
struct sock *sk = asoc->base.sk;
|
|
|
|
|
|
|
|
/* If it is a non-temporary association belonging to a TCP-style
|
2007-02-09 21:25:18 +07:00
|
|
|
* listening socket that is not closed, do not free it so that accept()
|
2005-04-17 05:20:36 +07:00
|
|
|
* can pick it up later.
|
2007-02-09 21:25:18 +07:00
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING) &&
|
|
|
|
(!asoc->temp) && (sk->sk_shutdown != SHUTDOWN_MASK))
|
|
|
|
return;
|
|
|
|
|
|
|
|
sctp_association_free(asoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ADDIP Section 4.1 ASCONF Chunk Procedures
|
|
|
|
* A4) Start a T-4 RTO timer, using the RTO value of the selected
|
|
|
|
* destination address (we use active path instead of primary path just
|
2007-02-09 21:25:18 +07:00
|
|
|
* because primary path may be inactive.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_setup_t4(struct sctp_cmd_seq *cmds,
|
|
|
|
struct sctp_association *asoc,
|
|
|
|
struct sctp_chunk *chunk)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct sctp_transport *t;
|
|
|
|
|
2009-05-12 20:52:51 +07:00
|
|
|
t = sctp_assoc_choose_alter_transport(asoc, chunk->transport);
|
2005-04-17 05:20:36 +07:00
|
|
|
asoc->timeouts[SCTP_EVENT_TIMEOUT_T4_RTO] = t->rto;
|
|
|
|
chunk->transport = t;
|
|
|
|
}
|
|
|
|
|
2007-02-09 21:25:18 +07:00
|
|
|
/* Process an incoming Operation Error Chunk. */
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_process_operr(struct sctp_cmd_seq *cmds,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_association *asoc,
|
|
|
|
struct sctp_chunk *chunk)
|
|
|
|
{
|
|
|
|
struct sctp_errhdr *err_hdr;
|
2009-03-02 13:46:51 +07:00
|
|
|
struct sctp_ulpevent *ev;
|
|
|
|
|
|
|
|
while (chunk->chunk_end > chunk->skb->data) {
|
|
|
|
err_hdr = (struct sctp_errhdr *)(chunk->skb->data);
|
|
|
|
|
|
|
|
ev = sctp_ulpevent_make_remote_error(asoc, chunk, 0,
|
|
|
|
GFP_ATOMIC);
|
|
|
|
if (!ev)
|
|
|
|
return;
|
|
|
|
|
2017-12-08 20:04:05 +07:00
|
|
|
asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
|
2009-03-02 13:46:51 +07:00
|
|
|
|
|
|
|
switch (err_hdr->cause) {
|
|
|
|
case SCTP_ERROR_UNKNOWN_CHUNK:
|
|
|
|
{
|
2017-06-30 10:52:13 +07:00
|
|
|
struct sctp_chunkhdr *unk_chunk_hdr;
|
2009-03-02 13:46:51 +07:00
|
|
|
|
2017-06-30 10:52:13 +07:00
|
|
|
unk_chunk_hdr = (struct sctp_chunkhdr *)
|
|
|
|
err_hdr->variable;
|
2009-03-02 13:46:51 +07:00
|
|
|
switch (unk_chunk_hdr->type) {
|
|
|
|
/* ADDIP 4.1 A9) If the peer responds to an ASCONF with
|
|
|
|
* an ERROR chunk reporting that it did not recognized
|
|
|
|
* the ASCONF chunk type, the sender of the ASCONF MUST
|
|
|
|
* NOT send any further ASCONF chunks and MUST stop its
|
|
|
|
* T-4 timer.
|
|
|
|
*/
|
|
|
|
case SCTP_CID_ASCONF:
|
|
|
|
if (asoc->peer.asconf_capable == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
asoc->peer.asconf_capable = 0;
|
|
|
|
sctp_add_cmd_sf(cmds, SCTP_CMD_TIMER_STOP,
|
2005-04-17 05:20:36 +07:00
|
|
|
SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));
|
2009-03-02 13:46:51 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
2009-03-02 13:46:51 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-09 21:25:18 +07:00
|
|
|
/* Helper function to remove the association non-primary peer
|
2005-04-17 05:20:36 +07:00
|
|
|
* transports.
|
2007-02-09 21:25:18 +07:00
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
static void sctp_cmd_del_non_primary(struct sctp_association *asoc)
|
|
|
|
{
|
|
|
|
struct sctp_transport *t;
|
|
|
|
struct list_head *temp;
|
2017-08-11 09:23:57 +07:00
|
|
|
struct list_head *pos;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
|
|
|
|
t = list_entry(pos, struct sctp_transport, transports);
|
2006-11-21 08:05:23 +07:00
|
|
|
if (!sctp_cmp_addr_exact(&t->ipaddr,
|
2007-02-09 21:25:18 +07:00
|
|
|
&asoc->peer.primary_addr)) {
|
2015-08-29 08:23:39 +07:00
|
|
|
sctp_assoc_rm_peer(asoc, t);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-20 00:58:12 +07:00
|
|
|
/* Helper function to set sk_err on a 1-1 style socket. */
|
|
|
|
static void sctp_cmd_set_sk_err(struct sctp_association *asoc, int error)
|
|
|
|
{
|
|
|
|
struct sock *sk = asoc->base.sk;
|
|
|
|
|
|
|
|
if (!sctp_style(sk, UDP))
|
|
|
|
sk->sk_err = error;
|
|
|
|
}
|
|
|
|
|
2007-05-05 03:55:27 +07:00
|
|
|
/* Helper function to generate an association change event */
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_assoc_change(struct sctp_cmd_seq *commands,
|
|
|
|
struct sctp_association *asoc,
|
|
|
|
u8 state)
|
2007-05-05 03:55:27 +07:00
|
|
|
{
|
|
|
|
struct sctp_ulpevent *ev;
|
|
|
|
|
|
|
|
ev = sctp_ulpevent_make_assoc_change(asoc, 0, state, 0,
|
|
|
|
asoc->c.sinit_num_ostreams,
|
|
|
|
asoc->c.sinit_max_instreams,
|
|
|
|
NULL, GFP_ATOMIC);
|
|
|
|
if (ev)
|
2017-12-08 20:04:05 +07:00
|
|
|
asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
|
2007-05-05 03:55:27 +07:00
|
|
|
}
|
|
|
|
|
2018-03-14 18:05:34 +07:00
|
|
|
static void sctp_cmd_peer_no_auth(struct sctp_cmd_seq *commands,
|
|
|
|
struct sctp_association *asoc)
|
|
|
|
{
|
|
|
|
struct sctp_ulpevent *ev;
|
|
|
|
|
|
|
|
ev = sctp_ulpevent_make_authkey(asoc, 0, SCTP_AUTH_NO_AUTH, GFP_ATOMIC);
|
|
|
|
if (ev)
|
|
|
|
asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
|
|
|
|
}
|
|
|
|
|
2007-05-05 03:55:27 +07:00
|
|
|
/* Helper function to generate an adaptation indication event */
|
2017-08-11 09:23:52 +07:00
|
|
|
static void sctp_cmd_adaptation_ind(struct sctp_cmd_seq *commands,
|
2007-05-05 03:55:27 +07:00
|
|
|
struct sctp_association *asoc)
|
|
|
|
{
|
|
|
|
struct sctp_ulpevent *ev;
|
|
|
|
|
|
|
|
ev = sctp_ulpevent_make_adaptation_indication(asoc, GFP_ATOMIC);
|
|
|
|
|
|
|
|
if (ev)
|
2017-12-08 20:04:05 +07:00
|
|
|
asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
|
2007-05-05 03:55:27 +07:00
|
|
|
}
|
|
|
|
|
2008-09-09 01:00:26 +07:00
|
|
|
|
|
|
|
static void sctp_cmd_t1_timer_update(struct sctp_association *asoc,
|
2017-08-05 19:00:02 +07:00
|
|
|
enum sctp_event_timeout timer,
|
|
|
|
char *name)
|
2008-09-09 01:00:26 +07:00
|
|
|
{
|
|
|
|
struct sctp_transport *t;
|
|
|
|
|
|
|
|
t = asoc->init_last_sent_to;
|
|
|
|
asoc->init_err_counter++;
|
|
|
|
|
|
|
|
if (t->init_sent_count > (asoc->init_cycle + 1)) {
|
|
|
|
asoc->timeouts[timer] *= 2;
|
|
|
|
if (asoc->timeouts[timer] > asoc->max_init_timeo) {
|
|
|
|
asoc->timeouts[timer] = asoc->max_init_timeo;
|
|
|
|
}
|
|
|
|
asoc->init_cycle++;
|
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 00:49:40 +07:00
|
|
|
|
|
|
|
pr_debug("%s: T1[%s] timeout adjustment init_err_counter:%d"
|
|
|
|
" cycle:%d timeout:%ld\n", __func__, name,
|
|
|
|
asoc->init_err_counter, asoc->init_cycle,
|
|
|
|
asoc->timeouts[timer]);
|
2008-09-09 01:00:26 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-08-11 00:51:03 +07:00
|
|
|
/* Send the whole message, chunk by chunk, to the outqueue.
|
|
|
|
* This way the whole message is queued up and bundling if
|
|
|
|
* encouraged for small fragments.
|
|
|
|
*/
|
2016-09-14 01:04:19 +07:00
|
|
|
static void sctp_cmd_send_msg(struct sctp_association *asoc,
|
|
|
|
struct sctp_datamsg *msg, gfp_t gfp)
|
2009-08-11 00:51:03 +07:00
|
|
|
{
|
|
|
|
struct sctp_chunk *chunk;
|
|
|
|
|
2016-09-14 01:04:19 +07:00
|
|
|
list_for_each_entry(chunk, &msg->chunks, frag_list)
|
|
|
|
sctp_outq_tail(&asoc->outqueue, chunk, gfp);
|
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 05:20:13 +07:00
|
|
|
|
|
|
|
asoc->outqueue.sched->enqueue(&asoc->outqueue, msg);
|
2009-08-11 00:51:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-28 15:47:22 +07:00
|
|
|
/* Sent the next ASCONF packet currently stored in the association.
|
|
|
|
* This happens after the ASCONF_ACK was succeffully processed.
|
|
|
|
*/
|
|
|
|
static void sctp_cmd_send_asconf(struct sctp_association *asoc)
|
|
|
|
{
|
2012-08-07 14:25:24 +07:00
|
|
|
struct net *net = sock_net(asoc->base.sk);
|
|
|
|
|
2010-04-28 15:47:22 +07:00
|
|
|
/* Send the next asconf chunk from the addip chunk
|
|
|
|
* queue.
|
|
|
|
*/
|
|
|
|
if (!list_empty(&asoc->addip_chunk_list)) {
|
|
|
|
struct list_head *entry = asoc->addip_chunk_list.next;
|
|
|
|
struct sctp_chunk *asconf = list_entry(entry,
|
|
|
|
struct sctp_chunk, list);
|
|
|
|
list_del_init(entry);
|
|
|
|
|
|
|
|
/* Hold the chunk until an ASCONF_ACK is received. */
|
|
|
|
sctp_chunk_hold(asconf);
|
2012-08-07 14:25:24 +07:00
|
|
|
if (sctp_primitive_ASCONF(net, asoc, asconf))
|
2010-04-28 15:47:22 +07:00
|
|
|
sctp_chunk_free(asconf);
|
|
|
|
else
|
|
|
|
asoc->addip_last_asconf = asconf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-11 00:51:03 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* These three macros allow us to pull the debugging code out of the
|
|
|
|
* main flow of sctp_do_sm() to keep attention focused on the real
|
|
|
|
* functionality there.
|
|
|
|
*/
|
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 00:49:40 +07:00
|
|
|
#define debug_pre_sfn() \
|
|
|
|
pr_debug("%s[pre-fn]: ep:%p, %s, %s, asoc:%p[%s], %s\n", __func__, \
|
|
|
|
ep, sctp_evttype_tbl[event_type], (*debug_fn)(subtype), \
|
|
|
|
asoc, sctp_state_tbl[state], state_fn->name)
|
|
|
|
|
|
|
|
#define debug_post_sfn() \
|
|
|
|
pr_debug("%s[post-fn]: asoc:%p, status:%s\n", __func__, asoc, \
|
|
|
|
sctp_status_tbl[status])
|
|
|
|
|
|
|
|
#define debug_post_sfx() \
|
|
|
|
pr_debug("%s[post-sfx]: error:%d, asoc:%p[%s]\n", __func__, error, \
|
|
|
|
asoc, sctp_state_tbl[(asoc && sctp_id2assoc(ep->base.sk, \
|
|
|
|
sctp_assoc2id(asoc))) ? asoc->state : SCTP_STATE_CLOSED])
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the master state machine processing function.
|
|
|
|
*
|
|
|
|
* If you want to understand all of lksctp, this is a
|
|
|
|
* good place to start.
|
|
|
|
*/
|
2017-08-05 19:00:03 +07:00
|
|
|
int sctp_do_sm(struct net *net, enum sctp_event event_type,
|
2017-08-05 19:00:04 +07:00
|
|
|
union sctp_subtype subtype, enum sctp_state state,
|
2017-08-05 19:00:03 +07:00
|
|
|
struct sctp_endpoint *ep, struct sctp_association *asoc,
|
|
|
|
void *event_arg, gfp_t gfp)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-08-05 19:00:04 +07:00
|
|
|
typedef const char *(printfn_t)(union sctp_subtype);
|
2005-04-17 05:20:36 +07:00
|
|
|
static printfn_t *table[] = {
|
|
|
|
NULL, sctp_cname, sctp_tname, sctp_oname, sctp_pname,
|
|
|
|
};
|
|
|
|
printfn_t *debug_fn __attribute__ ((unused)) = table[event_type];
|
2017-08-11 09:23:57 +07:00
|
|
|
const struct sctp_sm_table_entry *state_fn;
|
|
|
|
struct sctp_cmd_seq commands;
|
|
|
|
enum sctp_disposition status;
|
|
|
|
int error = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Look up the state function, run it, and then process the
|
|
|
|
* side effects. These three steps are the heart of lksctp.
|
|
|
|
*/
|
2012-08-07 14:25:24 +07:00
|
|
|
state_fn = sctp_sm_lookup_event(net, event_type, state, subtype);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
sctp_init_cmd_seq(&commands);
|
|
|
|
|
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 00:49:40 +07:00
|
|
|
debug_pre_sfn();
|
2013-12-18 16:18:55 +07:00
|
|
|
status = state_fn->fn(net, ep, asoc, subtype, event_arg, &commands);
|
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 00:49:40 +07:00
|
|
|
debug_post_sfn();
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
error = sctp_side_effects(event_type, subtype, state,
|
2016-01-08 20:00:54 +07:00
|
|
|
ep, &asoc, event_arg, status,
|
2005-04-17 05:20:36 +07:00
|
|
|
&commands, gfp);
|
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 00:49:40 +07:00
|
|
|
debug_post_sfx();
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* This the master state function side effect processing function.
|
|
|
|
*****************************************************************/
|
2017-08-05 19:00:04 +07:00
|
|
|
static int sctp_side_effects(enum sctp_event event_type,
|
|
|
|
union sctp_subtype subtype,
|
2017-08-05 18:59:59 +07:00
|
|
|
enum sctp_state state,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_endpoint *ep,
|
2016-01-08 20:00:54 +07:00
|
|
|
struct sctp_association **asoc,
|
2005-04-17 05:20:36 +07:00
|
|
|
void *event_arg,
|
2017-08-11 09:23:57 +07:00
|
|
|
enum sctp_disposition status,
|
2017-08-11 09:23:52 +07:00
|
|
|
struct sctp_cmd_seq *commands,
|
2005-10-07 13:46:04 +07:00
|
|
|
gfp_t gfp)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* FIXME - Most of the dispositions left today would be categorized
|
|
|
|
* as "exceptional" dispositions. For those dispositions, it
|
|
|
|
* may not be proper to run through any of the commands at all.
|
|
|
|
* For example, the command interpreter might be run only with
|
|
|
|
* disposition SCTP_DISPOSITION_CONSUME.
|
|
|
|
*/
|
|
|
|
if (0 != (error = sctp_cmd_interpreter(event_type, subtype, state,
|
2016-01-08 20:00:54 +07:00
|
|
|
ep, *asoc,
|
2005-04-17 05:20:36 +07:00
|
|
|
event_arg, status,
|
|
|
|
commands, gfp)))
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case SCTP_DISPOSITION_DISCARD:
|
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 00:49:40 +07:00
|
|
|
pr_debug("%s: ignored sctp protocol event - state:%d, "
|
|
|
|
"event_type:%d, event_id:%d\n", __func__, state,
|
|
|
|
event_type, subtype.chunk);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_DISPOSITION_NOMEM:
|
|
|
|
/* We ran out of memory, so we need to discard this
|
|
|
|
* packet.
|
|
|
|
*/
|
|
|
|
/* BUG--we should now recover some memory, probably by
|
|
|
|
* reneging...
|
|
|
|
*/
|
|
|
|
error = -ENOMEM;
|
|
|
|
break;
|
|
|
|
|
2007-02-09 21:25:18 +07:00
|
|
|
case SCTP_DISPOSITION_DELETE_TCB:
|
2016-01-08 20:00:54 +07:00
|
|
|
case SCTP_DISPOSITION_ABORT:
|
2005-04-17 05:20:36 +07:00
|
|
|
/* This should now be a command. */
|
2016-01-08 20:00:54 +07:00
|
|
|
*asoc = NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_DISPOSITION_CONSUME:
|
|
|
|
/*
|
|
|
|
* We should no longer have much work to do here as the
|
|
|
|
* real work has been done as explicit commands above.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_DISPOSITION_VIOLATION:
|
2012-05-14 04:56:26 +07:00
|
|
|
net_err_ratelimited("protocol violation state %d chunkid %d\n",
|
|
|
|
state, subtype.chunk);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_DISPOSITION_NOT_IMPL:
|
2010-08-24 20:21:08 +07:00
|
|
|
pr_warn("unimplemented feature in state %d, event_type %d, event_id %d\n",
|
|
|
|
state, event_type, subtype.chunk);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_DISPOSITION_BUG:
|
2010-08-24 20:21:08 +07:00
|
|
|
pr_err("bug in state %d, event_type %d, event_id %d\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
state, event_type, subtype.chunk);
|
|
|
|
BUG();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-08-24 20:21:08 +07:00
|
|
|
pr_err("impossible disposition %d in state %d, event_type %d, event_id %d\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
status, state, event_type, subtype.chunk);
|
|
|
|
BUG();
|
|
|
|
break;
|
2007-04-21 07:09:22 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
bail:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* 2nd Level Abstractions
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
/* This is the side-effect interpreter. */
|
2017-08-05 19:00:03 +07:00
|
|
|
static int sctp_cmd_interpreter(enum sctp_event event_type,
|
2017-08-05 19:00:04 +07:00
|
|
|
union sctp_subtype subtype,
|
2017-08-05 18:59:59 +07:00
|
|
|
enum sctp_state state,
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_endpoint *ep,
|
|
|
|
struct sctp_association *asoc,
|
|
|
|
void *event_arg,
|
2017-08-11 09:23:57 +07:00
|
|
|
enum sctp_disposition status,
|
2017-08-11 09:23:52 +07:00
|
|
|
struct sctp_cmd_seq *commands,
|
2005-10-07 13:46:04 +07:00
|
|
|
gfp_t gfp)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2017-08-11 09:23:57 +07:00
|
|
|
struct sctp_sock *sp = sctp_sk(ep->base.sk);
|
|
|
|
struct sctp_chunk *chunk = NULL, *new_obj;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct sctp_packet *packet;
|
2017-08-11 09:23:57 +07:00
|
|
|
struct sctp_sackhdr sackh;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct timer_list *timer;
|
|
|
|
struct sctp_transport *t;
|
2017-08-11 09:23:57 +07:00
|
|
|
unsigned long timeout;
|
|
|
|
struct sctp_cmd *cmd;
|
2005-04-17 05:20:36 +07:00
|
|
|
int local_cork = 0;
|
2017-08-11 09:23:57 +07:00
|
|
|
int error = 0;
|
|
|
|
int force;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (SCTP_EVENT_T_TIMEOUT != event_type)
|
2011-06-13 23:21:26 +07:00
|
|
|
chunk = event_arg;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Note: This whole file is a huge candidate for rework.
|
|
|
|
* For example, each command could either have its own handler, so
|
|
|
|
* the loop would look like:
|
|
|
|
* while (cmds)
|
|
|
|
* cmd->handle(x, y, z)
|
|
|
|
* --jgrimm
|
|
|
|
*/
|
|
|
|
while (NULL != (cmd = sctp_next_cmd(commands))) {
|
|
|
|
switch (cmd->verb) {
|
|
|
|
case SCTP_CMD_NOP:
|
|
|
|
/* Do nothing. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_NEW_ASOC:
|
|
|
|
/* Register a new association. */
|
|
|
|
if (local_cork) {
|
2016-03-11 04:33:07 +07:00
|
|
|
sctp_outq_uncork(&asoc->outqueue, gfp);
|
2005-04-17 05:20:36 +07:00
|
|
|
local_cork = 0;
|
|
|
|
}
|
2013-06-14 23:24:04 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Register with the endpoint. */
|
2013-06-14 23:24:04 +07:00
|
|
|
asoc = cmd->obj.asoc;
|
|
|
|
BUG_ON(asoc->peer.primary_path == NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_endpoint_add_asoc(ep, asoc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_UPDATE_ASSOC:
|
2017-06-20 15:05:11 +07:00
|
|
|
sctp_cmd_assoc_update(commands, asoc, cmd->obj.asoc);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_PURGE_OUTQUEUE:
|
|
|
|
sctp_outq_teardown(&asoc->outqueue);
|
|
|
|
break;
|
|
|
|
|
2007-02-09 21:25:18 +07:00
|
|
|
case SCTP_CMD_DELETE_TCB:
|
2005-04-17 05:20:36 +07:00
|
|
|
if (local_cork) {
|
2016-03-11 04:33:07 +07:00
|
|
|
sctp_outq_uncork(&asoc->outqueue, gfp);
|
2005-04-17 05:20:36 +07:00
|
|
|
local_cork = 0;
|
|
|
|
}
|
|
|
|
/* Delete the current association. */
|
|
|
|
sctp_cmd_delete_tcb(commands, asoc);
|
|
|
|
asoc = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_NEW_STATE:
|
|
|
|
/* Enter a new state. */
|
|
|
|
sctp_cmd_new_state(commands, asoc, cmd->obj.state);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_REPORT_TSN:
|
|
|
|
/* Record the arrival of a TSN. */
|
2008-10-09 04:18:39 +07:00
|
|
|
error = sctp_tsnmap_mark(&asoc->peer.tsn_map,
|
2012-06-30 10:04:26 +07:00
|
|
|
cmd->obj.u32, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_REPORT_FWDTSN:
|
2017-12-14 23:41:28 +07:00
|
|
|
asoc->stream.si->report_ftsn(&asoc->ulpq, cmd->obj.u32);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_PROCESS_FWDTSN:
|
2017-12-14 23:41:29 +07:00
|
|
|
asoc->stream.si->handle_ftsn(&asoc->ulpq,
|
|
|
|
cmd->obj.chunk);
|
2007-02-09 21:25:18 +07:00
|
|
|
break;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
case SCTP_CMD_GEN_SACK:
|
|
|
|
/* Generate a Selective ACK.
|
|
|
|
* The argument tells us whether to just count
|
|
|
|
* the packet and MAYBE generate a SACK, or
|
|
|
|
* force a SACK out.
|
|
|
|
*/
|
|
|
|
force = cmd->obj.i32;
|
|
|
|
error = sctp_gen_sack(asoc, force, commands);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_PROCESS_SACK:
|
|
|
|
/* Process an inbound SACK. */
|
|
|
|
error = sctp_cmd_process_sack(commands, asoc,
|
2012-10-29 15:32:13 +07:00
|
|
|
cmd->obj.chunk);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_GEN_INIT_ACK:
|
|
|
|
/* Generate an INIT ACK chunk. */
|
|
|
|
new_obj = sctp_make_init_ack(asoc, chunk, GFP_ATOMIC,
|
|
|
|
0);
|
|
|
|
if (!new_obj)
|
|
|
|
goto nomem;
|
|
|
|
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
|
|
|
|
SCTP_CHUNK(new_obj));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_PEER_INIT:
|
|
|
|
/* Process a unified INIT from the peer.
|
|
|
|
* Note: Only used during INIT-ACK processing. If
|
|
|
|
* there is an error just return to the outter
|
|
|
|
* layer which will bail.
|
|
|
|
*/
|
|
|
|
error = sctp_cmd_process_init(commands, asoc, chunk,
|
2012-10-29 15:32:13 +07:00
|
|
|
cmd->obj.init, gfp);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_GEN_COOKIE_ECHO:
|
|
|
|
/* Generate a COOKIE ECHO chunk. */
|
|
|
|
new_obj = sctp_make_cookie_echo(asoc, chunk);
|
|
|
|
if (!new_obj) {
|
2012-10-29 15:32:13 +07:00
|
|
|
if (cmd->obj.chunk)
|
|
|
|
sctp_chunk_free(cmd->obj.chunk);
|
2005-04-17 05:20:36 +07:00
|
|
|
goto nomem;
|
|
|
|
}
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
|
|
|
|
SCTP_CHUNK(new_obj));
|
|
|
|
|
|
|
|
/* If there is an ERROR chunk to be sent along with
|
|
|
|
* the COOKIE_ECHO, send it, too.
|
|
|
|
*/
|
2012-10-29 15:32:13 +07:00
|
|
|
if (cmd->obj.chunk)
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
|
2012-10-29 15:32:13 +07:00
|
|
|
SCTP_CHUNK(cmd->obj.chunk));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-09 01:00:26 +07:00
|
|
|
if (new_obj->transport) {
|
|
|
|
new_obj->transport->init_sent_count++;
|
|
|
|
asoc->init_last_sent_to = new_obj->transport;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* FIXME - Eventually come up with a cleaner way to
|
2007-02-09 21:25:18 +07:00
|
|
|
* enabling COOKIE-ECHO + DATA bundling during
|
|
|
|
* multihoming stale cookie scenarios, the following
|
|
|
|
* command plays with asoc->peer.retran_path to
|
|
|
|
* avoid the problem of sending the COOKIE-ECHO and
|
|
|
|
* DATA in different paths, which could result
|
|
|
|
* in the association being ABORTed if the DATA chunk
|
2005-04-17 05:20:36 +07:00
|
|
|
* is processed first by the server. Checking the
|
|
|
|
* init error counter simply causes this command
|
|
|
|
* to be executed only during failed attempts of
|
|
|
|
* association establishment.
|
|
|
|
*/
|
2005-06-21 03:14:57 +07:00
|
|
|
if ((asoc->peer.retran_path !=
|
|
|
|
asoc->peer.primary_path) &&
|
|
|
|
(asoc->init_err_counter > 0)) {
|
|
|
|
sctp_add_cmd_sf(commands,
|
2007-02-09 21:25:18 +07:00
|
|
|
SCTP_CMD_FORCE_PRIM_RETRAN,
|
2005-04-17 05:20:36 +07:00
|
|
|
SCTP_NULL());
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_GEN_SHUTDOWN:
|
|
|
|
/* Generate SHUTDOWN when in SHUTDOWN_SENT state.
|
|
|
|
* Reset error counts.
|
|
|
|
*/
|
|
|
|
asoc->overall_error_count = 0;
|
|
|
|
|
|
|
|
/* Generate a SHUTDOWN chunk. */
|
|
|
|
new_obj = sctp_make_shutdown(asoc, chunk);
|
|
|
|
if (!new_obj)
|
|
|
|
goto nomem;
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
|
|
|
|
SCTP_CHUNK(new_obj));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_CHUNK_ULP:
|
|
|
|
/* Send a chunk to the sockets layer. */
|
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 00:49:40 +07:00
|
|
|
pr_debug("%s: sm_sideff: chunk_up:%p, ulpq:%p\n",
|
|
|
|
__func__, cmd->obj.chunk, &asoc->ulpq);
|
|
|
|
|
2017-12-08 20:04:04 +07:00
|
|
|
asoc->stream.si->ulpevent_data(&asoc->ulpq,
|
|
|
|
cmd->obj.chunk,
|
|
|
|
GFP_ATOMIC);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_EVENT_ULP:
|
|
|
|
/* Send a notification to the sockets layer. */
|
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 00:49:40 +07:00
|
|
|
pr_debug("%s: sm_sideff: event_up:%p, ulpq:%p\n",
|
|
|
|
__func__, cmd->obj.ulpevent, &asoc->ulpq);
|
|
|
|
|
2017-12-08 20:04:05 +07:00
|
|
|
asoc->stream.si->enqueue_event(&asoc->ulpq,
|
|
|
|
cmd->obj.ulpevent);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_REPLY:
|
|
|
|
/* If an caller has not already corked, do cork. */
|
|
|
|
if (!asoc->outqueue.cork) {
|
|
|
|
sctp_outq_cork(&asoc->outqueue);
|
|
|
|
local_cork = 1;
|
|
|
|
}
|
|
|
|
/* Send a chunk to our peer. */
|
2016-09-14 01:04:22 +07:00
|
|
|
sctp_outq_tail(&asoc->outqueue, cmd->obj.chunk, gfp);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_SEND_PKT:
|
|
|
|
/* Send a full packet to our peer. */
|
2012-10-29 15:32:13 +07:00
|
|
|
packet = cmd->obj.packet;
|
2016-03-11 04:33:07 +07:00
|
|
|
sctp_packet_transmit(packet, gfp);
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_ootb_pkt_free(packet);
|
|
|
|
break;
|
|
|
|
|
2007-10-25 02:59:16 +07:00
|
|
|
case SCTP_CMD_T1_RETRAN:
|
|
|
|
/* Mark a transport for retransmission. */
|
|
|
|
sctp_retransmit(&asoc->outqueue, cmd->obj.transport,
|
|
|
|
SCTP_RTXR_T1_RTX);
|
|
|
|
break;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
case SCTP_CMD_RETRAN:
|
|
|
|
/* Mark a transport for retransmission. */
|
|
|
|
sctp_retransmit(&asoc->outqueue, cmd->obj.transport,
|
|
|
|
SCTP_RTXR_T3_RTX);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_ECN_CE:
|
|
|
|
/* Do delayed CE processing. */
|
|
|
|
sctp_do_ecn_ce_work(asoc, cmd->obj.u32);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_ECN_ECNE:
|
|
|
|
/* Do delayed ECNE processing. */
|
|
|
|
new_obj = sctp_do_ecn_ecne_work(asoc, cmd->obj.u32,
|
|
|
|
chunk);
|
|
|
|
if (new_obj)
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
|
|
|
|
SCTP_CHUNK(new_obj));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_ECN_CWR:
|
|
|
|
/* Do delayed CWR processing. */
|
|
|
|
sctp_do_ecn_cwr_work(asoc, cmd->obj.u32);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_SETUP_T2:
|
2012-10-29 15:32:13 +07:00
|
|
|
sctp_cmd_setup_t2(commands, asoc, cmd->obj.chunk);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
2011-07-07 07:28:35 +07:00
|
|
|
case SCTP_CMD_TIMER_START_ONCE:
|
|
|
|
timer = &asoc->timers[cmd->obj.to];
|
|
|
|
|
|
|
|
if (timer_pending(timer))
|
|
|
|
break;
|
|
|
|
/* fall through */
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
case SCTP_CMD_TIMER_START:
|
|
|
|
timer = &asoc->timers[cmd->obj.to];
|
|
|
|
timeout = asoc->timeouts[cmd->obj.to];
|
2006-01-09 13:24:28 +07:00
|
|
|
BUG_ON(!timeout);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
timer->expires = jiffies + timeout;
|
|
|
|
sctp_association_hold(asoc);
|
|
|
|
add_timer(timer);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_TIMER_RESTART:
|
|
|
|
timer = &asoc->timers[cmd->obj.to];
|
|
|
|
timeout = asoc->timeouts[cmd->obj.to];
|
|
|
|
if (!mod_timer(timer, jiffies + timeout))
|
|
|
|
sctp_association_hold(asoc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_TIMER_STOP:
|
|
|
|
timer = &asoc->timers[cmd->obj.to];
|
2013-02-04 03:32:57 +07:00
|
|
|
if (del_timer(timer))
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_association_put(asoc);
|
|
|
|
break;
|
|
|
|
|
2005-06-21 03:14:57 +07:00
|
|
|
case SCTP_CMD_INIT_CHOOSE_TRANSPORT:
|
2012-10-29 15:32:13 +07:00
|
|
|
chunk = cmd->obj.chunk;
|
2009-05-12 20:52:51 +07:00
|
|
|
t = sctp_assoc_choose_alter_transport(asoc,
|
|
|
|
asoc->init_last_sent_to);
|
2005-06-21 03:14:57 +07:00
|
|
|
asoc->init_last_sent_to = t;
|
|
|
|
chunk->transport = t;
|
|
|
|
t->init_sent_count++;
|
2009-11-24 03:53:57 +07:00
|
|
|
/* Set the new transport as primary */
|
|
|
|
sctp_assoc_set_primary(asoc, t);
|
2005-06-21 03:14:57 +07:00
|
|
|
break;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
case SCTP_CMD_INIT_RESTART:
|
|
|
|
/* Do the needed accounting and updates
|
|
|
|
* associated with restarting an initialization
|
2005-06-21 03:14:57 +07:00
|
|
|
* timer. Only multiply the timeout by two if
|
|
|
|
* all transports have been tried at the current
|
|
|
|
* timeout.
|
|
|
|
*/
|
2008-09-09 01:00:26 +07:00
|
|
|
sctp_cmd_t1_timer_update(asoc,
|
|
|
|
SCTP_EVENT_TIMEOUT_T1_INIT,
|
|
|
|
"INIT");
|
2005-06-21 03:14:57 +07:00
|
|
|
|
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
|
|
|
|
SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_COOKIEECHO_RESTART:
|
|
|
|
/* Do the needed accounting and updates
|
|
|
|
* associated with restarting an initialization
|
|
|
|
* timer. Only multiply the timeout by two if
|
|
|
|
* all transports have been tried at the current
|
|
|
|
* timeout.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2008-09-09 01:00:26 +07:00
|
|
|
sctp_cmd_t1_timer_update(asoc,
|
|
|
|
SCTP_EVENT_TIMEOUT_T1_COOKIE,
|
|
|
|
"COOKIE");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* If we've sent any data bundled with
|
|
|
|
* COOKIE-ECHO we need to resend.
|
|
|
|
*/
|
2008-04-13 08:54:24 +07:00
|
|
|
list_for_each_entry(t, &asoc->peer.transport_addr_list,
|
|
|
|
transports) {
|
2007-10-25 02:59:16 +07:00
|
|
|
sctp_retransmit_mark(&asoc->outqueue, t,
|
|
|
|
SCTP_RTXR_T1_RTX);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
sctp_add_cmd_sf(commands,
|
|
|
|
SCTP_CMD_TIMER_RESTART,
|
2005-06-21 03:14:57 +07:00
|
|
|
SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE));
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_INIT_FAILED:
|
2017-10-28 18:43:57 +07:00
|
|
|
sctp_cmd_init_failed(commands, asoc, cmd->obj.u32);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_ASSOC_FAILED:
|
|
|
|
sctp_cmd_assoc_failed(commands, asoc, event_type,
|
2017-10-28 18:43:57 +07:00
|
|
|
subtype, chunk, cmd->obj.u32);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
2005-06-21 03:14:57 +07:00
|
|
|
case SCTP_CMD_INIT_COUNTER_INC:
|
|
|
|
asoc->init_err_counter++;
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
2005-06-21 03:14:57 +07:00
|
|
|
case SCTP_CMD_INIT_COUNTER_RESET:
|
|
|
|
asoc->init_err_counter = 0;
|
|
|
|
asoc->init_cycle = 0;
|
2008-09-09 01:00:26 +07:00
|
|
|
list_for_each_entry(t, &asoc->peer.transport_addr_list,
|
|
|
|
transports) {
|
|
|
|
t->init_sent_count = 0;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_REPORT_DUP:
|
|
|
|
sctp_tsnmap_mark_dup(&asoc->peer.tsn_map,
|
|
|
|
cmd->obj.u32);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_REPORT_BAD_TAG:
|
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 00:49:40 +07:00
|
|
|
pr_debug("%s: vtag mismatch!\n", __func__);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_STRIKE:
|
|
|
|
/* Mark one strike against a transport. */
|
2012-07-21 14:56:07 +07:00
|
|
|
sctp_do_8_2_transport_strike(commands, asoc,
|
|
|
|
cmd->obj.transport, 0);
|
2009-03-02 16:46:14 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_TRANSPORT_IDLE:
|
|
|
|
t = cmd->obj.transport;
|
|
|
|
sctp_transport_lower_cwnd(t, SCTP_LOWER_CWND_INACTIVE);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
2009-03-02 16:46:14 +07:00
|
|
|
case SCTP_CMD_TRANSPORT_HB_SENT:
|
2005-04-17 05:20:36 +07:00
|
|
|
t = cmd->obj.transport;
|
2012-07-21 14:56:07 +07:00
|
|
|
sctp_do_8_2_transport_strike(commands, asoc,
|
|
|
|
t, 1);
|
2009-03-02 16:46:14 +07:00
|
|
|
t->hb_sent = 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_TRANSPORT_ON:
|
|
|
|
t = cmd->obj.transport;
|
|
|
|
sctp_cmd_transport_on(commands, asoc, t, chunk);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_HB_TIMERS_START:
|
|
|
|
sctp_cmd_hb_timers_start(commands, asoc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_HB_TIMER_UPDATE:
|
|
|
|
t = cmd->obj.transport;
|
sctp: avoid refreshing heartbeat timer too often
Currently on high rate SCTP streams the heartbeat timer refresh can
consume quite a lot of resources as timer updates are costly and it
contains a random factor, which a) is also costly and b) invalidates
mod_timer() optimization for not editing a timer to the same value.
It may even cause the timer to be slightly advanced, for no good reason.
As suggested by David Laight this patch now removes this timer update
from hot path by leaving the timer on and re-evaluating upon its
expiration if the heartbeat is still needed or not, similarly to what is
done for TCP. If it's not needed anymore the timer is re-scheduled to
the new timeout, considering the time already elapsed.
For this, we now record the last tx timestamp per transport, updated in
the same spots as hb timer was restarted on tx. Also split up
sctp_transport_reset_timers into sctp_transport_reset_t3_rtx and
sctp_transport_reset_hb_timer, so we can re-arm T3 without re-arming the
heartbeat one.
On loopback with MTU of 65535 and data chunks with 1636, so that we
have a considerable amount of chunks without stressing system calls,
netperf -t SCTP_STREAM -l 30, perf looked like this before:
Samples: 103K of event 'cpu-clock', Event count (approx.): 25833000000
Overhead Command Shared Object Symbol
+ 6,15% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,43% netperf [kernel.vmlinux] [k] _raw_write_unlock_irqrestore
- _raw_write_unlock_irqrestore
- 96,54% _raw_spin_unlock_irqrestore
- 36,14% mod_timer
+ 97,24% sctp_transport_reset_timers
+ 2,76% sctp_do_sm
+ 33,65% __wake_up_sync_key
+ 28,77% sctp_ulpq_tail_event
+ 1,40% del_timer
- 1,84% mod_timer
+ 99,03% sctp_transport_reset_timers
+ 0,97% sctp_do_sm
+ 1,50% sctp_ulpq_tail_event
And after this patch, now with netperf -l 60:
Samples: 230K of event 'cpu-clock', Event count (approx.): 57707250000
Overhead Command Shared Object Symbol
+ 5,65% netperf [kernel.vmlinux] [k] memcpy_erms
+ 5,59% netperf [kernel.vmlinux] [k] copy_user_enhanced_fast_string
- 5,05% netperf [kernel.vmlinux] [k] _raw_spin_unlock_irqrestore
- _raw_spin_unlock_irqrestore
+ 49,89% __wake_up_sync_key
+ 45,68% sctp_ulpq_tail_event
- 2,85% mod_timer
+ 76,51% sctp_transport_reset_t3_rtx
+ 23,49% sctp_do_sm
+ 1,55% del_timer
+ 2,50% netperf [sctp] [k] sctp_datamsg_from_user
+ 2,26% netperf [sctp] [k] sctp_sendmsg
Throughput-wise, from 6800mbps without the patch to 7050mbps with it,
~3.7%.
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-07 01:15:19 +07:00
|
|
|
sctp_transport_reset_hb_timer(t);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_HB_TIMERS_STOP:
|
|
|
|
sctp_cmd_hb_timers_stop(commands, asoc);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_REPORT_ERROR:
|
|
|
|
error = cmd->obj.error;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_PROCESS_CTSN:
|
|
|
|
/* Dummy up a SACK for processing. */
|
2006-11-21 08:26:53 +07:00
|
|
|
sackh.cum_tsn_ack = cmd->obj.be32;
|
2017-10-28 18:43:56 +07:00
|
|
|
sackh.a_rwnd = htonl(asoc->peer.rwnd +
|
|
|
|
asoc->outqueue.outstanding_bytes);
|
2005-04-17 05:20:36 +07:00
|
|
|
sackh.num_gap_ack_blocks = 0;
|
|
|
|
sackh.num_dup_tsns = 0;
|
2012-10-15 10:56:39 +07:00
|
|
|
chunk->subh.sack_hdr = &sackh;
|
2005-04-17 05:20:36 +07:00
|
|
|
sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK,
|
2012-10-15 10:56:39 +07:00
|
|
|
SCTP_CHUNK(chunk));
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_DISCARD_PACKET:
|
2008-06-20 06:08:18 +07:00
|
|
|
/* We need to discard the whole packet.
|
|
|
|
* Uncork the queue since there might be
|
|
|
|
* responses pending
|
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
chunk->pdiscard = 1;
|
2008-06-20 06:08:18 +07:00
|
|
|
if (asoc) {
|
2016-03-11 04:33:07 +07:00
|
|
|
sctp_outq_uncork(&asoc->outqueue, gfp);
|
2008-06-20 06:08:18 +07:00
|
|
|
local_cork = 0;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_RTO_PENDING:
|
|
|
|
t = cmd->obj.transport;
|
|
|
|
t->rto_pending = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_PART_DELIVER:
|
2017-12-08 20:04:07 +07:00
|
|
|
asoc->stream.si->start_pd(&asoc->ulpq, GFP_ATOMIC);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_RENEGE:
|
2017-12-08 20:04:06 +07:00
|
|
|
asoc->stream.si->renege_events(&asoc->ulpq,
|
|
|
|
cmd->obj.chunk,
|
|
|
|
GFP_ATOMIC);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_SETUP_T4:
|
2012-10-29 15:32:13 +07:00
|
|
|
sctp_cmd_setup_t4(commands, asoc, cmd->obj.chunk);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SCTP_CMD_PROCESS_OPERR:
|
|
|
|
sctp_cmd_process_operr(commands, asoc, chunk);
|
|
|
|
break;
|
|
|
|
case SCTP_CMD_CLEAR_INIT_TAG:
|
|
|
|
asoc->peer.i.init_tag = 0;
|
|
|
|
break;
|
|
|
|
case SCTP_CMD_DEL_NON_PRIMARY:
|
|
|
|
sctp_cmd_del_non_primary(asoc);
|
|
|
|
break;
|
|
|
|
case SCTP_CMD_T3_RTX_TIMERS_STOP:
|
|
|
|
sctp_cmd_t3_rtx_timers_stop(commands, asoc);
|
|
|
|
break;
|
|
|
|
case SCTP_CMD_FORCE_PRIM_RETRAN:
|
|
|
|
t = asoc->peer.retran_path;
|
|
|
|
asoc->peer.retran_path = asoc->peer.primary_path;
|
2016-09-14 01:04:22 +07:00
|
|
|
sctp_outq_uncork(&asoc->outqueue, gfp);
|
2005-04-17 05:20:36 +07:00
|
|
|
local_cork = 0;
|
|
|
|
asoc->peer.retran_path = t;
|
|
|
|
break;
|
2006-05-20 00:58:12 +07:00
|
|
|
case SCTP_CMD_SET_SK_ERR:
|
|
|
|
sctp_cmd_set_sk_err(asoc, cmd->obj.error);
|
|
|
|
break;
|
2007-05-05 03:55:27 +07:00
|
|
|
case SCTP_CMD_ASSOC_CHANGE:
|
|
|
|
sctp_cmd_assoc_change(commands, asoc,
|
|
|
|
cmd->obj.u8);
|
|
|
|
break;
|
|
|
|
case SCTP_CMD_ADAPTATION_IND:
|
|
|
|
sctp_cmd_adaptation_ind(commands, asoc);
|
|
|
|
break;
|
2018-03-14 18:05:34 +07:00
|
|
|
case SCTP_CMD_PEER_NO_AUTH:
|
|
|
|
sctp_cmd_peer_no_auth(commands, asoc);
|
|
|
|
break;
|
2007-05-05 03:55:27 +07:00
|
|
|
|
2007-09-17 09:32:11 +07:00
|
|
|
case SCTP_CMD_ASSOC_SHKEY:
|
|
|
|
error = sctp_auth_asoc_init_active_key(asoc,
|
|
|
|
GFP_ATOMIC);
|
|
|
|
break;
|
2008-04-13 08:39:34 +07:00
|
|
|
case SCTP_CMD_UPDATE_INITTAG:
|
|
|
|
asoc->peer.i.init_tag = cmd->obj.u32;
|
|
|
|
break;
|
2009-08-11 00:51:03 +07:00
|
|
|
case SCTP_CMD_SEND_MSG:
|
|
|
|
if (!asoc->outqueue.cork) {
|
|
|
|
sctp_outq_cork(&asoc->outqueue);
|
|
|
|
local_cork = 1;
|
|
|
|
}
|
2016-09-14 01:04:19 +07:00
|
|
|
sctp_cmd_send_msg(asoc, cmd->obj.msg, gfp);
|
2009-08-11 00:51:03 +07:00
|
|
|
break;
|
2010-04-28 15:47:22 +07:00
|
|
|
case SCTP_CMD_SEND_NEXT_ASCONF:
|
|
|
|
sctp_cmd_send_asconf(asoc);
|
|
|
|
break;
|
2011-05-30 06:23:36 +07:00
|
|
|
case SCTP_CMD_PURGE_ASCONF_QUEUE:
|
|
|
|
sctp_asconf_queue_teardown(asoc);
|
|
|
|
break;
|
2011-08-30 04:02:24 +07:00
|
|
|
|
|
|
|
case SCTP_CMD_SET_ASOC:
|
2017-06-20 15:01:55 +07:00
|
|
|
if (asoc && local_cork) {
|
|
|
|
sctp_outq_uncork(&asoc->outqueue, gfp);
|
|
|
|
local_cork = 0;
|
|
|
|
}
|
2011-08-30 04:02:24 +07:00
|
|
|
asoc = cmd->obj.asoc;
|
|
|
|
break;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
default:
|
2012-10-29 15:32:13 +07:00
|
|
|
pr_warn("Impossible command: %u\n",
|
|
|
|
cmd->verb);
|
2005-04-17 05:20:36 +07:00
|
|
|
break;
|
2007-04-21 07:09:22 +07:00
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2008-06-20 06:08:18 +07:00
|
|
|
/* If this is in response to a received chunk, wait until
|
|
|
|
* we are done with the packet to open the queue so that we don't
|
|
|
|
* send multiple packets in response to a single request.
|
|
|
|
*/
|
|
|
|
if (asoc && SCTP_EVENT_T_CHUNK == event_type && chunk) {
|
|
|
|
if (chunk->end_of_packet || chunk->singleton)
|
2016-09-14 01:04:22 +07:00
|
|
|
sctp_outq_uncork(&asoc->outqueue, gfp);
|
2008-06-20 06:08:18 +07:00
|
|
|
} else if (local_cork)
|
2016-09-14 01:04:22 +07:00
|
|
|
sctp_outq_uncork(&asoc->outqueue, gfp);
|
2016-04-09 02:41:28 +07:00
|
|
|
|
2016-04-30 00:17:08 +07:00
|
|
|
if (sp->data_ready_signalled)
|
|
|
|
sp->data_ready_signalled = 0;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
return error;
|
|
|
|
nomem:
|
|
|
|
error = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|