Skip to content

Commit 5aa93bc

Browse files
nhormandavem330
authored andcommitted
sctp: Implement quick failover draft from tsvwg
I've seen several attempts recently made to do quick failover of sctp transports by reducing various retransmit timers and counters. While its possible to implement a faster failover on multihomed sctp associations, its not particularly robust, in that it can lead to unneeded retransmits, as well as false connection failures due to intermittent latency on a network. Instead, lets implement the new ietf quick failover draft found here: http://tools.ietf.org/html/draft-nishida-tsvwg-sctp-failover-05 This will let the sctp stack identify transports that have had a small number of errors, and avoid using them quickly until their reliability can be re-established. I've tested this out on two virt guests connected via multiple isolated virt networks and believe its in compliance with the above draft and works well. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Vlad Yasevich <vyasevich@gmail.com> CC: Sridhar Samudrala <sri@us.ibm.com> CC: "David S. Miller" <davem@davemloft.net> CC: linux-sctp@vger.kernel.org CC: joe@perches.com Acked-by: Vlad Yasevich <vyasevich@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e390648 commit 5aa93bc

10 files changed

Lines changed: 221 additions & 15 deletions

File tree

‎Documentation/networking/ip-sysctl.txt‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,20 @@ path_max_retrans - INTEGER
14401440

14411441
Default: 5
14421442

1443+
pf_retrans - INTEGER
1444+
The number of retransmissions that will be attempted on a given path
1445+
before traffic is redirected to an alternate transport (should one
1446+
exist). Note this is distinct from path_max_retrans, as a path that
1447+
passes the pf_retrans threshold can still be used. Its only
1448+
deprioritized when a transmission path is selected by the stack. This
1449+
setting is primarily used to enable fast failover mechanisms without
1450+
having to reduce path_max_retrans to a very low value. See:
1451+
http://www.ietf.org/id/draft-nishida-tsvwg-sctp-failover-05.txt
1452+
for details. Note also that a value of pf_retrans > path_max_retrans
1453+
disables this feature
1454+
1455+
Default: 0
1456+
14431457
rto_initial - INTEGER
14441458
The initial round trip timeout value in milliseconds that will be used
14451459
in calculating round trip times. This is the initial time interval

‎include/net/sctp/constants.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ typedef enum {
334334
typedef enum {
335335
SCTP_TRANSPORT_UP,
336336
SCTP_TRANSPORT_DOWN,
337+
SCTP_TRANSPORT_PF,
337338
} sctp_transport_cmd_t;
338339

339340
/* These are the address scopes defined mainly for IPv4 addresses

‎include/net/sctp/structs.h‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ extern struct sctp_globals {
161161
int max_retrans_path;
162162
int max_retrans_init;
163163

164+
/* Potentially-Failed.Max.Retrans sysctl value
165+
* taken from:
166+
* http://tools.ietf.org/html/draft-nishida-tsvwg-sctp-failover-05
167+
*/
168+
int pf_retrans;
169+
164170
/*
165171
* Policy for preforming sctp/socket accounting
166172
* 0 - do socket level accounting, all assocs share sk_sndbuf
@@ -258,6 +264,7 @@ extern struct sctp_globals {
258264
#define sctp_sndbuf_policy (sctp_globals.sndbuf_policy)
259265
#define sctp_rcvbuf_policy (sctp_globals.rcvbuf_policy)
260266
#define sctp_max_retrans_path (sctp_globals.max_retrans_path)
267+
#define sctp_pf_retrans (sctp_globals.pf_retrans)
261268
#define sctp_max_retrans_init (sctp_globals.max_retrans_init)
262269
#define sctp_sack_timeout (sctp_globals.sack_timeout)
263270
#define sctp_hb_interval (sctp_globals.hb_interval)
@@ -990,10 +997,15 @@ struct sctp_transport {
990997

991998
/* This is the max_retrans value for the transport and will
992999
* be initialized from the assocs value. This can be changed
993-
* using SCTP_SET_PEER_ADDR_PARAMS socket option.
1000+
* using the SCTP_SET_PEER_ADDR_PARAMS socket option.
9941001
*/
9951002
__u16 pathmaxrxt;
9961003

1004+
/* This is the partially failed retrans value for the transport
1005+
* and will be initialized from the assocs value. This can be changed
1006+
* using the SCTP_PEER_ADDR_THLDS socket option
1007+
*/
1008+
int pf_retrans;
9971009
/* PMTU : The current known path MTU. */
9981010
__u32 pathmtu;
9991011

@@ -1664,6 +1676,12 @@ struct sctp_association {
16641676
*/
16651677
int max_retrans;
16661678

1679+
/* This is the partially failed retrans value for the transport
1680+
* and will be initialized from the assocs value. This can be
1681+
* changed using the SCTP_PEER_ADDR_THLDS socket option
1682+
*/
1683+
int pf_retrans;
1684+
16671685
/* Maximum number of times the endpoint will retransmit INIT */
16681686
__u16 max_init_attempts;
16691687

‎include/net/sctp/user.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ typedef __s32 sctp_assoc_t;
9393
#define SCTP_GET_ASSOC_NUMBER 28 /* Read only */
9494
#define SCTP_GET_ASSOC_ID_LIST 29 /* Read only */
9595
#define SCTP_AUTO_ASCONF 30
96+
#define SCTP_PEER_ADDR_THLDS 31
9697

9798
/* Internal Socket Options. Some of the sctp library functions are
9899
* implemented using these socket options.
@@ -649,6 +650,7 @@ struct sctp_paddrinfo {
649650
*/
650651
enum sctp_spinfo_state {
651652
SCTP_INACTIVE,
653+
SCTP_PF,
652654
SCTP_ACTIVE,
653655
SCTP_UNCONFIRMED,
654656
SCTP_UNKNOWN = 0xffff /* Value used for transport state unknown */
@@ -741,4 +743,13 @@ typedef struct {
741743
int sd;
742744
} sctp_peeloff_arg_t;
743745

746+
/*
747+
* Peer Address Thresholds socket option
748+
*/
749+
struct sctp_paddrthlds {
750+
sctp_assoc_t spt_assoc_id;
751+
struct sockaddr_storage spt_address;
752+
__u16 spt_pathmaxrxt;
753+
__u16 spt_pathpfthld;
754+
};
744755
#endif /* __net_sctp_user_h__ */

‎net/sctp/associola.c‎

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
124124
* socket values.
125125
*/
126126
asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt;
127+
asoc->pf_retrans = sctp_pf_retrans;
128+
127129
asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial);
128130
asoc->rto_max = msecs_to_jiffies(sp->rtoinfo.srto_max);
129131
asoc->rto_min = msecs_to_jiffies(sp->rtoinfo.srto_min);
@@ -686,6 +688,9 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
686688
/* Set the path max_retrans. */
687689
peer->pathmaxrxt = asoc->pathmaxrxt;
688690

691+
/* And the partial failure retrnas threshold */
692+
peer->pf_retrans = asoc->pf_retrans;
693+
689694
/* Initialize the peer's SACK delay timeout based on the
690695
* association configured value.
691696
*/
@@ -841,6 +846,7 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
841846
struct sctp_ulpevent *event;
842847
struct sockaddr_storage addr;
843848
int spc_state = 0;
849+
bool ulp_notify = true;
844850

845851
/* Record the transition on the transport. */
846852
switch (command) {
@@ -854,6 +860,14 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
854860
spc_state = SCTP_ADDR_CONFIRMED;
855861
else
856862
spc_state = SCTP_ADDR_AVAILABLE;
863+
/* Don't inform ULP about transition from PF to
864+
* active state and set cwnd to 1, see SCTP
865+
* Quick failover draft section 5.1, point 5
866+
*/
867+
if (transport->state == SCTP_PF) {
868+
ulp_notify = false;
869+
transport->cwnd = 1;
870+
}
857871
transport->state = SCTP_ACTIVE;
858872
break;
859873

@@ -872,19 +886,27 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
872886
spc_state = SCTP_ADDR_UNREACHABLE;
873887
break;
874888

889+
case SCTP_TRANSPORT_PF:
890+
transport->state = SCTP_PF;
891+
ulp_notify = false;
892+
break;
893+
875894
default:
876895
return;
877896
}
878897

879898
/* Generate and send a SCTP_PEER_ADDR_CHANGE notification to the
880899
* user.
881900
*/
882-
memset(&addr, 0, sizeof(struct sockaddr_storage));
883-
memcpy(&addr, &transport->ipaddr, transport->af_specific->sockaddr_len);
884-
event = sctp_ulpevent_make_peer_addr_change(asoc, &addr,
885-
0, spc_state, error, GFP_ATOMIC);
886-
if (event)
887-
sctp_ulpq_tail_event(&asoc->ulpq, event);
901+
if (ulp_notify) {
902+
memset(&addr, 0, sizeof(struct sockaddr_storage));
903+
memcpy(&addr, &transport->ipaddr,
904+
transport->af_specific->sockaddr_len);
905+
event = sctp_ulpevent_make_peer_addr_change(asoc, &addr,
906+
0, spc_state, error, GFP_ATOMIC);
907+
if (event)
908+
sctp_ulpq_tail_event(&asoc->ulpq, event);
909+
}
888910

889911
/* Select new active and retran paths. */
890912

@@ -900,7 +922,8 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
900922
transports) {
901923

902924
if ((t->state == SCTP_INACTIVE) ||
903-
(t->state == SCTP_UNCONFIRMED))
925+
(t->state == SCTP_UNCONFIRMED) ||
926+
(t->state == SCTP_PF))
904927
continue;
905928
if (!first || t->last_time_heard > first->last_time_heard) {
906929
second = first;

‎net/sctp/outqueue.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,8 @@ static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
792792
if (!new_transport)
793793
new_transport = asoc->peer.active_path;
794794
} else if ((new_transport->state == SCTP_INACTIVE) ||
795-
(new_transport->state == SCTP_UNCONFIRMED)) {
795+
(new_transport->state == SCTP_UNCONFIRMED) ||
796+
(new_transport->state == SCTP_PF)) {
796797
/* If the chunk is Heartbeat or Heartbeat Ack,
797798
* send it to chunk->transport, even if it's
798799
* inactive.
@@ -987,7 +988,8 @@ static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
987988
new_transport = chunk->transport;
988989
if (!new_transport ||
989990
((new_transport->state == SCTP_INACTIVE) ||
990-
(new_transport->state == SCTP_UNCONFIRMED)))
991+
(new_transport->state == SCTP_UNCONFIRMED) ||
992+
(new_transport->state == SCTP_PF)))
991993
new_transport = asoc->peer.active_path;
992994
if (new_transport->state == SCTP_UNCONFIRMED)
993995
continue;

‎net/sctp/sm_sideeffect.c‎

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
7676
sctp_cmd_seq_t *commands,
7777
gfp_t gfp);
7878

79+
static void sctp_cmd_hb_timer_update(sctp_cmd_seq_t *cmds,
80+
struct sctp_transport *t);
7981
/********************************************************************
8082
* Helper functions
8183
********************************************************************/
@@ -470,7 +472,8 @@ sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
470472
* notification SHOULD be sent to the upper layer.
471473
*
472474
*/
473-
static void sctp_do_8_2_transport_strike(struct sctp_association *asoc,
475+
static void sctp_do_8_2_transport_strike(sctp_cmd_seq_t *commands,
476+
struct sctp_association *asoc,
474477
struct sctp_transport *transport,
475478
int is_hb)
476479
{
@@ -495,6 +498,23 @@ static void sctp_do_8_2_transport_strike(struct sctp_association *asoc,
495498
transport->error_count++;
496499
}
497500

501+
/* If the transport error count is greater than the pf_retrans
502+
* threshold, and less than pathmaxrtx, then mark this transport
503+
* as Partially Failed, ee SCTP Quick Failover Draft, secon 5.1,
504+
* point 1
505+
*/
506+
if ((transport->state != SCTP_PF) &&
507+
(asoc->pf_retrans < transport->pathmaxrxt) &&
508+
(transport->error_count > asoc->pf_retrans)) {
509+
510+
sctp_assoc_control_transport(asoc, transport,
511+
SCTP_TRANSPORT_PF,
512+
0);
513+
514+
/* Update the hb timer to resend a heartbeat every rto */
515+
sctp_cmd_hb_timer_update(commands, transport);
516+
}
517+
498518
if (transport->state != SCTP_INACTIVE &&
499519
(transport->error_count > transport->pathmaxrxt)) {
500520
SCTP_DEBUG_PRINTK_IPADDR("transport_strike:association %p",
@@ -699,6 +719,10 @@ static void sctp_cmd_transport_on(sctp_cmd_seq_t *cmds,
699719
SCTP_HEARTBEAT_SUCCESS);
700720
}
701721

722+
if (t->state == SCTP_PF)
723+
sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP,
724+
SCTP_HEARTBEAT_SUCCESS);
725+
702726
/* The receiver of the HEARTBEAT ACK should also perform an
703727
* RTT measurement for that destination transport address
704728
* using the time value carried in the HEARTBEAT ACK chunk.
@@ -1565,8 +1589,8 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
15651589

15661590
case SCTP_CMD_STRIKE:
15671591
/* Mark one strike against a transport. */
1568-
sctp_do_8_2_transport_strike(asoc, cmd->obj.transport,
1569-
0);
1592+
sctp_do_8_2_transport_strike(commands, asoc,
1593+
cmd->obj.transport, 0);
15701594
break;
15711595

15721596
case SCTP_CMD_TRANSPORT_IDLE:
@@ -1576,7 +1600,8 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
15761600

15771601
case SCTP_CMD_TRANSPORT_HB_SENT:
15781602
t = cmd->obj.transport;
1579-
sctp_do_8_2_transport_strike(asoc, t, 1);
1603+
sctp_do_8_2_transport_strike(commands, asoc,
1604+
t, 1);
15801605
t->hb_sent = 1;
15811606
break;
15821607

0 commit comments

Comments
 (0)