Release 4.11 net/sctp/sm_sideeffect.c
/* SCTP kernel implementation
* (C) Copyright IBM Corp. 2001, 2004
* Copyright (c) 1999 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
*
* This file is part of the SCTP kernel implementation
*
* 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.
*
* This SCTP implementation is free software;
* you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This SCTP implementation is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
* ************************
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU CC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
* Please send any bug reports or fixes you make to the
* email address(es):
* lksctp developers <linux-sctp@vger.kernel.org>
*
* Written or modified by:
* La Monte H.P. Yarroll <piggy@acm.org>
* Karl Knutson <karl@athena.chicago.il.us>
* 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>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/skbuff.h>
#include <linux/types.h>
#include <linux/socket.h>
#include <linux/ip.h>
#include <linux/gfp.h>
#include <net/sock.h>
#include <net/sctp/sctp.h>
#include <net/sctp/sm.h>
static int sctp_cmd_interpreter(sctp_event_t event_type,
sctp_subtype_t subtype,
sctp_state_t state,
struct sctp_endpoint *ep,
struct sctp_association *asoc,
void *event_arg,
sctp_disposition_t status,
sctp_cmd_seq_t *commands,
gfp_t gfp);
static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
sctp_state_t state,
struct sctp_endpoint *ep,
struct sctp_association **asoc,
void *event_arg,
sctp_disposition_t status,
sctp_cmd_seq_t *commands,
gfp_t gfp);
/********************************************************************
* Helper functions
********************************************************************/
/* A helper function for delayed processing of INET ECN CE bit. */
static void sctp_do_ecn_ce_work(struct sctp_association *asoc,
__u32 lowest_tsn)
{
/* Save the TSN away for comparison when we receive CWR */
asoc->last_ecne_tsn = lowest_tsn;
asoc->need_ecne = 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 26 | 96.30% | 3 | 75.00% |
David S. Miller | 1 | 3.70% | 1 | 25.00% |
Total | 27 | 100.00% | 4 | 100.00% |
/* 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,
__u32 lowest_tsn,
struct sctp_chunk *chunk)
{
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;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 91 | 98.91% | 5 | 83.33% |
David S. Miller | 1 | 1.09% | 1 | 16.67% |
Total | 92 | 100.00% | 6 | 100.00% |
/* 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;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 20 | 95.24% | 3 | 75.00% |
Sridhar Samudrala | 1 | 4.76% | 1 | 25.00% |
Total | 21 | 100.00% | 4 | 100.00% |
/* Generate SACK if necessary. We call this at the end of a packet. */
static int sctp_gen_sack(struct sctp_association *asoc, int force,
sctp_cmd_seq_t *commands)
{
__u32 ctsn, max_tsn_seen;
struct sctp_chunk *sack;
struct sctp_transport *trans = asoc->peer.last_data_from;
int error = 0;
if (force ||
(!trans && (asoc->param_flags & SPP_SACKDELAY_DISABLE)) ||
(trans && (trans->param_flags & SPP_SACKDELAY_DISABLE)))
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]
*/
if (max_tsn_seen != ctsn)
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) {
asoc->peer.sack_cnt++;
/* Set the SACK delay timeout based on the
* SACK delay for the last transport
* data was received from, or the default
* for the association.
*/
if (trans) {
/* We will need a SACK for the next packet. */
if (asoc->peer.sack_cnt >= trans->sackfreq - 1)
asoc->peer.sack_needed = 1;
asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
trans->sackdelay;
} else {
/* We will need a SACK for the next packet. */
if (asoc->peer.sack_cnt >= asoc->sackfreq - 1)
asoc->peer.sack_needed = 1;
asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
asoc->sackdelay;
}
/* Restart the SACK timer. */
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
SCTP_TO(SCTP_EVENT_TIMEOUT_SACK));
} else {
__u32 old_a_rwnd = asoc->a_rwnd;
asoc->a_rwnd = asoc->rwnd;
sack = sctp_make_sack(asoc);
if (!sack) {
asoc->a_rwnd = old_a_rwnd;
goto nomem;
}
asoc->peer.sack_needed = 0;
asoc->peer.sack_cnt = 0;
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(sack));
/* Stop the SACK timer. */
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
SCTP_TO(SCTP_EVENT_TIMEOUT_SACK));
}
return error;
nomem:
error = -ENOMEM;
return error;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 164 | 50.46% | 4 | 40.00% |
Frank Filz | 77 | 23.69% | 1 | 10.00% |
Wei Yongjun | 60 | 18.46% | 1 | 10.00% |
Marcelo Ricardo Leitner | 15 | 4.62% | 1 | 10.00% |
Vladislav Yasevich | 7 | 2.15% | 1 | 10.00% |
Sridhar Samudrala | 2 | 0.62% | 2 | 20.00% |
Total | 325 | 100.00% | 10 | 100.00% |
/* When the T3-RTX timer expires, it calls this function to create the
* relevant state machine event.
*/
void sctp_generate_t3_rtx_event(unsigned long peer)
{
int error;
struct sctp_transport *transport = (struct sctp_transport *) peer;
struct sctp_association *asoc = transport->asoc;
struct sock *sk = asoc->base.sk;
struct net *net = sock_net(sk);
/* Check whether a task is in the sock. */
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->T3_rtx_timer, jiffies + (HZ/20)))
sctp_transport_hold(transport);
goto out_unlock;
}
/* Run through the state machine. */
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX),
asoc->state,
asoc->ep, asoc,
transport, GFP_ATOMIC);
if (error)
sk->sk_err = -error;
out_unlock:
bh_unlock_sock(sk);
sctp_transport_put(transport);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 122 | 78.21% | 3 | 27.27% |
Eric W. Biedermann | 12 | 7.69% | 1 | 9.09% |
Karl Heiss | 11 | 7.05% | 1 | 9.09% |
David S. Miller | 3 | 1.92% | 1 | 9.09% |
Sridhar Samudrala | 2 | 1.28% | 1 | 9.09% |
Daniel Borkmann | 2 | 1.28% | 1 | 9.09% |
Wang Weidong | 2 | 1.28% | 1 | 9.09% |
Arnaldo Carvalho de Melo | 1 | 0.64% | 1 | 9.09% |
Harvey Harrison | 1 | 0.64% | 1 | 9.09% |
Total | 156 | 100.00% | 11 | 100.00% |
/* 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,
sctp_event_timeout_t timeout_type)
{
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: timer %d\n", __func__,
timeout_type);
/* 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. */
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
SCTP_ST_TIMEOUT(timeout_type),
asoc->state, asoc->ep, asoc,
(void *)timeout_type, GFP_ATOMIC);
if (error)
sk->sk_err = -error;
out_unlock:
bh_unlock_sock(sk);
sctp_association_put(asoc);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 133 | 82.10% | 3 | 33.33% |
Eric W. Biedermann | 12 | 7.41% | 1 | 11.11% |
Karl Heiss | 11 | 6.79% | 1 | 11.11% |
Daniel Borkmann | 2 | 1.23% | 1 | 11.11% |
Wang Weidong | 2 | 1.23% | 1 | 11.11% |
Arnaldo Carvalho de Melo | 1 | 0.62% | 1 | 11.11% |
Harvey Harrison | 1 | 0.62% | 1 | 11.11% |
Total | 162 | 100.00% | 9 | 100.00% |
static void sctp_generate_t1_cookie_event(unsigned long data)
{
struct sctp_association *asoc = (struct sctp_association *) data;
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_T1_COOKIE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 28 | 96.55% | 3 | 75.00% |
Sridhar Samudrala | 1 | 3.45% | 1 | 25.00% |
Total | 29 | 100.00% | 4 | 100.00% |
static void sctp_generate_t1_init_event(unsigned long data)
{
struct sctp_association *asoc = (struct sctp_association *) data;
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_T1_INIT);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 28 | 96.55% | 3 | 75.00% |
Sridhar Samudrala | 1 | 3.45% | 1 | 25.00% |
Total | 29 | 100.00% | 4 | 100.00% |
static void sctp_generate_t2_shutdown_event(unsigned long data)
{
struct sctp_association *asoc = (struct sctp_association *) data;
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_T2_SHUTDOWN);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 25 | 86.21% | 3 | 60.00% |
Sridhar Samudrala | 4 | 13.79% | 2 | 40.00% |
Total | 29 | 100.00% | 5 | 100.00% |
static void sctp_generate_t4_rto_event(unsigned long data)
{
struct sctp_association *asoc = (struct sctp_association *) data;
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_T4_RTO);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sridhar Samudrala | 29 | 100.00% | 2 | 100.00% |
Total | 29 | 100.00% | 2 | 100.00% |
static void sctp_generate_t5_shutdown_guard_event(unsigned long data)
{
struct sctp_association *asoc = (struct sctp_association *)data;
sctp_generate_timeout_event(asoc,
SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD);
} Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 28 | 96.55% | 3 | 75.00% |
Sridhar Samudrala | 1 | 3.45% | 1 | 25.00% |
Total | 29 | 100.00% | 4 | 100.00% |
/* sctp_generate_t5_shutdown_guard_event() */
static void sctp_generate_autoclose_event(unsigned long data)
{
struct sctp_association *asoc = (struct sctp_association *) data;
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_AUTOCLOSE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 28 | 96.55% | 3 | 75.00% |
Sridhar Samudrala | 1 | 3.45% | 1 | 25.00% |
Total | 29 | 100.00% | 4 | 100.00% |
/* Generate a heart beat event. If the sock is busy, reschedule. Make
* sure that the transport is still valid.
*/
void sctp_generate_heartbeat_event(unsigned long data)
{
int error = 0;
struct sctp_transport *transport = (struct sctp_transport *) data;
struct sctp_association *asoc = transport->asoc;
struct sock *sk = asoc->base.sk;
struct net *net = sock_net(sk);
u32 elapsed, timeout;
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->hb_timer, jiffies + (HZ/20)))
sctp_transport_hold(transport);
goto out_unlock;
}
/* 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;
}
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_HEARTBEAT),
asoc->state, asoc->ep, asoc,
transport, GFP_ATOMIC);
if (error)
sk->sk_err = -error;
out_unlock:
bh_unlock_sock(sk);
sctp_transport_put(transport);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 123 | 57.48% | 4 | 33.33% |
Marcelo Ricardo Leitner | 58 | 27.10% | 1 | 8.33% |
Eric W. Biedermann | 12 | 5.61% | 1 | 8.33% |
Karl Heiss | 11 | 5.14% | 1 | 8.33% |
Daisy Chang | 4 | 1.87% | 1 | 8.33% |
Wang Weidong | 2 | 0.93% | 1 | 8.33% |
Daniel Borkmann | 2 | 0.93% | 1 | 8.33% |
Harvey Harrison | 1 | 0.47% | 1 | 8.33% |
Arnaldo Carvalho de Melo | 1 | 0.47% | 1 | 8.33% |
Total | 214 | 100.00% | 12 | 100.00% |
/* Handle the timeout of the ICMP protocol unreachable timer. Trigger
* the correct state machine transition that will close the association.
*/
void sctp_generate_proto_unreach_event(unsigned long data)
{
struct sctp_transport *transport = (struct sctp_transport *) data;
struct sctp_association *asoc = transport->asoc;
struct sock *sk = asoc->base.sk;
struct net *net = sock_net(sk);
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->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;
sctp_do_sm(net, SCTP_EVENT_T_OTHER,
SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),
asoc->state, asoc->ep, asoc, transport, GFP_ATOMIC);
out_unlock:
bh_unlock_sock(sk);
sctp_association_put(asoc);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vladislav Yasevich | 123 | 82.00% | 1 | 20.00% |
Eric W. Biedermann | 12 | 8.00% | 1 | 20.00% |
Karl Heiss | 11 | 7.33% | 1 | 20.00% |
Wang Weidong | 2 | 1.33% | 1 | 20.00% |
Daniel Borkmann | 2 | 1.33% | 1 | 20.00% |
Total | 150 | 100.00% | 5 | 100.00% |
/* Handle the timeout of the RE-CONFIG timer. */
void sctp_generate_reconf_event(unsigned long data)
{
struct sctp_transport *transport = (struct sctp_transport *)data;
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);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Xin Long | 156 | 100.00% | 1 | 100.00% |
Total | 156 | 100.00% | 1 | 100.00% |
/* Inject a SACK Timeout event into the state machine. */
static void sctp_generate_sack_event(unsigned long data)
{
struct sctp_association *asoc = (struct sctp_association *) data;
sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 24 | 82.76% | 2 | 50.00% |
Daisy Chang | 4 | 13.79% | 1 | 25.00% |
Sridhar Samudrala | 1 | 3.45% | 1 | 25.00% |
Total | 29 | 100.00% | 4 | 100.00% |
sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
NULL,
sctp_generate_t1_cookie_event,
sctp_generate_t1_init_event,
sctp_generate_t2_shutdown_event,
NULL,
sctp_generate_t4_rto_event,
sctp_generate_t5_shutdown_guard_event,
NULL,
NULL,
sctp_generate_sack_event,
sctp_generate_autoclose_event,
};
/* 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.
*
*/
static void sctp_do_8_2_transport_strike(sctp_cmd_seq_t *commands,
struct sctp_association *asoc,
struct sctp_transport *transport,
int is_hb)
{
struct net *net = sock_net(asoc->base.sk);
/* The check for association's overall error counter exceeding the
* threshold is done in the state function.
*/
/* 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.
* Additionally, some tranport states inhibit error increments.
*/
if (!is_hb) {
asoc->overall_error_count++;
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++;
}
/* If the transport error count is greater than the pf_retrans
* threshold, and less than pathmaxrtx, and if the current state
* is SCTP_ACTIVE, then mark this transport as Partially Failed,
* see SCTP Quick Failover Draft, section 5.1
*/
if (net->sctp.pf_enable &&
(transport->state == SCTP_ACTIVE) &&
(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_transport_reset_hb_timer(transport);
}
if (transport->state != SCTP_INACTIVE &&
(transport->error_count > transport->pathmaxrxt)) {
pr_debug("%s: association:%p transport addr:%pISpc failed\n",
__func__, asoc, &transport->ipaddr.sa);
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.
*
* Special Case: the first HB doesn't trigger exponential backoff.
* The first unacknowledged HB triggers it. We do this with a flag
* that indicates that we have an outstanding HB.
*/
if (!is_hb || transport->hb_sent) {
transport->rto = min((transport->rto * 2), transport->asoc->rto_max);
sctp_max_rto(asoc, transport);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 72 | 29.75% | 3 | 15.79% |
Vladislav Yasevich | 62 | 25.62% | 3 | 15.79% |
Neil Horman | 47 | 19.42% | 1 | 5.26% |
Zhu Yanjun | 20 | 8.26% | 1 | 5.26% |
Frank Filz | 11 | 4.55% | 2 | 10.53% |
Sridhar Samudrala | 8 | 3.31% | 1 | 5.26% |
Michele Baldessari | 7 | 2.89% | 1 | 5.26% |
Daniel Borkmann | 4 | 1.65% | 1 | 5.26% |
Karl Heiss | 3 | 1.24% | 1 | 5.26% |
Matija Glavinic Pecotic | 3 | 1.24% | 1 | 5.26% |
Al Viro | 2 | 0.83% | 1 | 5.26% |
Lucas De Marchi | 1 | 0.41% | 1 | 5.26% |
Marcelo Ricardo Leitner | 1 | 0.41% | 1 | 5.26% |
Daniel Mack | 1 | 0.41% | 1 | 5.26% |
Total | 242 | 100.00% | 19 | 100.00% |
/* Worker routine to handle INIT command failure. */
static void sctp_cmd_init_failed(sctp_cmd_seq_t *commands,
struct sctp_association *asoc,
unsigned int error)
{
struct sctp_ulpevent *event;
event = sctp_ulpevent_make_assoc_change(asoc, 0, SCTP_CANT_STR_ASSOC,
(__u16)error, 0, 0, NULL,
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());
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 80 | 84.21% | 5 | 62.50% |
Sridhar Samudrala | 12 | 12.63% | 1 | 12.50% |
Vladislav Yasevich | 2 | 2.11% | 1 | 12.50% |
Eric Dumazet | 1 | 1.05% | 1 | 12.50% |
Total | 95 | 100.00% | 8 | 100.00% |
/* Worker routine to handle SCTP_CMD_ASSOC_FAILED. */
static void sctp_cmd_assoc_failed(sctp_cmd_seq_t *commands,
struct sctp_association *asoc,
sctp_event_t event_type,
sctp_subtype_t subtype,
struct sctp_chunk *chunk,
unsigned int error)
{
struct sctp_ulpevent *event;
struct sctp_chunk *abort;
/* Cancel any partial delivery in progress. */
sctp_ulpq_abort_pd(&asoc->ulpq, GFP_ATOMIC);
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,
GFP_ATOMIC);
if (event)
sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
SCTP_ULPEVENT(event));
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));
}
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());
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 113 | 57.65% | 4 | 50.00% |
Neil Horman | 42 | 21.43% | 1 | 12.50% |
Vladislav Yasevich | 39 | 19.90% | 1 | 12.50% |
Sridhar Samudrala | 1 | 0.51% | 1 | 12.50% |
Eric Dumazet | 1 | 0.51% | 1 | 12.50% |
Total | 196 | 100.00% | 8 | 100.00% |
/* 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.
*/
static int sctp_cmd_process_init(sctp_cmd_seq_t *commands,
struct sctp_association *asoc,
struct sctp_chunk *chunk,
sctp_init_chunk_t *peer_init,
gfp_t gfp)
{
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.
*/
if (!sctp_process_init(asoc, chunk, sctp_source(chunk), peer_init, gfp))
error = -ENOMEM;
else
error = 0;
return error;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 62 | 98.41% | 3 | 75.00% |
Al Viro | 1 | 1.59% | 1 | 25.00% |
Total | 63 | 100.00% | 4 | 100.00% |
/* Helper function to break out starting up of heartbeat timers. */
static void sctp_cmd_hb_timers_start(sctp_cmd_seq_t *cmds,
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.
*/
list_for_each_entry(t, &asoc->peer.transport_addr_list, transports)
sctp_transport_reset_hb_timer(t);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 27 | 79.41% | 3 | 50.00% |
Robert P. J. Day | 3 | 8.82% | 1 | 16.67% |
Sridhar Samudrala | 3 | 8.82% | 1 | 16.67% |
Marcelo Ricardo Leitner | 1 | 2.94% | 1 | 16.67% |
Total | 34 | 100.00% | 6 | 100.00% |
static void sctp_cmd_hb_timers_stop(sctp_cmd_seq_t *cmds,
struct sctp_association *asoc)
{
struct sctp_transport *t;
/* Stop all heartbeat timers. */
list_for_each_entry(t, &asoc->peer.transport_addr_list,
transports) {
if (del_timer(&t->hb_timer))
sctp_transport_put(t);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 42 | 91.30% | 4 | 80.00% |
Robert P. J. Day | 4 | 8.70% | 1 | 20.00% |
Total | 46 | 100.00% | 5 | 100.00% |
/* Helper function to stop any pending T3-RTX timers */
static void sctp_cmd_t3_rtx_timers_stop(sctp_cmd_seq_t *cmds,
struct sctp_association *asoc)
{
struct sctp_transport *t;
list_for_each_entry(t, &asoc->peer.transport_addr_list,
transports) {
if (del_timer(&t->T3_rtx_timer))
sctp_transport_put(t);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Sridhar Samudrala | 41 | 91.11% | 1 | 50.00% |
Robert P. J. Day | 4 | 8.89% | 1 | 50.00% |
Total | 45 | 100.00% | 2 | 100.00% |
/* Helper function to handle the reception of an HEARTBEAT ACK. */
static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds,
struct sctp_association *asoc,
struct sctp_transport *t,
struct sctp_chunk *chunk)
{
sctp_sender_hb_info_t *hbinfo;
int was_unconfirmed = 0;
/* 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;
/*
* 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.
*/
if (t->asoc->state < SCTP_STATE_SHUTDOWN_PENDING)
t->asoc->overall_error_count = 0;
/* Clear the hb_sent flag to signal that we had a good
* acknowledgement.
*/
t->hb_sent = 0;
/* Mark the destination transport address as active if it is not so
* marked.
*/
if ((t->state == SCTP_INACTIVE) || (t->state == SCTP_UNCONFIRMED)) {
was_unconfirmed = 1;
sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP,
SCTP_HEARTBEAT_SUCCESS);
}
if (t->state == SCTP_PF)
sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP,
SCTP_HEARTBEAT_SUCCESS);
/* HB-ACK was received for a the proper HB. Consider this
* forward progress.
*/
if (t->dst)
sctp_transport_dst_confirm(t);
/* 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.
* 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.
*/
if (t->rto_pending == 0)
t->rto_pending = 1;
hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data;
sctp_transport_update_rto(t, (jiffies - hbinfo->sent_at));
/* Update the heartbeat timer. */
sctp_transport_reset_hb_timer(t);
if (was_unconfirmed && asoc->peer.transport_count == 1)
sctp_transport_immediate_rtx(t);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 80 | 40.61% | 6 | 33.33% |
Michio Honda | 28 | 14.21% | 1 | 5.56% |
Vladislav Yasevich | 22 | 11.17% | 2 | 11.11% |
Sridhar Samudrala | 20 | 10.15% | 2 | 11.11% |
Neil Horman | 19 | 9.64% | 1 | 5.56% |
Daniel Borkmann | 11 | 5.58% | 1 | 5.56% |
Thomas Graf | 11 | 5.58% | 1 | 5.56% |
Frank Filz | 3 | 1.52% | 1 | 5.56% |
Julian Anastasov | 1 | 0.51% | 1 | 5.56% |
Marcelo Ricardo Leitner | 1 | 0.51% | 1 | 5.56% |
Xin Long | 1 | 0.51% | 1 | 5.56% |
Total | 197 | 100.00% | 18 | 100.00% |
/* Helper function to process the process SACK command. */
static int sctp_cmd_process_sack(sctp_cmd_seq_t *cmds,
struct sctp_association *asoc,
struct sctp_chunk *chunk)
{
int err = 0;
if (sctp_outq_sack(&asoc->outqueue, chunk)) {
struct net *net = sock_net(asoc->base.sk);
/* There are no more TSNs awaiting SACK. */
err = sctp_do_sm(net, SCTP_EVENT_T_OTHER,
SCTP_ST_OTHER(SCTP_EVENT_NO_PENDING_TSN),
asoc->state, asoc->ep, asoc, NULL,
GFP_ATOMIC);
}
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 63 | 74.12% | 4 | 50.00% |
Eric W. Biedermann | 16 | 18.82% | 1 | 12.50% |
Nicolas Dichtel | 3 | 3.53% | 1 | 12.50% |
Vladislav Yasevich | 2 | 2.35% | 1 | 12.50% |
Sridhar Samudrala | 1 | 1.18% | 1 | 12.50% |
Total | 85 | 100.00% | 8 | 100.00% |
/* Helper function to set the timeout value for T2-SHUTDOWN timer and to set
* the transport for a shutdown chunk.
*/
static void sctp_cmd_setup_t2(sctp_cmd_seq_t *cmds,
struct sctp_association *asoc,
struct sctp_chunk *chunk)
{
struct sctp_transport *t;
if (chunk->transport)
t = chunk->transport;
else {
t = sctp_assoc_choose_alter_transport(asoc,
asoc->shutdown_last_sent_to);
chunk->transport = t;
}
asoc->shutdown_last_sent_to = t;
asoc->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] = t->rto;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jon Grimm | 48 | 64.86% | 4 | 66.67% |
Vladislav Yasevich | 21 | 28.38% | 1 | 16.67% |
Wei Yongjun | 5 | 6.76% | 1 | 16.67% |
Total | 74 | 100.00% | 6 | 100.00% |
/* Helper function to change the state of an association. */
static void sctp_cmd_new_state(sctp_cmd_seq_t *cmds,
struct sctp_association *asoc,
sctp_state_t state)
{
struct sock *sk = asoc->base.sk;
asoc->state = state;
pr_debug("%s: asoc:%p[%s]\n", __func__, asoc, sctp_state_tbl[state]);
if (sctp_style(sk, TCP)) {
/* Change the sk->sk_state of a TCP-style socket that has
* successfully completed a connect() call.
*/
if (sctp_state(asoc, ESTABLISHED) && sctp_sstate(sk, CLOSED))
sk->sk_state = SCTP_SS_ESTABLISHED;
/* Set the RCV_SHUTDOWN flag when a SHUTDOWN is received. */
if (sctp_state(asoc, SHUTDOWN_RECEIVED) &&
sctp_sstate(sk, ESTABLISHED)) {
sk->sk_state = SCTP_SS_CLOSING;
sk->sk_shutdown |= RCV_SHUTDOWN;
}
}
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] =
asoc->rto_initial;
asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE] =
asoc->rto_initial;
}
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().
*/
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