Skip to contentSkip to conversation

sctp: update from rfc7829

PATCH Superseded Xin Long 3 participants 21 messages Oct 8, 2019 – Oct 22, 2019

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Xin Long

author maintainer
#0 lore raw

v2 cover 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.

Xin Long (5):
sctp: add SCTP_ADDR_POTENTIALLY_FAILED notification
sctp: add pf_expose per netns and sock and asoc
sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt
sctp: add support for Primary Path Switchover
sctp: add SCTP_PEER_ADDR_THLDS_V2 sockopt

 include/net/netns/sctp.h   |  13 +++++
 include/net/sctp/structs.h |  13 ++++-
 include/uapi/linux/sctp.h  |  13 +++++
 net/sctp/associola.c       |  26 ++++-----
 net/sctp/protocol.c        |   6 ++
 net/sctp/sm_sideeffect.c   |   5 ++
 net/sctp/socket.c          | 143 ++++++++++++++++++++++++++++++++++++++++-----
 net/sctp/sysctl.c          |  16 +++++
 8 files changed, 203 insertions(+), 32 deletions(-)
Signature · 1 line
2.1.0
author maintainer
#1 lore raw

PATCH v2 1/5 sctp: add SCTP_ADDR_POTENTIALLY_FAILED notification

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.

---
 include/uapi/linux/sctp.h |  1 +
 net/sctp/associola.c      | 17 ++++-------------
 2 files changed, 5 insertions(+), 13 deletions(-)
include/uapi/linux/sctp.h +1 -0
index 6d5b164..45a85d7 100644
@@ -410,6 +410,7 @@ enum sctp_spc_state {
 	SCTP_ADDR_ADDED,
 	SCTP_ADDR_MADE_PRIM,
 	SCTP_ADDR_CONFIRMED,
+	SCTP_ADDR_POTENTIALLY_FAILED,
 };
 
 
net/sctp/associola.c +4 -13
index d2ffc9a..7278b7e 100644
@@ -798,14 +798,6 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
 			spc_state = SCTP_ADDR_CONFIRMED;
 		else
 			spc_state = SCTP_ADDR_AVAILABLE;
-		/* Don't inform ULP about transition from PF to
-		 * active state and set cwnd to 1 MTU, see SCTP
-		 * Quick failover draft section 5.1, point 5
-		 */
-		if (transport->state = SCTP_PF) {
-			ulp_notify = false;
-			transport->cwnd = asoc->pathmtu;
-		}
 		transport->state = SCTP_ACTIVE;
 		break;
 
@@ -814,19 +806,18 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
 		 * to inactive state.  Also, release the cached route since
 		 * there may be a better route next time.
 		 */
-		if (transport->state != SCTP_UNCONFIRMED)
+		if (transport->state != SCTP_UNCONFIRMED) {
 			transport->state = SCTP_INACTIVE;
-		else {
+			spc_state = SCTP_ADDR_UNREACHABLE;
+		} else {
 			sctp_transport_dst_release(transport);
 			ulp_notify = false;
 		}
-
-		spc_state = SCTP_ADDR_UNREACHABLE;
 		break;
 
 	case SCTP_TRANSPORT_PF:
 		transport->state = SCTP_PF;
-		ulp_notify = false;
+		spc_state = SCTP_ADDR_POTENTIALLY_FAILED;
 		break;
 
 	default:
Signature · 1 line
2.1.0
author maintainer
#2 lore raw

PATCH v2 2/5 sctp: add pf_expose per netns and sock and asoc

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.

---
 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(-)
include/net/netns/sctp.h +7 -0
index bdc0f27..5234940c 100644
@@ -97,6 +97,13 @@ struct netns_sctp {
 	int pf_enable;
 
 	/*
+	 * Disable Potentially-Failed state exposure, enabled by default
+	 * pf_expose	-  0  : disable pf state exposure
+	 *		- >0  : enable  pf state exposure
+	 */
+	int pf_expose;
+
+	/*
 	 * Policy for preforming sctp/socket accounting
 	 * 0   - do socket level accounting, all assocs share sk_sndbuf
 	 * 1   - do sctp accounting, each asoc may use sk_sndbuf bytes
include/net/sctp/structs.h +2 -0
index 503fbc3..c2d3317 100644
@@ -215,6 +215,7 @@ struct sctp_sock {
 	__u32 adaptation_ind;
 	__u32 pd_point;
 	__u16	nodelay:1,
+		pf_expose:1,
 		reuse:1,
 		disable_fragments:1,
 		v4mapped:1,
@@ -2053,6 +2054,7 @@ struct sctp_association {
 
 	__u8 need_ecne:1,	/* Need to send an ECNE Chunk? */
 	     temp:1,		/* Is it a temporary association? */
+	     pf_expose:1,       /* Expose pf state? */
 	     force_delay:1;
 
 	__u8 strreset_enable;
include/uapi/linux/sctp.h +1 -0
index 45a85d7..b6649d6 100644
@@ -920,6 +920,7 @@ struct sctp_paddrinfo {
 enum sctp_spinfo_state {
 	SCTP_INACTIVE,
 	SCTP_PF,
+#define	SCTP_POTENTIALLY_FAILED		SCTP_PF
 	SCTP_ACTIVE,
 	SCTP_UNCONFIRMED,
 	SCTP_UNKNOWN = 0xffff  /* Value used for transport state unknown */
net/sctp/associola.c +7 -1
index 7278b7e..1c30fda 100644
@@ -86,6 +86,7 @@ static struct sctp_association *sctp_association_init(
 	 */
 	asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt;
 	asoc->pf_retrans  = sp->pf_retrans;
+	asoc->pf_expose   = sp->pf_expose;
 
 	asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial);
 	asoc->rto_max = msecs_to_jiffies(sp->rtoinfo.srto_max);
@@ -793,6 +794,8 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
 		 * to heartbeat success, report the SCTP_ADDR_CONFIRMED
 		 * state to the user, otherwise report SCTP_ADDR_AVAILABLE.
 		 */
+		if (transport->state = SCTP_PF && !asoc->pf_expose)
+			ulp_notify = false;
 		if (SCTP_UNCONFIRMED = transport->state &&
 		    SCTP_HEARTBEAT_SUCCESS = error)
 			spc_state = SCTP_ADDR_CONFIRMED;
@@ -817,7 +820,10 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
 
 	case SCTP_TRANSPORT_PF:
 		transport->state = SCTP_PF;
-		spc_state = SCTP_ADDR_POTENTIALLY_FAILED;
+		if (!asoc->pf_expose)
+			ulp_notify = false;
+		else
+			spc_state = SCTP_ADDR_POTENTIALLY_FAILED;
 		break;
 
 	default:
net/sctp/protocol.c +3 -0
index 08d14d8..a303011 100644
@@ -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         - 5  attempts (per destination address)
 	 * Max.Init.Retransmits     - 8  attempts
net/sctp/socket.c +10 -2
index 939b8d2..8d27434 100644
@@ -5041,6 +5041,7 @@ static int sctp_init_sock(struct sock *sk)
 	sp->hbinterval  = net->sctp.hb_interval;
 	sp->pathmaxrxt  = net->sctp.max_retrans_path;
 	sp->pf_retrans  = net->sctp.pf_retrans;
+	sp->pf_expose   = net->sctp.pf_expose;
 	sp->pathmtu     = 0; /* allow default discovery */
 	sp->sackdelay   = net->sctp.sack_timeout;
 	sp->sackfreq	= 2;
@@ -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;
+	}
 
 	pinfo.spinfo_assoc_id = sctp_assoc2id(transport->asoc);
 	pinfo.spinfo_state = transport->state;
net/sctp/sysctl.c +7 -0
index 238cf17..eacc9a1 100644
@@ -318,6 +318,13 @@ static struct ctl_table sctp_net_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
+	{
+		.procname	= "pf_expose",
+		.data		= &init_net.sctp.pf_expose,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
 
 	{ /* sentinel */ }
 };
Signature · 1 line
2.1.0
author maintainer
#3 lore raw

PATCH v2 3/5 sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

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.

---
 include/uapi/linux/sctp.h |  1 +
 net/sctp/socket.c         | 76 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+)
include/uapi/linux/sctp.h +1 -0
index b6649d6..a15cc28 100644
@@ -137,6 +137,7 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_ASCONF_SUPPORTED	128
 #define SCTP_AUTH_SUPPORTED	129
 #define SCTP_ECN_SUPPORTED	130
+#define SCTP_EXPOSE_POTENTIALLY_FAILED_STATE	131
 
 /* PR-SCTP policies */
 #define SCTP_PR_SCTP_NONE	0x0000
net/sctp/socket.c +76 -0

100 lines not on this page · raw message

Signature · 1 line
2.1.0
author maintainer
#4 lore raw

PATCH v2 4/5 sctp: add support for Primary Path Switchover

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.

---
 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(-)
include/net/netns/sctp.h +6 -0
index 5234940c..cab0903 100644
@@ -89,6 +89,12 @@ struct netns_sctp {
 	 */
 	int pf_retrans;
 
+	/* Primary.Switchover.Max.Retrans sysctl value
+	 * taken from:
+	 * https://tools.ietf.org/html/rfc7829
+	 */
+	int ps_retrans;
+
 	/*
 	 * Disable Potentially-Failed feature, the feature is enabled by default
 	 * pf_enable	-  0  : disable pf
include/net/sctp/structs.h +8 -3
index c2d3317..3680a93 100644
@@ -184,7 +184,8 @@ struct sctp_sock {
 	__u32 flowlabel;
 	__u8  dscp;
 
-	int pf_retrans;
+	__u16 pf_retrans;
+	__u16 ps_retrans;
 
 	/* The initial Path MTU to use for new associations. */
 	__u32 pathmtu;
@@ -897,7 +898,9 @@ struct sctp_transport {
 	 * and will be initialized from the assocs value.  This can be changed
 	 * using the SCTP_PEER_ADDR_THLDS socket option
 	 */
-	int pf_retrans;
+	__u16 pf_retrans;
+	/* Used for primary path switchover. */
+	__u16 ps_retrans;
 	/* PMTU	      : The current known path MTU.  */
 	__u32 pathmtu;
 
@@ -1773,7 +1776,9 @@ struct sctp_association {
 	 * and will be initialized from the assocs value.  This can be
 	 * changed using the SCTP_PEER_ADDR_THLDS socket option
 	 */
-	int pf_retrans;
+	__u16 pf_retrans;
+	/* Used for primary path switchover. */
+	__u16 ps_retrans;
 
 	/* Maximum number of times the endpoint will retransmit INIT  */
 	__u16 max_init_attempts;
net/sctp/associola.c +3 -0
index 1c30fda..8aaa7c3 100644
@@ -86,6 +86,7 @@ static struct sctp_association *sctp_association_init(
 	 */
 	asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt;
 	asoc->pf_retrans  = sp->pf_retrans;
+	asoc->ps_retrans  = sp->ps_retrans;
 	asoc->pf_expose   = sp->pf_expose;
 
 	asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial);
@@ -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
 	 * association configured value.
net/sctp/protocol.c +3 -0
index a303011..84a3d75 100644
@@ -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;
 
net/sctp/sm_sideeffect.c +5 -0
index e52b212..acd737d 100644
@@ -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, set RTO <- RTO * 2 ("back off the timer").  The
 	 * maximum value discussed in rule C7 above (RTO.max) may be
net/sctp/socket.c +1 -0
index 82faf78..7dfb2c5 100644
@@ -5075,6 +5075,7 @@ static int sctp_init_sock(struct sock *sk)
 	sp->hbinterval  = net->sctp.hb_interval;
 	sp->pathmaxrxt  = net->sctp.max_retrans_path;
 	sp->pf_retrans  = net->sctp.pf_retrans;
+	sp->ps_retrans  = net->sctp.ps_retrans;
 	sp->pf_expose   = net->sctp.pf_expose;
 	sp->pathmtu     = 0; /* allow default discovery */
 	sp->sackdelay   = net->sctp.sack_timeout;
net/sctp/sysctl.c +9 -0
index eacc9a1..c9ebfc2 100644
@@ -212,6 +212,15 @@ static struct ctl_table sctp_net_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec_minmax,
 		.extra1		= SYSCTL_ZERO,
+		.extra2		= &init_net.sctp.ps_retrans,
+	},
+	{
+		.procname	= "ps_retrans",
+		.data		= &init_net.sctp.ps_retrans,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &init_net.sctp.pf_retrans,
 		.extra2		= SYSCTL_INT_MAX,
 	},
 	{
Signature · 1 line
2.1.0
author maintainer
#5 lore raw

PATCH v2 5/5 sctp: add SCTP_PEER_ADDR_THLDS_V2 sockopt

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.

---
 include/uapi/linux/sctp.h | 10 +++++++++
 net/sctp/socket.c         | 54 +++++++++++++++++++++++++++++++++++------------
 2 files changed, 50 insertions(+), 14 deletions(-)
include/uapi/linux/sctp.h +10 -0
index a15cc28..7974257 100644
@@ -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
  * implemented using these socket options.
@@ -1071,6 +1072,15 @@ struct sctp_paddrthlds {
 	__u16 spt_pathpfthld;
 };
 
+/* Use a new structure with spt_pathcpthld for back compatibility */
+struct sctp_paddrthlds_v2 {
+	sctp_assoc_t spt_assoc_id;
+	struct sockaddr_storage spt_address;
+	__u16 spt_pathmaxrxt;
+	__u16 spt_pathpfthld;
+	__u16 spt_pathcpthld;
+};
+
 /*
  * Socket Option for Getting the Association/Stream-Specific PR-SCTP Status
  */
net/sctp/socket.c +40 -14

130 lines not on this page · raw message

Signature · 1 line
2.1.0
#6 lore raw

RE: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

In reply to Xin Long

From: Xin Long

Quoted 5 lines

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)

author maintainer
#7 lore raw

Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

Quoted 8 lines · David Laight

From: Xin Long

Quoted 5 lines

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.

Quoted 5 lines

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.

Quoted 7 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#8 lore raw

Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

Quoted 9 lines · Xin Long
Quoted 8 lines · David Laight

From: Xin Long

Quoted 5 lines

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.

Quoted 7 lines
Quoted 5 lines

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 8 lines
Quoted 7 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

author maintainer
#9 lore raw

Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

Quoted 18 lines · Neil Horman
Quoted 9 lines · Xin Long
Quoted 8 lines · David Laight

From: Xin Long

Quoted 5 lines

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.

Quoted 7 lines
Quoted 5 lines

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.

Quoted 7 lines

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().

Quoted 11 lines

Neil

Quoted 8 lines
Quoted 7 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#10 lore raw

Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

Quoted 26 lines · Xin Long
Quoted 18 lines · Neil Horman
Quoted 9 lines · Xin Long
Quoted 8 lines · David Laight

From: Xin Long

Quoted 5 lines

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.

Quoted 7 lines
Quoted 5 lines

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.

Quoted 7 lines

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?

Quoted 8 lines

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 12 lines
Quoted 11 lines

Neil

Quoted 8 lines
Quoted 7 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

author maintainer
#11 lore raw

Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

Quoted 31 lines · Neil Horman
Quoted 29 lines · Xin Long
Quoted 18 lines · Neil Horman
Quoted 9 lines · Xin Long
Quoted 8 lines · David Laight

From: Xin Long

Quoted 5 lines

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.

Quoted 7 lines
Quoted 5 lines

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.

Quoted 7 lines

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.

Quoted 8 lines
Quoted 5 lines

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?

Quoted 15 lines

Neil

Quoted 12 lines
Quoted 11 lines

Neil

Quoted 8 lines
Quoted 7 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

author maintainer
#12 lore raw

Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

Quoted 46 lines · Xin Long
Quoted 31 lines · Neil Horman
Quoted 29 lines · Xin Long
Quoted 18 lines · Neil Horman
Quoted 9 lines · Xin Long
Quoted 8 lines · David Laight

From: Xin Long

Quoted 5 lines

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.

Quoted 7 lines
Quoted 5 lines

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.

Quoted 7 lines

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.

Quoted 8 lines
Quoted 5 lines

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

Quoted 6 lines

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 16 lines
Quoted 16 lines

Neil

Quoted 12 lines
Quoted 11 lines

Neil

Quoted 8 lines
Quoted 7 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#13 lore raw

Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

Quoted 52 lines · Xin Long
Quoted 51 lines · Xin Long
Quoted 31 lines · Neil Horman
Quoted 29 lines · Xin Long
Quoted 18 lines · Neil Horman
Quoted 9 lines · Xin Long
Quoted 8 lines · David Laight

From: Xin Long

Quoted 5 lines

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.

Quoted 7 lines
Quoted 5 lines

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.

Quoted 7 lines

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.

Quoted 8 lines
Quoted 5 lines

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

Quoted 7 lines
Quoted 1 line

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 17 lines
Quoted 16 lines
Quoted 16 lines

Neil

Quoted 12 lines
Quoted 11 lines

Neil

Quoted 8 lines
Quoted 7 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

author maintainer
#14 lore raw

Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

In reply to Neil Horman
Quoted 15 lines · Neil Horman
Quoted 13 lines · Xin Long
Quoted 12 lines · David Laight

From: Xin Long

Quoted 5 lines

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?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

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?

Quoted 14 lines

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 8 lines
Quoted 7 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#15 lore raw

RE: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

RnJvbTogWGluIExvbmcgPGx1Y2llbi54aW5AZ21haWwuY29tPg0KPiBTZW50OiAxNCBPY3RvYmVy IDIwMTkgMDk6MzcNCi4uLg0KPiBSRkMgYWN0dWFsbHkga2VlcHMgYWRkaW5nIG5ldyBub3RpZmlj YXRpb25zLA0KDQpUaGF0IFJGQyBrZWVwcyBtb3ZpbmcgdGhlIGdvYWxwb3N0cy4NCkV2ZW4gdGhl IHN0cnVjdHVyZXMgYXJlIGd1YXJhbnRlZWQgdG8gaGF2ZSBob2xlcy4NCg0KPiBhbmQgYSB1c2Vy IHNob3VsZG4ndCBleHBlY3QNCj4gdGhlIHNwZWNpZmljIG5vdGlmaWNhdGlvbnMgY29taW5nIGlu IHNvbWUgZXhhY3Qgb3JkZXJzLiBUaGV5IHNob3VsZCBqdXN0DQo+IGlnbm9yZSBpdCBhbmQgd2Fp dCB1bnRpbCB0aGUgb25lcyB0aGV5IGV4cGVjdC4gSSBkb24ndCB0aGluayBzb21lIHVzZXJzDQo+ IHdvdWxkIGFib3J0IGl0cyBhcHBsaWNhdGlvbiB3aGVuIGdldHRpbmcgYW4gdW5leHBlY3RlZCBu b3RpZmljYXRpb24uDQoNCkkndmUgYW4gZXhhbXBsZSBvZiBleGFjdGx5IDEgYXBwbGljYXRpb24u DQpJdCB1c2VzIFRDUC1zdHlsZSBzb2NrZXRzIChhbmQgd2lsbCB3b3JrIG92ZXIgVENQKS4NCkl0 IGRvZXMgZ2V0c29ja29wdChTQ1RQX0VWRU5UUyksIHNldHMgc2N0cF9hc3NvY2lhdGlvbl9ldmVu dCwgdGhlbiBzZXRzb2Nrb3B0KCkuDQpBbnkgTVNHX05PVElGSUNBVElPTiBpcyBhc3N1bWVkIHRv IGJlIHRoZSBhIGNvbm5lY3Rpb24gcmVzZXQgKGVuYWJsZWQgYWJvdmUpDQphbmQgdHJlYXRlZCBh cyBhbiBpbndhcmRzIGRpc2Nvbm5lY3QuDQoNClNvIGFueSB1bmV4cGVjdGVkIG5vdGlmaWNhdGlv biB3aWxsIGtpbGwgdGhlIGNvbm5lY3Rpb24uDQoNCkkgc3VzcGVjdCBpdCBpc24ndCB0aGUgb25s eSBvbmUuLg0KDQoJRGF2aWQNCg0KLQ0KUmVnaXN0ZXJlZCBBZGRyZXNzIExha2VzaWRlLCBCcmFt bGV5IFJvYWQsIE1vdW50IEZhcm0sIE1pbHRvbiBLZXluZXMsIE1LMSAxUFQsIFVLDQpSZWdpc3Ry YXRpb24gTm86IDEzOTczODYgKFdhbGVzKQ0K

#16 lore raw

Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

In reply to Xin Long
Quoted 19 lines · Xin Long
Quoted 18 lines · Neil Horman
Quoted 16 lines · Xin Long
Quoted 8 lines · David Laight

From: Xin Long

Quoted 5 lines

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.

Quoted 5 lines

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.

Quoted 9 lines
Quoted 4 lines

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 5 lines

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 2 lines

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 15 lines
Quoted 14 lines

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 8 lines
Quoted 7 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#17 lore raw

RE: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

From: Neil Horman <[email protected]>

Quoted 49 lines

Sent: 14 October 2019 13:42
To: Xin Long <[email protected]>
Cc: David Laight <[email protected]>; network dev <[email protected]>; [email protected]; Marcelo Ricardo Leitner <[email protected]>; [email protected]
Subject: Re: [PATCHv2 net-next 3/5] sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt

Quoted 19 lines · Xin Long
Quoted 18 lines · Neil Horman
Quoted 16 lines · Xin Long
Quoted 8 lines · David Laight

From: Xin Long

Quoted 5 lines

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.

Quoted 5 lines

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.

Quoted 9 lines
Quoted 4 lines

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 5 lines

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 5 lines
Quoted 2 lines

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)

#18 lore raw

RE: [PATCHv2 net-next 2/5] sctp: add pf_expose per netns and sock and asoc

In reply to Xin Long

From: Xin Long

Quoted 25 lines

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.

...

net/sctp/protocol.c static int __net_init sctp_defaults_init(struct net *net) · line 1225

Quoted 10 lines

index 08d14d8..a303011 100644

net/sctp/protocol.c +3 -0
@@ -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 5 lines
net/sctp/protocol.c +0 -1
@@ -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)

net/sctp/protocol.c static int sctp_getsockopt_peer_addr_info(struct sock *sk, int len, · line 5533

Quoted 10 lines
net/sctp/protocol.c +9 -1
-		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.

...

net/sctp/sysctl.c static struct ctl_table sctp_net_table[] = { · line 327

Quoted 13 lines
net/sctp/sysctl.c +7 -0
@@ -318,6 +318,13 @@ static struct ctl_table sctp_net_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
+	{
+		.procname	= "pf_expose",
+		.data		= &init_net.sctp.pf_expose,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},

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)

author maintainer
#19 lore raw

Re: [PATCHv2 net-next 2/5] sctp: add pf_expose per netns and sock and asoc

Quoted 35 lines · David Laight

From: Xin Long

Quoted 25 lines

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.

...

Quoted 7 lines

index 08d14d8..a303011 100644

net/sctp/protocol.c +0 -0
@@ -1220,6 +1220,9 @@ static int __net_init sctp_defaults_init(struct net *net)
      /* Enable pf state by default */
      net->sctp.pf_enable = 1;
 
Quoted 6 lines

net/sctp/protocol.c static int __net_init sctp_defaults_init(struct net *net) · line 1225

Quoted 3 lines
net/sctp/protocol.c +3 -0
+     /* 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 14 lines

...

Quoted 12 lines
net/sctp/protocol.c +6 -2
@@ -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) {
Quoted 8 lines

net/sctp/protocol.c static int sctp_getsockopt_peer_addr_info(struct sock *sk, int len, · line 5533

Quoted 3 lines
net/sctp/protocol.c +3 -0
+             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.

Quoted 18 lines

...

net/sctp/sysctl.c static struct ctl_table sctp_net_table[] = { · line 327

Quoted 13 lines
net/sctp/sysctl.c +7 -0
@@ -318,6 +318,13 @@ static struct ctl_table sctp_net_table[] = {
              .mode           = 0644,
              .proc_handler   = proc_dointvec,
      },
+     {
+             .procname       = "pf_expose",
+             .data           = &init_net.sctp.pf_expose,
+             .maxlen         = sizeof(int),
+             .mode           = 0644,
+             .proc_handler   = proc_dointvec,
+     },

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".

Quoted 7 lines

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK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