Skip to content

Commit 92da362

Browse files
committed
Merge branch 'sctp-rfc7829'
Xin Long says: ==================== sctp: update from rfc7829 SCTP-PF was implemented based on a Internet-Draft in 2012: https://tools.ietf.org/html/draft-nishida-tsvwg-sctp-failover-05 It's been updated quite a few by rfc7829 in 2016. This patchset adds the following features: 1. add SCTP_ADDR_POTENTIALLY_FAILED notification 2. add pf_expose per netns/sock/asoc 3. add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt 4. add ps_retrans per netns/sock/asoc/transport (Primary Path Switchover) 5. add spt_pathcpthld for SCTP_PEER_ADDR_THLDS sockopt v1->v2: - See Patch 2/5 and Patch 5/5. v2->v3: - See Patch 1/5, 2/5 and 3/5. v3->v4: - See Patch 1/5, 2/5, 3/5 and 4/5. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents a0c7634 + d467ac0 commit 92da362

10 files changed

Lines changed: 266 additions & 38 deletions

File tree

‎Documentation/networking/ip-sysctl.txt‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,6 +2091,28 @@ pf_enable - INTEGER
20912091

20922092
Default: 1
20932093

2094+
pf_expose - INTEGER
2095+
Unset or enable/disable pf (pf is short for potentially failed) state
2096+
exposure. Applications can control the exposure of the PF path state
2097+
in the SCTP_PEER_ADDR_CHANGE event and the SCTP_GET_PEER_ADDR_INFO
2098+
sockopt. When it's unset, no SCTP_PEER_ADDR_CHANGE event with
2099+
SCTP_ADDR_PF state will be sent and a SCTP_PF-state transport info
2100+
can be got via SCTP_GET_PEER_ADDR_INFO sockopt; When it's enabled,
2101+
a SCTP_PEER_ADDR_CHANGE event will be sent for a transport becoming
2102+
SCTP_PF state and a SCTP_PF-state transport info can be got via
2103+
SCTP_GET_PEER_ADDR_INFO sockopt; When it's diabled, no
2104+
SCTP_PEER_ADDR_CHANGE event will be sent and it returns -EACCES when
2105+
trying to get a SCTP_PF-state transport info via SCTP_GET_PEER_ADDR_INFO
2106+
sockopt.
2107+
2108+
0: Unset pf state exposure, Compatible with old applications.
2109+
2110+
1: Disable pf state exposure.
2111+
2112+
2: Enable pf state exposure.
2113+
2114+
Default: 0
2115+
20942116
addip_noauth_enable - BOOLEAN
20952117
Dynamic Address Reconfiguration (ADD-IP) requires the use of
20962118
authentication to protect the operations of adding or removing new
@@ -2173,6 +2195,18 @@ pf_retrans - INTEGER
21732195

21742196
Default: 0
21752197

2198+
ps_retrans - INTEGER
2199+
Primary.Switchover.Max.Retrans (PSMR), it's a tunable parameter coming
2200+
from section-5 "Primary Path Switchover" in rfc7829. The primary path
2201+
will be changed to another active path when the path error counter on
2202+
the old primary path exceeds PSMR, so that "the SCTP sender is allowed
2203+
to continue data transmission on a new working path even when the old
2204+
primary destination address becomes active again". Note this feature
2205+
is disabled by initializing 'ps_retrans' per netns as 0xffff by default,
2206+
and its value can't be less than 'pf_retrans' when changing by sysctl.
2207+
2208+
Default: 0xffff
2209+
21762210
rto_initial - INTEGER
21772211
The initial round trip timeout value in milliseconds that will be used
21782212
in calculating round trip times. This is the initial time interval

‎include/net/netns/sctp.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,27 @@ struct netns_sctp {
8989
*/
9090
int pf_retrans;
9191

92+
/* Primary.Switchover.Max.Retrans sysctl value
93+
* taken from:
94+
* https://tools.ietf.org/html/rfc7829
95+
*/
96+
int ps_retrans;
97+
9298
/*
9399
* Disable Potentially-Failed feature, the feature is enabled by default
94100
* pf_enable - 0 : disable pf
95101
* - >0 : enable pf
96102
*/
97103
int pf_enable;
98104

105+
/*
106+
* Disable Potentially-Failed state exposure, ignored by default
107+
* pf_expose - 0 : compatible with old applications (by default)
108+
* - 1 : disable pf state exposure
109+
* - 2 : enable pf state exposure
110+
*/
111+
int pf_expose;
112+
99113
/*
100114
* Policy for preforming sctp/socket accounting
101115
* 0 - do socket level accounting, all assocs share sk_sndbuf

‎include/net/sctp/constants.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,18 @@ enum { SCTP_MAX_GABS = 16 };
286286
* functions simpler to write.
287287
*/
288288

289+
/* These are the values for pf exposure, UNUSED is to keep compatible with old
290+
* applications by default.
291+
*/
292+
enum {
293+
SCTP_PF_EXPOSE_UNSET,
294+
SCTP_PF_EXPOSE_DISABLE,
295+
SCTP_PF_EXPOSE_ENABLE,
296+
};
297+
#define SCTP_PF_EXPOSE_MAX SCTP_PF_EXPOSE_ENABLE
298+
299+
#define SCTP_PS_RETRANS_MAX 0xffff
300+
289301
/* These return values describe the success or failure of a number of
290302
* routines which form the lower interface to SCTP_outqueue.
291303
*/

‎include/net/sctp/structs.h‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ struct sctp_sock {
184184
__u32 flowlabel;
185185
__u8 dscp;
186186

187-
int pf_retrans;
187+
__u16 pf_retrans;
188+
__u16 ps_retrans;
188189

189190
/* The initial Path MTU to use for new associations. */
190191
__u32 pathmtu;
@@ -215,6 +216,7 @@ struct sctp_sock {
215216
__u32 adaptation_ind;
216217
__u32 pd_point;
217218
__u16 nodelay:1,
219+
pf_expose:2,
218220
reuse:1,
219221
disable_fragments:1,
220222
v4mapped:1,
@@ -896,7 +898,9 @@ struct sctp_transport {
896898
* and will be initialized from the assocs value. This can be changed
897899
* using the SCTP_PEER_ADDR_THLDS socket option
898900
*/
899-
int pf_retrans;
901+
__u16 pf_retrans;
902+
/* Used for primary path switchover. */
903+
__u16 ps_retrans;
900904
/* PMTU : The current known path MTU. */
901905
__u32 pathmtu;
902906

@@ -1772,7 +1776,9 @@ struct sctp_association {
17721776
* and will be initialized from the assocs value. This can be
17731777
* changed using the SCTP_PEER_ADDR_THLDS socket option
17741778
*/
1775-
int pf_retrans;
1779+
__u16 pf_retrans;
1780+
/* Used for primary path switchover. */
1781+
__u16 ps_retrans;
17761782

17771783
/* Maximum number of times the endpoint will retransmit INIT */
17781784
__u16 max_init_attempts;
@@ -2053,6 +2059,7 @@ struct sctp_association {
20532059

20542060
__u8 need_ecne:1, /* Need to send an ECNE Chunk? */
20552061
temp:1, /* Is it a temporary association? */
2062+
pf_expose:2, /* Expose pf state? */
20562063
force_delay:1;
20572064

20582065
__u8 strreset_enable;

‎include/uapi/linux/sctp.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ typedef __s32 sctp_assoc_t;
105105
#define SCTP_DEFAULT_SNDINFO 34
106106
#define SCTP_AUTH_DEACTIVATE_KEY 35
107107
#define SCTP_REUSE_PORT 36
108+
#define SCTP_PEER_ADDR_THLDS_V2 37
108109

109110
/* Internal Socket Options. Some of the sctp library functions are
110111
* implemented using these socket options.
@@ -137,6 +138,8 @@ typedef __s32 sctp_assoc_t;
137138
#define SCTP_ASCONF_SUPPORTED 128
138139
#define SCTP_AUTH_SUPPORTED 129
139140
#define SCTP_ECN_SUPPORTED 130
141+
#define SCTP_EXPOSE_POTENTIALLY_FAILED_STATE 131
142+
#define SCTP_EXPOSE_PF_STATE SCTP_EXPOSE_POTENTIALLY_FAILED_STATE
140143

141144
/* PR-SCTP policies */
142145
#define SCTP_PR_SCTP_NONE 0x0000
@@ -410,6 +413,8 @@ enum sctp_spc_state {
410413
SCTP_ADDR_ADDED,
411414
SCTP_ADDR_MADE_PRIM,
412415
SCTP_ADDR_CONFIRMED,
416+
SCTP_ADDR_POTENTIALLY_FAILED,
417+
#define SCTP_ADDR_PF SCTP_ADDR_POTENTIALLY_FAILED
413418
};
414419

415420

@@ -933,6 +938,7 @@ struct sctp_paddrinfo {
933938
enum sctp_spinfo_state {
934939
SCTP_INACTIVE,
935940
SCTP_PF,
941+
#define SCTP_POTENTIALLY_FAILED SCTP_PF
936942
SCTP_ACTIVE,
937943
SCTP_UNCONFIRMED,
938944
SCTP_UNKNOWN = 0xffff /* Value used for transport state unknown */
@@ -1082,6 +1088,15 @@ struct sctp_paddrthlds {
10821088
__u16 spt_pathpfthld;
10831089
};
10841090

1091+
/* Use a new structure with spt_pathcpthld for back compatibility */
1092+
struct sctp_paddrthlds_v2 {
1093+
sctp_assoc_t spt_assoc_id;
1094+
struct sockaddr_storage spt_address;
1095+
__u16 spt_pathmaxrxt;
1096+
__u16 spt_pathpfthld;
1097+
__u16 spt_pathcpthld;
1098+
};
1099+
10851100
/*
10861101
* Socket Option for Getting the Association/Stream-Specific PR-SCTP Status
10871102
*/

‎net/sctp/associola.c‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ static struct sctp_association *sctp_association_init(
8686
*/
8787
asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt;
8888
asoc->pf_retrans = sp->pf_retrans;
89+
asoc->ps_retrans = sp->ps_retrans;
90+
asoc->pf_expose = sp->pf_expose;
8991

9092
asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial);
9193
asoc->rto_max = msecs_to_jiffies(sp->rtoinfo.srto_max);
@@ -627,6 +629,8 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
627629

628630
/* And the partial failure retrans threshold */
629631
peer->pf_retrans = asoc->pf_retrans;
632+
/* And the primary path switchover retrans threshold */
633+
peer->ps_retrans = asoc->ps_retrans;
630634

631635
/* Initialize the peer's SACK delay timeout based on the
632636
* association configured value.
@@ -786,8 +790,8 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
786790
enum sctp_transport_cmd command,
787791
sctp_sn_error_t error)
788792
{
793+
int spc_state = SCTP_ADDR_AVAILABLE;
789794
bool ulp_notify = true;
790-
int spc_state = 0;
791795

792796
/* Record the transition on the transport. */
793797
switch (command) {
@@ -796,19 +800,13 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
796800
* to heartbeat success, report the SCTP_ADDR_CONFIRMED
797801
* state to the user, otherwise report SCTP_ADDR_AVAILABLE.
798802
*/
799-
if (SCTP_UNCONFIRMED == transport->state &&
800-
SCTP_HEARTBEAT_SUCCESS == error)
801-
spc_state = SCTP_ADDR_CONFIRMED;
802-
else
803-
spc_state = SCTP_ADDR_AVAILABLE;
804-
/* Don't inform ULP about transition from PF to
805-
* active state and set cwnd to 1 MTU, see SCTP
806-
* Quick failover draft section 5.1, point 5
807-
*/
808-
if (transport->state == SCTP_PF) {
803+
if (transport->state == SCTP_PF &&
804+
asoc->pf_expose != SCTP_PF_EXPOSE_ENABLE)
809805
ulp_notify = false;
810-
transport->cwnd = asoc->pathmtu;
811-
}
806+
else if (transport->state == SCTP_UNCONFIRMED &&
807+
error == SCTP_HEARTBEAT_SUCCESS)
808+
spc_state = SCTP_ADDR_CONFIRMED;
809+
812810
transport->state = SCTP_ACTIVE;
813811
break;
814812

@@ -817,19 +815,21 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
817815
* to inactive state. Also, release the cached route since
818816
* there may be a better route next time.
819817
*/
820-
if (transport->state != SCTP_UNCONFIRMED)
818+
if (transport->state != SCTP_UNCONFIRMED) {
821819
transport->state = SCTP_INACTIVE;
822-
else {
820+
spc_state = SCTP_ADDR_UNREACHABLE;
821+
} else {
823822
sctp_transport_dst_release(transport);
824823
ulp_notify = false;
825824
}
826-
827-
spc_state = SCTP_ADDR_UNREACHABLE;
828825
break;
829826

830827
case SCTP_TRANSPORT_PF:
831828
transport->state = SCTP_PF;
832-
ulp_notify = false;
829+
if (asoc->pf_expose != SCTP_PF_EXPOSE_ENABLE)
830+
ulp_notify = false;
831+
else
832+
spc_state = SCTP_ADDR_POTENTIALLY_FAILED;
833833
break;
834834

835835
default:

‎net/sctp/protocol.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,9 +1217,15 @@ static int __net_init sctp_defaults_init(struct net *net)
12171217
/* Max.Burst - 4 */
12181218
net->sctp.max_burst = SCTP_DEFAULT_MAX_BURST;
12191219

1220+
/* Disable of Primary Path Switchover by default */
1221+
net->sctp.ps_retrans = SCTP_PS_RETRANS_MAX;
1222+
12201223
/* Enable pf state by default */
12211224
net->sctp.pf_enable = 1;
12221225

1226+
/* Ignore pf exposure feature by default */
1227+
net->sctp.pf_expose = SCTP_PF_EXPOSE_UNSET;
1228+
12231229
/* Association.Max.Retrans - 10 attempts
12241230
* Path.Max.Retrans - 5 attempts (per destination address)
12251231
* Max.Init.Retransmits - 8 attempts

‎net/sctp/sm_sideeffect.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,11 @@ static void sctp_do_8_2_transport_strike(struct sctp_cmd_seq *commands,
567567
SCTP_FAILED_THRESHOLD);
568568
}
569569

570+
if (transport->error_count > transport->ps_retrans &&
571+
asoc->peer.primary_path == transport &&
572+
asoc->peer.active_path != transport)
573+
sctp_assoc_set_primary(asoc, asoc->peer.active_path);
574+
570575
/* E2) For the destination address for which the timer
571576
* expires, set RTO <- RTO * 2 ("back off the timer"). The
572577
* maximum value discussed in rule C7 above (RTO.max) may be

0 commit comments

Comments
 (0)