From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-08 11:25:26
SCTP Quick failover draft section 5.1, point 5 has been removed
from rfc7829. Instead, "the sender SHOULD (i) notify the Upper
Layer Protocol (ULP) about this state transition", as said in
section 3.2, point 8.
So this patch is to add SCTP_ADDR_POTENTIALLY_FAILED, defined
in section 7.1, "which is reported if the affected address
becomes PF". Also remove transport cwnd's update when moving
from PF back to ACTIVE , which is no longer in rfc7829 either.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
include/uapi/linux/sctp.h | 1 +
net/sctp/associola.c | 17 ++++-------------
2 files changed, 5 insertions(+), 13 deletions(-)
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-08 11:25:36
As said in rfc7829, section 3, point 12:
The SCTP stack SHOULD expose the PF state of its destination
addresses to the ULP as well as provide the means to notify the
ULP of state transitions of its destination addresses from
active to PF, and vice versa. However, it is recommended that
an SCTP stack implementing SCTP-PF also allows for the ULP to be
kept ignorant of the PF state of its destinations and the
associated state transitions, thus allowing for retention of the
simpler state transition model of [RFC4960] in the ULP.
Not only does it allow to expose the PF state to ULP, but also
allow to ignore sctp-pf to ULP.
So this patch is to add pf_expose per netns, sock and asoc. And in
sctp_assoc_control_transport(), ulp_notify will be set to false if
asoc->expose is not set.
It also allows a user to change pf_expose per netns by sysctl, and
pf_expose per sock and asoc will be initialized with it.
Note that pf_expose also works for SCTP_GET_PEER_ADDR_INFO sockopt,
to not allow a user to query the state of a sctp-pf peer address
when pf_expose is not enabled, as said in section 7.3.
v1->v2:
- Fix a build warning noticed by Nathan Chancellor.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
include/net/netns/sctp.h | 7 +++++++
include/net/sctp/structs.h | 2 ++
include/uapi/linux/sctp.h | 1 +
net/sctp/associola.c | 8 +++++++-
net/sctp/protocol.c | 3 +++
net/sctp/socket.c | 12 ++++++++++--
net/sctp/sysctl.c | 7 +++++++
7 files changed, 37 insertions(+), 3 deletions(-)
@@ -2053,6 +2054,7 @@ struct sctp_association {__u8need_ecne:1,/* Need to send an ECNE Chunk? */temp:1,/* Is it a temporary association? */+pf_expose:1,/* Expose pf state? */force_delay:1;__u8strreset_enable;
@@ -920,6 +920,7 @@ struct sctp_paddrinfo {enumsctp_spinfo_state{SCTP_INACTIVE,SCTP_PF,+#define SCTP_POTENTIALLY_FAILED SCTP_PFSCTP_ACTIVE,SCTP_UNCONFIRMED,SCTP_UNKNOWN=0xffff/* Value used for transport state unknown */
@@ -1220,6 +1220,9 @@ static int __net_init sctp_defaults_init(struct net *net)/* Enable pf state by default */net->sctp.pf_enable=1;+/* Enable pf state exposure by default */+net->sctp.pf_expose=1;+/* Association.Max.Retrans - 10 attempts*Path.Max.Retrans-5attempts(perdestinationaddress)*Max.Init.Retransmits-8attempts
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-08 11:25:43
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
include/uapi/linux/sctp.h | 1 +
net/sctp/socket.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+)
@@ -4589,6 +4589,37 @@ static int sctp_setsockopt_ecn_supported(struct sock *sk,returnretval;}+staticintsctp_setsockopt_pf_expose(structsock*sk,+char__user*optval,+unsignedintoptlen)+{+structsctp_assoc_valueparams;+structsctp_association*asoc;+intretval=-EINVAL;++if(optlen!=sizeof(params))+gotoout;++if(copy_from_user(¶ms,optval,optlen)){+retval=-EFAULT;+gotoout;+}++asoc=sctp_id2assoc(sk,params.assoc_id);+if(!asoc&¶ms.assoc_id!=SCTP_FUTURE_ASSOC&&+sctp_style(sk,UDP))+gotoout;++if(asoc)+asoc->pf_expose=!!params.assoc_value;+else+sctp_sk(sk)->pf_expose=!!params.assoc_value;+retval=0;++out:+returnretval;+}+/* API 6.2 setsockopt(), getsockopt()**Applicationsusesetsockopt()andgetsockopt()tosetorretrieve
@@ -4798,6 +4829,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,caseSCTP_ECN_SUPPORTED:retval=sctp_setsockopt_ecn_supported(sk,optval,optlen);break;+caseSCTP_EXPOSE_POTENTIALLY_FAILED_STATE:+retval=sctp_setsockopt_pf_expose(sk,optval,optlen);+break;default:retval=-ENOPROTOOPT;break;
@@ -7908,6 +7942,45 @@ static int sctp_getsockopt_ecn_supported(struct sock *sk, int len,returnretval;}+staticintsctp_getsockopt_pf_expose(structsock*sk,intlen,+char__user*optval,+int__user*optlen)+{+structsctp_assoc_valueparams;+structsctp_association*asoc;+intretval=-EFAULT;++if(len<sizeof(params)){+retval=-EINVAL;+gotoout;+}++len=sizeof(params);+if(copy_from_user(¶ms,optval,len))+gotoout;++asoc=sctp_id2assoc(sk,params.assoc_id);+if(!asoc&¶ms.assoc_id!=SCTP_FUTURE_ASSOC&&+sctp_style(sk,UDP)){+retval=-EINVAL;+gotoout;+}++params.assoc_value=asoc?asoc->pf_expose+:sctp_sk(sk)->pf_expose;++if(put_user(len,optlen))+gotoout;++if(copy_to_user(optval,¶ms,len))+gotoout;++retval=0;++out:+returnretval;+}+staticintsctp_getsockopt(structsock*sk,intlevel,intoptname,char__user*optval,int__user*optlen){
@@ -8120,6 +8193,9 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,caseSCTP_ECN_SUPPORTED:retval=sctp_getsockopt_ecn_supported(sk,len,optval,optlen);break;+caseSCTP_EXPOSE_POTENTIALLY_FAILED_STATE:+retval=sctp_getsockopt_pf_expose(sk,len,optval,optlen);+break;default:retval=-ENOPROTOOPT;break;
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-08 11:25:49
This is a new feature defined in section 5 of rfc7829: "Primary Path
Switchover". By introducing a new tunable parameter:
Primary.Switchover.Max.Retrans (PSMR)
The primary path will be changed to another active path when the path
error counter on the old primary path exceeds PSMR, so that "the SCTP
sender is allowed to continue data transmission on a new working path
even when the old primary destination address becomes active again".
This patch is to add this tunable parameter, 'ps_retrans' per netns,
sock, asoc and transport. It also allows a user to change ps_retrans
per netns by sysctl, and ps_retrans per sock/asoc/transport will be
initialized with it.
The check will be done in sctp_do_8_2_transport_strike() when this
feature is enabled.
Note this feature is disabled by initializing 'ps_retrans' per netns
as 0xffff by default, and its value can't be less than 'pf_retrans'
when changing by sysctl.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
include/net/netns/sctp.h | 6 ++++++
include/net/sctp/structs.h | 11 ++++++++---
net/sctp/associola.c | 3 +++
net/sctp/protocol.c | 3 +++
net/sctp/sm_sideeffect.c | 5 +++++
net/sctp/socket.c | 1 +
net/sctp/sysctl.c | 9 +++++++++
7 files changed, 35 insertions(+), 3 deletions(-)
@@ -184,7 +184,8 @@ struct sctp_sock {__u32flowlabel;__u8dscp;-intpf_retrans;+__u16pf_retrans;+__u16ps_retrans;/* The initial Path MTU to use for new associations. */__u32pathmtu;
@@ -897,7 +898,9 @@ struct sctp_transport {*andwillbeinitializedfromtheassocsvalue.Thiscanbechanged*usingtheSCTP_PEER_ADDR_THLDSsocketoption*/-intpf_retrans;+__u16pf_retrans;+/* Used for primary path switchover. */+__u16ps_retrans;/* PMTU : The current known path MTU. */__u32pathmtu;
@@ -1773,7 +1776,9 @@ struct sctp_association {*andwillbeinitializedfromtheassocsvalue.Thiscanbe*changedusingtheSCTP_PEER_ADDR_THLDSsocketoption*/-intpf_retrans;+__u16pf_retrans;+/* Used for primary path switchover. */+__u16ps_retrans;/* Maximum number of times the endpoint will retransmit INIT */__u16max_init_attempts;
@@ -625,6 +626,8 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,/* And the partial failure retrans threshold */peer->pf_retrans=asoc->pf_retrans;+/* And the primary path switchover retrans threshold */+peer->ps_retrans=asoc->ps_retrans;/* Initialize the peer's SACK delay timeout based on the*associationconfiguredvalue.
@@ -1217,6 +1217,9 @@ static int __net_init sctp_defaults_init(struct net *net)/* Max.Burst - 4 */net->sctp.max_burst=SCTP_DEFAULT_MAX_BURST;+/* Disable of Primary Path Switchover by default */+net->sctp.ps_retrans=0xffff;+/* Enable pf state by default */net->sctp.pf_enable=1;
@@ -567,6 +567,11 @@ static void sctp_do_8_2_transport_strike(struct sctp_cmd_seq *commands,SCTP_FAILED_THRESHOLD);}+if(transport->error_count>transport->ps_retrans&&+asoc->peer.primary_path==transport&&+asoc->peer.active_path!=transport)+sctp_assoc_set_primary(asoc,asoc->peer.active_path);+/* E2) For the destination address for which the timer*expires,setRTO<-RTO*2("back off the timer").The*maximumvaluediscussedinruleC7above(RTO.max)maybe
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-08 11:25:57
Section 7.2 of rfc7829: "Peer Address Thresholds (SCTP_PEER_ADDR_THLDS)
Socket Option" extends 'struct sctp_paddrthlds' with 'spt_pathcpthld'
added to allow a user to change ps_retrans per sock/asoc/transport, as
other 2 paddrthlds: pf_retrans, pathmaxrxt.
Note: to not break the user's program, here to support pf_retrans dump
and setting by adding a new sockopt SCTP_PEER_ADDR_THLDS_V2, and a new
structure sctp_paddrthlds_v2 instead of extending sctp_paddrthlds.
Also, when setting ps_retrans, the value is not allowed to be greater
than pf_retrans.
v1->v2:
- use SCTP_PEER_ADDR_THLDS_V2 to set/get pf_retrans instead,
as Marcelo and David Laight suggested.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
include/uapi/linux/sctp.h | 10 +++++++++
net/sctp/socket.c | 54 +++++++++++++++++++++++++++++++++++------------
2 files changed, 50 insertions(+), 14 deletions(-)
@@ -105,6 +105,7 @@ typedef __s32 sctp_assoc_t;#define SCTP_DEFAULT_SNDINFO 34#define SCTP_AUTH_DEACTIVATE_KEY 35#define SCTP_REUSE_PORT 36+#define SCTP_PEER_ADDR_THLDS_V2 37/* Internal Socket Options. Some of the sctp library functions are*implementedusingthesesocketoptions.
@@ -1071,6 +1072,15 @@ struct sctp_paddrthlds {__u16spt_pathpfthld;};+/* Use a new structure with spt_pathcpthld for back compatibility */+structsctp_paddrthlds_v2{+sctp_assoc_tspt_assoc_id;+structsockaddr_storagespt_address;+__u16spt_pathmaxrxt;+__u16spt_pathpfthld;+__u16spt_pathcpthld;+};+/**SocketOptionforGettingtheAssociation/Stream-SpecificPR-SCTPStatus*/
@@ -3963,6 +3967,8 @@ static int sctp_setsockopt_paddr_thresholds(struct sock *sk,if(val.spt_pathmaxrxt)trans->pathmaxrxt=val.spt_pathmaxrxt;+if(v2)+trans->ps_retrans=val.spt_pathcpthld;trans->pf_retrans=val.spt_pathpfthld;return0;
@@ -3978,17 +3984,23 @@ static int sctp_setsockopt_paddr_thresholds(struct sock *sk,transports){if(val.spt_pathmaxrxt)trans->pathmaxrxt=val.spt_pathmaxrxt;+if(v2)+trans->ps_retrans=val.spt_pathcpthld;trans->pf_retrans=val.spt_pathpfthld;}if(val.spt_pathmaxrxt)asoc->pathmaxrxt=val.spt_pathmaxrxt;+if(v2)+asoc->ps_retrans=val.spt_pathcpthld;asoc->pf_retrans=val.spt_pathpfthld;}else{structsctp_sock*sp=sctp_sk(sk);if(val.spt_pathmaxrxt)sp->pathmaxrxt=val.spt_pathmaxrxt;+if(v2)+sp->ps_retrans=val.spt_pathcpthld;sp->pf_retrans=val.spt_pathpfthld;}
@@ -4775,7 +4787,12 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,retval=sctp_setsockopt_auto_asconf(sk,optval,optlen);break;caseSCTP_PEER_ADDR_THLDS:-retval=sctp_setsockopt_paddr_thresholds(sk,optval,optlen);+retval=sctp_setsockopt_paddr_thresholds(sk,optval,optlen,+false);+break;+caseSCTP_PEER_ADDR_THLDS_V2:+retval=sctp_setsockopt_paddr_thresholds(sk,optval,optlen,+true);break;caseSCTP_RECVRCVINFO:retval=sctp_setsockopt_recvrcvinfo(sk,optval,optlen);
@@ -7213,18 +7230,19 @@ static int sctp_getsockopt_assoc_ids(struct sock *sk, int len,*http://www.ietf.org/id/draft-nishida-tsvwg-sctp-failover-05.txt*/staticintsctp_getsockopt_paddr_thresholds(structsock*sk,-char__user*optval,-intlen,-int__user*optlen)+char__user*optval,intlen,+int__user*optlen,boolv2){-structsctp_paddrthldsval;+structsctp_paddrthlds_v2val;structsctp_transport*trans;structsctp_association*asoc;+intmin;-if(len<sizeof(structsctp_paddrthlds))+min=v2?sizeof(val):sizeof(structsctp_paddrthlds);+if(len<min)return-EINVAL;-len=sizeof(structsctp_paddrthlds);-if(copy_from_user(&val,(structsctp_paddrthlds__user*)optval,len))+len=min;+if(copy_from_user(&val,optval,len))return-EFAULT;if(!sctp_is_any(sk,(constunionsctp_addr*)&val.spt_address)){
@@ -7235,6 +7253,7 @@ static int sctp_getsockopt_paddr_thresholds(struct sock *sk,val.spt_pathmaxrxt=trans->pathmaxrxt;val.spt_pathpfthld=trans->pf_retrans;+val.spt_pathcpthld=trans->ps_retrans;gotoout;}
@@ -7247,11 +7266,13 @@ static int sctp_getsockopt_paddr_thresholds(struct sock *sk,if(asoc){val.spt_pathpfthld=asoc->pf_retrans;val.spt_pathmaxrxt=asoc->pathmaxrxt;+val.spt_pathcpthld=asoc->ps_retrans;}else{structsctp_sock*sp=sctp_sk(sk);val.spt_pathpfthld=sp->pf_retrans;val.spt_pathmaxrxt=sp->pathmaxrxt;+val.spt_pathcpthld=sp->ps_retrans;}out:
@@ -8131,7 +8152,12 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,retval=sctp_getsockopt_auto_asconf(sk,len,optval,optlen);break;caseSCTP_PEER_ADDR_THLDS:-retval=sctp_getsockopt_paddr_thresholds(sk,optval,len,optlen);+retval=sctp_getsockopt_paddr_thresholds(sk,optval,len,+optlen,false);+break;+caseSCTP_PEER_ADDR_THLDS_V2:+retval=sctp_getsockopt_paddr_thresholds(sk,optval,len,+optlen,true);break;caseSCTP_GET_ASSOC_STATS:retval=sctp_getsockopt_assoc_stats(sk,len,optval,optlen);
From: David Laight <hidden> Date: 2019-10-08 13:03:01
From: Xin Long
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-08 15:27:42
On Tue, Oct 8, 2019 at 9:02 PM David Laight [off-list ref] wrote:
From: Xin Long
quoted
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
If we do that, sctp_getsockopt_peer_addr_info() in patch 2/5 breaks.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Neil Horman <nhorman@tuxdriver.com> Date: 2019-10-09 16:18:13
On Tue, Oct 08, 2019 at 11:28:32PM +0800, Xin Long wrote:
On Tue, Oct 8, 2019 at 9:02 PM David Laight [off-list ref] wrote:
quoted
From: Xin Long
quoted
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
If we do that, sctp_getsockopt_peer_addr_info() in patch 2/5 breaks.
I don't think we can safely do either of these things. Older
applications still need to behave as they did prior to the introduction
of this notification, and we shouldn't allow unexpected notifications to
be sent.
What if you added a check in get_peer_addr_info to only return -EACCESS
if pf_expose is 0 and the application isn't subscribed to the PF event?
Neil
quoted
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-10 09:28:48
On Thu, Oct 10, 2019 at 12:18 AM Neil Horman [off-list ref] wrote:
On Tue, Oct 08, 2019 at 11:28:32PM +0800, Xin Long wrote:
quoted
On Tue, Oct 8, 2019 at 9:02 PM David Laight [off-list ref] wrote:
quoted
From: Xin Long
quoted
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
If we do that, sctp_getsockopt_peer_addr_info() in patch 2/5 breaks.
I don't think we can safely do either of these things. Older
applications still need to behave as they did prior to the introduction
of this notification, and we shouldn't allow unexpected notifications to
be sent.
What if you added a check in get_peer_addr_info to only return -EACCESS
if pf_expose is 0 and the application isn't subscribed to the PF event?
We can't subscribe to PF event only, but all the SCTP_PEER_ADDR_CHANGE
events.
Now I'm thinking both PF event and "return -EACCES" in get_peer_addr_info
are new, we should give 'expose' a default value that would disable both.
How do think if we set 'pf_expose = -1' by default. We send the pf event
only if (asoc->pf_expose > 0) in sctp_assoc_control_transport().
Neil
quoted
quoted
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Neil Horman <nhorman@tuxdriver.com> Date: 2019-10-10 12:41:01
On Thu, Oct 10, 2019 at 05:28:34PM +0800, Xin Long wrote:
On Thu, Oct 10, 2019 at 12:18 AM Neil Horman [off-list ref] wrote:
quoted
On Tue, Oct 08, 2019 at 11:28:32PM +0800, Xin Long wrote:
quoted
On Tue, Oct 8, 2019 at 9:02 PM David Laight [off-list ref] wrote:
quoted
From: Xin Long
quoted
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
If we do that, sctp_getsockopt_peer_addr_info() in patch 2/5 breaks.
I don't think we can safely do either of these things. Older
applications still need to behave as they did prior to the introduction
of this notification, and we shouldn't allow unexpected notifications to
be sent.
What if you added a check in get_peer_addr_info to only return -EACCESS
if pf_expose is 0 and the application isn't subscribed to the PF event?
We can't subscribe to PF event only, but all the SCTP_PEER_ADDR_CHANGE
events.
Now I'm thinking both PF event and "return -EACCES" in get_peer_addr_info
are new, we should give 'expose' a default value that would disable both.
How do think if we set 'pf_expose = -1' by default. We send the pf event
only if (asoc->pf_expose > 0) in sctp_assoc_control_transport().
And if pf_expose = 0, we send the event, and return -EACCESS if we call
the socket option and find a PF assoc? If so, yes, I think that makes
sense.
Neil
quoted
Neil
quoted
quoted
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-11 15:58:05
On Thu, Oct 10, 2019 at 8:40 PM Neil Horman [off-list ref] wrote:
On Thu, Oct 10, 2019 at 05:28:34PM +0800, Xin Long wrote:
quoted
On Thu, Oct 10, 2019 at 12:18 AM Neil Horman [off-list ref] wrote:
quoted
On Tue, Oct 08, 2019 at 11:28:32PM +0800, Xin Long wrote:
quoted
On Tue, Oct 8, 2019 at 9:02 PM David Laight [off-list ref] wrote:
quoted
From: Xin Long
quoted
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
If we do that, sctp_getsockopt_peer_addr_info() in patch 2/5 breaks.
I don't think we can safely do either of these things. Older
applications still need to behave as they did prior to the introduction
of this notification, and we shouldn't allow unexpected notifications to
be sent.
What if you added a check in get_peer_addr_info to only return -EACCESS
if pf_expose is 0 and the application isn't subscribed to the PF event?
We can't subscribe to PF event only, but all the SCTP_PEER_ADDR_CHANGE
events.
Now I'm thinking both PF event and "return -EACCES" in get_peer_addr_info
are new, we should give 'expose' a default value that would disable both.
How do think if we set 'pf_expose = -1' by default. We send the pf event
only if (asoc->pf_expose > 0) in sctp_assoc_control_transport().
And if pf_expose = 0, we send the event, and return -EACCESS if we call
the socket option and find a PF assoc? If so, yes, I think that makes
sense.
pf_expose:
-1: compatible with old application (by default)
0: not expose PF to user
1: expose PF to user
So it should be:
if pf_expose == -1: not send event, not return -EACCESS
if pf_expose == 0: not send event, return -EACCESS
if pf_expose > 0: sent event, not return -EACCESS
makes sense?
Neil
quoted
quoted
Neil
quoted
quoted
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-11 16:25:36
On Fri, Oct 11, 2019 at 11:57 PM Xin Long [off-list ref] wrote:
On Thu, Oct 10, 2019 at 8:40 PM Neil Horman [off-list ref] wrote:
quoted
On Thu, Oct 10, 2019 at 05:28:34PM +0800, Xin Long wrote:
quoted
On Thu, Oct 10, 2019 at 12:18 AM Neil Horman [off-list ref] wrote:
quoted
On Tue, Oct 08, 2019 at 11:28:32PM +0800, Xin Long wrote:
quoted
On Tue, Oct 8, 2019 at 9:02 PM David Laight [off-list ref] wrote:
quoted
From: Xin Long
quoted
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
If we do that, sctp_getsockopt_peer_addr_info() in patch 2/5 breaks.
I don't think we can safely do either of these things. Older
applications still need to behave as they did prior to the introduction
of this notification, and we shouldn't allow unexpected notifications to
be sent.
What if you added a check in get_peer_addr_info to only return -EACCESS
if pf_expose is 0 and the application isn't subscribed to the PF event?
We can't subscribe to PF event only, but all the SCTP_PEER_ADDR_CHANGE
events.
Now I'm thinking both PF event and "return -EACCES" in get_peer_addr_info
are new, we should give 'expose' a default value that would disable both.
How do think if we set 'pf_expose = -1' by default. We send the pf event
only if (asoc->pf_expose > 0) in sctp_assoc_control_transport().
And if pf_expose = 0, we send the event, and return -EACCESS if we call
the socket option and find a PF assoc? If so, yes, I think that makes
sense.
pf_expose:
-1: compatible with old application (by default)
0: not expose PF to user
1: expose PF to user
So it should be:
if pf_expose == -1: not send event, not return -EACCESS
if pf_expose == 0: not send event, return -EACCESS
if pf_expose > 0: sent event, not return -EACCESS
makes sense?
Oh, sorry, pf_expose is 1 bit only now in asoc/ep.
Maybe we should use 2 bits, and values could be:
2: compatible with old application (by default)
0: not expose PF to user
1: expose PF to user
quoted
Neil
quoted
quoted
Neil
quoted
quoted
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Neil Horman <nhorman@tuxdriver.com> Date: 2019-10-11 21:29:25
On Sat, Oct 12, 2019 at 12:25:27AM +0800, Xin Long wrote:
On Fri, Oct 11, 2019 at 11:57 PM Xin Long [off-list ref] wrote:
quoted
On Thu, Oct 10, 2019 at 8:40 PM Neil Horman [off-list ref] wrote:
quoted
On Thu, Oct 10, 2019 at 05:28:34PM +0800, Xin Long wrote:
quoted
On Thu, Oct 10, 2019 at 12:18 AM Neil Horman [off-list ref] wrote:
quoted
On Tue, Oct 08, 2019 at 11:28:32PM +0800, Xin Long wrote:
quoted
On Tue, Oct 8, 2019 at 9:02 PM David Laight [off-list ref] wrote:
quoted
From: Xin Long
quoted
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
If we do that, sctp_getsockopt_peer_addr_info() in patch 2/5 breaks.
I don't think we can safely do either of these things. Older
applications still need to behave as they did prior to the introduction
of this notification, and we shouldn't allow unexpected notifications to
be sent.
What if you added a check in get_peer_addr_info to only return -EACCESS
if pf_expose is 0 and the application isn't subscribed to the PF event?
We can't subscribe to PF event only, but all the SCTP_PEER_ADDR_CHANGE
events.
Now I'm thinking both PF event and "return -EACCES" in get_peer_addr_info
are new, we should give 'expose' a default value that would disable both.
How do think if we set 'pf_expose = -1' by default. We send the pf event
only if (asoc->pf_expose > 0) in sctp_assoc_control_transport().
And if pf_expose = 0, we send the event, and return -EACCESS if we call
the socket option and find a PF assoc? If so, yes, I think that makes
sense.
pf_expose:
-1: compatible with old application (by default)
0: not expose PF to user
1: expose PF to user
So it should be:
if pf_expose == -1: not send event, not return -EACCESS
if pf_expose == 0: not send event, return -EACCESS
if pf_expose > 0: sent event, not return -EACCESS
makes sense?
Oh, sorry, pf_expose is 1 bit only now in asoc/ep.
Maybe we should use 2 bits, and values could be:
2: compatible with old application (by default)
0: not expose PF to user
1: expose PF to user
Yes, this version makes sense to me
Best
Neil
quoted
quoted
Neil
quoted
quoted
Neil
quoted
quoted
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-14 08:36:33
On Thu, Oct 10, 2019 at 12:18 AM Neil Horman [off-list ref] wrote:
On Tue, Oct 08, 2019 at 11:28:32PM +0800, Xin Long wrote:
quoted
On Tue, Oct 8, 2019 at 9:02 PM David Laight [off-list ref] wrote:
quoted
From: Xin Long
quoted
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
If we do that, sctp_getsockopt_peer_addr_info() in patch 2/5 breaks.
I don't think we can safely do either of these things. Older
applications still need to behave as they did prior to the introduction
of this notification, and we shouldn't allow unexpected notifications to
be sent.
Hi, Neil
I think about again, and also talked with QE, we think to get unexpected
notifications shouldn't be a problem for user's applications.
RFC actually keeps adding new notifications, and a user shouldn't expect
the specific notifications coming in some exact orders. They should just
ignore it and wait until the ones they expect. I don't think some users
would abort its application when getting an unexpected notification.
We should NACK patchset v3 and go with v2. What do you think?
What if you added a check in get_peer_addr_info to only return -EACCESS
if pf_expose is 0 and the application isn't subscribed to the PF event?
Neil
quoted
quoted
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: David Laight <hidden> Date: 2019-10-14 08:49:59
From: Xin Long <lucien.xin@gmail.com>
Sent: 14 October 2019 09:37
...
RFC actually keeps adding new notifications,
That RFC keeps moving the goalposts.
Even the structures are guaranteed to have holes.
and a user shouldn't expect
the specific notifications coming in some exact orders. They should just
ignore it and wait until the ones they expect. I don't think some users
would abort its application when getting an unexpected notification.
I've an example of exactly 1 application.
It uses TCP-style sockets (and will work over TCP).
It does getsockopt(SCTP_EVENTS), sets sctp_association_event, then setsockopt().
Any MSG_NOTIFICATION is assumed to be the a connection reset (enabled above)
and treated as an inwards disconnect.
So any unexpected notification will kill the connection.
I suspect it isn't the only one..
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Neil Horman <nhorman@tuxdriver.com> Date: 2019-10-14 12:42:00
On Mon, Oct 14, 2019 at 04:36:34PM +0800, Xin Long wrote:
On Thu, Oct 10, 2019 at 12:18 AM Neil Horman [off-list ref] wrote:
quoted
On Tue, Oct 08, 2019 at 11:28:32PM +0800, Xin Long wrote:
quoted
On Tue, Oct 8, 2019 at 9:02 PM David Laight [off-list ref] wrote:
quoted
From: Xin Long
quoted
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
If we do that, sctp_getsockopt_peer_addr_info() in patch 2/5 breaks.
I don't think we can safely do either of these things. Older
applications still need to behave as they did prior to the introduction
of this notification, and we shouldn't allow unexpected notifications to
be sent.
Hi, Neil
I think about again, and also talked with QE, we think to get unexpected
notifications shouldn't be a problem for user's applications.
On principle, I disagree. Regardless of what the RFC does, we shouldn't
send notifications that an application aren't subscribed to. Just
because QE doesn't think it should be a problem (and for their uses it
may well not be an issue), we can't make that general assumption.
RFC actually keeps adding new notifications, and a user shouldn't expect
the specific notifications coming in some exact orders. They should just
ignore it and wait until the ones they expect. I don't think some users
would abort its application when getting an unexpected notification.
To make that assertion is to discount the purpose of the SCTP_EVENTS
sockopt entirely. the SCTP_EVENTS option is a whitelist operation, so
they expect to get what they subscribe to, and no more.
We should NACK patchset v3 and go with v2. What do you think?
No, we need to go with an option that maintains backwards compatibility
without relying on the assumption that applications will just ignore
events they didn't subscribe to. Davids example is a case in point.
Neil
quoted
What if you added a check in get_peer_addr_info to only return -EACCESS
if pf_expose is 0 and the application isn't subscribed to the PF event?
Neil
quoted
quoted
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: David Laight <hidden> Date: 2019-10-14 13:49:03
From: Neil Horman <nhorman@tuxdriver.com>
Sent: 14 October 2019 13:42
To: Xin Long <lucien.xin@gmail.com>
Cc: David Laight <redacted>; network dev <redacted>; linux-sctp@vger.kernel.org; Marcelo
Ricardo Leitner [off-list ref]; davem@davemloft.net
Subject: Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt
On Mon, Oct 14, 2019 at 04:36:34PM +0800, Xin Long wrote:
quoted
On Thu, Oct 10, 2019 at 12:18 AM Neil Horman [off-list ref] wrote:
quoted
On Tue, Oct 08, 2019 at 11:28:32PM +0800, Xin Long wrote:
quoted
On Tue, Oct 8, 2019 at 9:02 PM David Laight [off-list ref] wrote:
quoted
From: Xin Long
quoted
Sent: 08 October 2019 12:25
This is a sockopt defined in section 7.3 of rfc7829: "Exposing
the Potentially Failed Path State", by which users can change
pf_expose per sock and asoc.
If I read these patches correctly the default for this sockopt in 'enabled'.
Doesn't this mean that old application binaries will receive notifications
that they aren't expecting?
I'd have thought that applications would be required to enable it.
If we do that, sctp_getsockopt_peer_addr_info() in patch 2/5 breaks.
I don't think we can safely do either of these things. Older
applications still need to behave as they did prior to the introduction
of this notification, and we shouldn't allow unexpected notifications to
be sent.
Hi, Neil
I think about again, and also talked with QE, we think to get unexpected
notifications shouldn't be a problem for user's applications.
On principle, I disagree. Regardless of what the RFC does, we shouldn't
send notifications that an application aren't subscribed to. Just
because QE doesn't think it should be a problem (and for their uses it
may well not be an issue), we can't make that general assumption.
quoted
RFC actually keeps adding new notifications, and a user shouldn't expect
the specific notifications coming in some exact orders. They should just
ignore it and wait until the ones they expect. I don't think some users
would abort its application when getting an unexpected notification.
To make that assertion is to discount the purpose of the SCTP_EVENTS
sockopt entirely. the SCTP_EVENTS option is a whitelist operation, so
they expect to get what they subscribe to, and no more.
quoted
We should NACK patchset v3 and go with v2. What do you think?
No, we need to go with an option that maintains backwards compatibility
without relying on the assumption that applications will just ignore
events they didn't subscribe to. Davids example is a case in point.
Although I don't enable the SCTP_PEER_ADDR_CHANGE indications.
But rfc 6458 doesn't say that the list might be extended.
Aren't there 3 separate items here:
1) The SCTP protocol changes (to better handle primary path failure).
2) The SCTP_GET_PEER_ADDR_INFO sockopt.
3) The MSG_NOTIFICATION indication for SCTP_ADDR_POTENTIALLY_FAILED.
Looking at RFC 7829 section 7.3.
7.3 defines SCTP_EXPOSE_POTENTIALLY_FAILED_STATE.
For compatibility this must default to 'disabled'.
This is even true if the application has set the SCTP_PEER_ADDR_THLDS.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: David Laight <hidden> Date: 2019-10-18 15:34:45
From: Xin Long
Sent: 08 October 2019 12:25
As said in rfc7829, section 3, point 12:
The SCTP stack SHOULD expose the PF state of its destination
addresses to the ULP as well as provide the means to notify the
ULP of state transitions of its destination addresses from
active to PF, and vice versa. However, it is recommended that
an SCTP stack implementing SCTP-PF also allows for the ULP to be
kept ignorant of the PF state of its destinations and the
associated state transitions, thus allowing for retention of the
simpler state transition model of [RFC4960] in the ULP.
Not only does it allow to expose the PF state to ULP, but also
allow to ignore sctp-pf to ULP.
So this patch is to add pf_expose per netns, sock and asoc. And in
sctp_assoc_control_transport(), ulp_notify will be set to false if
asoc->expose is not set.
It also allows a user to change pf_expose per netns by sysctl, and
pf_expose per sock and asoc will be initialized with it.
Note that pf_expose also works for SCTP_GET_PEER_ADDR_INFO sockopt,
to not allow a user to query the state of a sctp-pf peer address
when pf_expose is not enabled, as said in section 7.3.
@@ -1220,6 +1220,9 @@ static int __net_init sctp_defaults_init(struct net *net)/* Enable pf state by default */net->sctp.pf_enable=1;+/* Enable pf state exposure by default */+net->sctp.pf_expose=1;+
For compatibility with existing applications pf_expose MUST default to 0.
I'm not even sure it makes sense to have a sysctl for it.
...
quoted hunk
@@ -5521,8 +5522,15 @@ static int sctp_getsockopt_peer_addr_info(struct sock *sk, int len, transport = sctp_addr_id2transport(sk, &pinfo.spinfo_address, pinfo.spinfo_assoc_id);- if (!transport)- return -EINVAL;+ if (!transport) {+ retval = -EINVAL;+ goto out;+ }++ if (transport->state == SCTP_PF && !transport->asoc->pf_expose) {+ retval = -EACCES;+ goto out;+ }
Ugg...
To avoid reporting the unexpected 'SCTP_PF' state you probable need
to lie about the state (probably reporting 'working' - or whatever state
it would be in if PF detection wasn't enabled.
...
Setting this will break existing applications.
So I don't think the default should be settable.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
From: Xin Long <lucien.xin@gmail.com> Date: 2019-10-19 08:45:20
On Fri, Oct 18, 2019 at 11:34 PM David Laight [off-list ref] wrote:
From: Xin Long
quoted
Sent: 08 October 2019 12:25
As said in rfc7829, section 3, point 12:
The SCTP stack SHOULD expose the PF state of its destination
addresses to the ULP as well as provide the means to notify the
ULP of state transitions of its destination addresses from
active to PF, and vice versa. However, it is recommended that
an SCTP stack implementing SCTP-PF also allows for the ULP to be
kept ignorant of the PF state of its destinations and the
associated state transitions, thus allowing for retention of the
simpler state transition model of [RFC4960] in the ULP.
Not only does it allow to expose the PF state to ULP, but also
allow to ignore sctp-pf to ULP.
So this patch is to add pf_expose per netns, sock and asoc. And in
sctp_assoc_control_transport(), ulp_notify will be set to false if
asoc->expose is not set.
It also allows a user to change pf_expose per netns by sysctl, and
pf_expose per sock and asoc will be initialized with it.
Note that pf_expose also works for SCTP_GET_PEER_ADDR_INFO sockopt,
to not allow a user to query the state of a sctp-pf peer address
when pf_expose is not enabled, as said in section 7.3.
@@ -1220,6 +1220,9 @@ static int __net_init sctp_defaults_init(struct net *net)/* Enable pf state by default */net->sctp.pf_enable=1;+/* Enable pf state exposure by default */+net->sctp.pf_expose=1;+
For compatibility with existing applications pf_expose MUST default to 0.
I'm not even sure it makes sense to have a sysctl for it.
You're reivewing v2, pls go and check v3 where it's:
net->sctp.pf_expose = SCTP_PF_EXPOSE_UNUSED
...
quoted
@@ -5521,8 +5522,15 @@ static int sctp_getsockopt_peer_addr_info(struct sock *sk, int len, transport = sctp_addr_id2transport(sk, &pinfo.spinfo_address, pinfo.spinfo_assoc_id);- if (!transport)- return -EINVAL;+ if (!transport) {+ retval = -EINVAL;+ goto out;+ }++ if (transport->state == SCTP_PF && !transport->asoc->pf_expose) {+ retval = -EACCES;+ goto out;+ }
Ugg...
To avoid reporting the unexpected 'SCTP_PF' state you probable need
to lie about the state (probably reporting 'working' - or whatever state
it would be in if PF detection wasn't enabled.
return EACCES is from RFC. see v3 where it's become:
+ if (transport->state == SCTP_PF &&
+ transport->asoc->pf_expose == SCTP_PF_EXPOSE_DISABLE) {
+ retval = -EACCES;
+ goto out;
+ }
no more compatibility issue.
From: David Laight <hidden> Date: 2019-10-22 11:29:16
From: Xin Long <lucien.xin@gmail.com>
Sent: 19 October 2019 09:45
On Fri, Oct 18, 2019 at 11:34 PM David Laight [off-list ref] wrote:
quoted
From: Xin Long
quoted
Sent: 08 October 2019 12:25
As said in rfc7829, section 3, point 12:
The SCTP stack SHOULD expose the PF state of its destination
addresses to the ULP as well as provide the means to notify the
ULP of state transitions of its destination addresses from
active to PF, and vice versa. However, it is recommended that
an SCTP stack implementing SCTP-PF also allows for the ULP to be
kept ignorant of the PF state of its destinations and the
associated state transitions, thus allowing for retention of the
simpler state transition model of [RFC4960] in the ULP.
Not only does it allow to expose the PF state to ULP, but also
allow to ignore sctp-pf to ULP.
So this patch is to add pf_expose per netns, sock and asoc. And in
sctp_assoc_control_transport(), ulp_notify will be set to false if
asoc->expose is not set.
It also allows a user to change pf_expose per netns by sysctl, and
pf_expose per sock and asoc will be initialized with it.
Note that pf_expose also works for SCTP_GET_PEER_ADDR_INFO sockopt,
to not allow a user to query the state of a sctp-pf peer address
when pf_expose is not enabled, as said in section 7.3.
@@ -1220,6 +1220,9 @@ static int __net_init sctp_defaults_init(struct net *net)/* Enable pf state by default */net->sctp.pf_enable=1;+/* Enable pf state exposure by default */+net->sctp.pf_expose=1;+
For compatibility with existing applications pf_expose MUST default to 0.
I'm not even sure it makes sense to have a sysctl for it.
You're reivewing v2, pls go and check v3 where it's:
net->sctp.pf_expose = SCTP_PF_EXPOSE_UNUSED
I'll dig out that tri-state logic again later.
quoted
...
quoted
@@ -5521,8 +5522,15 @@ static int sctp_getsockopt_peer_addr_info(struct sock *sk, int len, transport = sctp_addr_id2transport(sk, &pinfo.spinfo_address, pinfo.spinfo_assoc_id);- if (!transport)- return -EINVAL;+ if (!transport) {+ retval = -EINVAL;+ goto out;+ }++ if (transport->state == SCTP_PF && !transport->asoc->pf_expose) {+ retval = -EACCES;+ goto out;+ }
Ugg...
To avoid reporting the unexpected 'SCTP_PF' state you probable need
to lie about the state (probably reporting 'working' - or whatever state
it would be in if PF detection wasn't enabled.
return EACCES is from RFC. see v3 where it's become:
+ if (transport->state == SCTP_PF &&
+ transport->asoc->pf_expose == SCTP_PF_EXPOSE_DISABLE) {
+ retval = -EACCES;
+ goto out;
+ }
no more compatibility issue.
Hmmm....
Never mind what the RFC says about returning EACCESS, that
is still an API change.
Setting this will break existing applications.
So I don't think the default should be settable.
If the user sets this new sysctl, he must have realized what's going to happen.
I don't think this will cause "compatibility issue".
The problem is that support is application dependant, not system dependant.
All it takes is a distro to decide to default to enabling it and all old apps break.
Given the application has to enable other things there is no reason not to
require this to be enabled by every application that wants to see the events (etc).
Note that this is different from doing the protocol part of PF - which is likely
to help applications when the 'primary' path is dodgy.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)