Skip to contentSkip to conversation

net: sctp: dynamically enable or disable pf state

PATCH Superseded [email protected] 3 participants 3 messages Dec 11, 2015 – Dec 14, 2015

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: sctp: dynamically enable or disable pf state

From: Zhu Yanjun <[email protected]>

As we all know, the vale of pf_retrans >= max_retrans_path can disable pf state. The variables of pf_retrans and max_retrans_path can be changed by the user space application.

Sometimes the user expects to disable pf state while the 2 variables are changed to enable pf state. So it is necessary to introduce a new variable to disable pf state.

---
 Documentation/networking/ip-sysctl.txt |   17 +++++++++++++++++
 include/net/netns/sctp.h               |    7 +++++++
 net/sctp/sm_sideeffect.c               |    5 ++++-
 net/sctp/sysctl.c                      |    9 +++++++++
 4 files changed, 37 insertions(+), 1 deletion(-)
Documentation/networking/ip-sysctl.txt +17 -0
index f647900..7195c24 100644
@@ -1723,6 +1723,23 @@ addip_enable - BOOLEAN
 
 	Default: 0
 
+pf_enable - INTEGER
+	Enable or disable pf state. A value of pf_retrans > path_max_retrans
+	also disables pf state. That is, one of both pf_enable and
+	pf_retrans > path_max_retrans can disable pf state. Since pf_retrans
+	and path_max_retrans can be changed by userspace application, sometimes
+	user expects to disable pf state by the value of
+	pf_retrans > path_max_retrans, but ocassionally the value of pf_retrans
+	or path_max_retrans is changed by the user application, this pf state is
+	enabled. As such, it is necessary to add this to dynamically enable
+	and disable pf state.
+
+	1: Enable pf.
+
+	0: Disable pf.
+
+	Default: 1
+
 addip_noauth_enable - BOOLEAN
 	Dynamic Address Reconfiguration (ADD-IP) requires the use of
 	authentication to protect the operations of adding or removing new
include/net/netns/sctp.h +7 -0
index 8ba379f..c501d67 100644
@@ -89,6 +89,13 @@ struct netns_sctp {
 	int pf_retrans;
 
 	/*
+	 * Disable Potentially-Failed feature, the feature is enabled by default
+	 * pf_enable	-  0  : disable pf
+	 *		- >0  : enable pf
+	 */
+	int pf_enable;
+
+	/*
 	 * 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
net/sctp/sm_sideeffect.c +4 -1
index 6098d4c..50309ed 100644
@@ -477,6 +477,8 @@ static void sctp_do_8_2_transport_strike(sctp_cmd_seq_t *commands,
 					 struct sctp_transport *transport,
 					 int is_hb)
 {
+	struct net *net = sock_net(asoc->base.sk);
+
 	/* The check for association's overall error counter exceeding the
 	 * threshold is done in the state function.
 	 */
@@ -503,7 +505,8 @@ static void sctp_do_8_2_transport_strike(sctp_cmd_seq_t *commands,
 	 * is SCTP_ACTIVE, then mark this transport as Partially Failed,
 	 * see SCTP Quick Failover Draft, section 5.1
 	 */
-	if ((transport->state = SCTP_ACTIVE) &&
+	if (net->sctp.pf_enable &&
+	   (transport->state = SCTP_ACTIVE) &&
 	   (asoc->pf_retrans < transport->pathmaxrxt) &&
 	   (transport->error_count > asoc->pf_retrans)) {
 
net/sctp/sysctl.c +9 -0
index 26d50c5..0a4f402 100644
@@ -308,6 +308,15 @@ static struct ctl_table sctp_net_table[] = {
 		.extra1		= &max_autoclose_min,
 		.extra2		= &max_autoclose_max,
 	},
+	{
+		.procname	= "pf_enable",
+		.data		= &init_net.sctp.pf_enable,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+		.extra1		= &one,
+		.extra2		= &int_max
+	},
 
 	{ /* sentinel */ }
 };
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 32 lines · On 12/11/2015 04:05 AM, [email protected] wrote:

From: Zhu Yanjun <[email protected]>

As we all know, the vale of pf_retrans >= max_retrans_path can disable pf state. The variables of pf_retrans and max_retrans_path can be changed by the user space application.

Sometimes the user expects to disable pf state while the 2 variables are changed to enable pf state. So it is necessary to introduce a new variable to disable pf state.

---
 Documentation/networking/ip-sysctl.txt |   17 +++++++++++++++++
 include/net/netns/sctp.h               |    7 +++++++
 net/sctp/sm_sideeffect.c               |    5 ++++-
 net/sctp/sysctl.c                      |    9 +++++++++
 4 files changed, 37 insertions(+), 1 deletion(-)
Documentation/networking/ip-sysctl.txt +6 -0
index f647900..7195c24 100644
@@ -1723,6 +1723,23 @@ addip_enable - BOOLEAN
 
 	Default: 0
 
+pf_enable - INTEGER
+	Enable or disable pf state. A value of pf_retrans > path_max_retrans
+	also disables pf state. That is, one of both pf_enable and
+	pf_retrans > path_max_retrans can disable pf state. Since pf_retrans
+	and path_max_retrans can be changed by userspace application, sometimes
+	user expects to disable pf state by the value of

Documentation/networking/ip-sysctl.txt addip_enable - BOOLEAN · line 1741

Quoted 10 lines
Documentation/networking/ip-sysctl.txt +10 -0
+	pf_retrans > path_max_retrans, but ocassionally the value of pf_retrans
+	or path_max_retrans is changed by the user application, this pf state is
+	enabled. As such, it is necessary to add this to dynamically enable
+	and disable pf state.
+
+	1: Enable pf.
+
+	0: Disable pf.
+
+	Default: 1

You never set the default value anywhere in the patch and thus disable PF extension by default.

Quoted 52 lines
Documentation/networking/ip-sysctl.txt +1 -0
+
 addip_noauth_enable - BOOLEAN
 	Dynamic Address Reconfiguration (ADD-IP) requires the use of
 	authentication to protect the operations of adding or removing new
include/net/netns/sctp.h +7 -0
index 8ba379f..c501d67 100644
@@ -89,6 +89,13 @@ struct netns_sctp {
 	int pf_retrans;
 
 	/*
+	 * Disable Potentially-Failed feature, the feature is enabled by default
+	 * pf_enable	-  0  : disable pf
+	 *		- >0  : enable pf
+	 */
+	int pf_enable;
+
+	/*
 	 * 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
net/sctp/sm_sideeffect.c +4 -1
index 6098d4c..50309ed 100644
@@ -477,6 +477,8 @@ static void sctp_do_8_2_transport_strike(sctp_cmd_seq_t *commands,
 					 struct sctp_transport *transport,
 					 int is_hb)
 {
+	struct net *net = sock_net(asoc->base.sk);
+
 	/* The check for association's overall error counter exceeding the
 	 * threshold is done in the state function.
 	 */
@@ -503,7 +505,8 @@ static void sctp_do_8_2_transport_strike(sctp_cmd_seq_t *commands,
 	 * is SCTP_ACTIVE, then mark this transport as Partially Failed,
 	 * see SCTP Quick Failover Draft, section 5.1
 	 */
-	if ((transport->state = SCTP_ACTIVE) &&
+	if (net->sctp.pf_enable &&
+	   (transport->state = SCTP_ACTIVE) &&
 	   (asoc->pf_retrans < transport->pathmaxrxt) &&
 	   (transport->error_count > asoc->pf_retrans)) {
 
net/sctp/sysctl.c +0 -0
index 26d50c5..0a4f402 100644
@@ -308,6 +308,15 @@ static struct ctl_table sctp_net_table[] = {
 		.extra1		= &max_autoclose_min,
 		.extra2		= &max_autoclose_max,

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

Quoted 10 lines
net/sctp/sysctl.c +9 -0
 	},
+	{
+		.procname	= "pf_enable",
+		.data		= &init_net.sctp.pf_enable,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+		.extra1		= &one,
+		.extra2		= &int_max
+	},

extra1 and extra2 above are ignored in proc_dointvec. Don't include them.

-vlad

Quoted 4 lines
net/sctp/sysctl.c +0 -0
 	{ /* sentinel */ }
 };
 
#2 lore raw
In reply to [email protected]

From: [email protected]

Quoted 1 line

Sent: 11 December 2015 09:06

...

Quoted 6 lines
Documentation/networking/ip-sysctl.txt +6 -0
+pf_enable - INTEGER
+	Enable or disable pf state. A value of pf_retrans > path_max_retrans
+	also disables pf state. That is, one of both pf_enable and
+	pf_retrans > path_max_retrans can disable pf state. Since pf_retrans
+	and path_max_retrans can be changed by userspace application, sometimes
+	user expects to disable pf state by the value of

Documentation/networking/ip-sysctl.txt addip_enable - BOOLEAN · line 1741

Quoted 10 lines
Documentation/networking/ip-sysctl.txt +10 -0
+	pf_retrans > path_max_retrans, but ocassionally the value of pf_retrans
+	or path_max_retrans is changed by the user application, this pf state is
+	enabled. As such, it is necessary to add this to dynamically enable
+	and disable pf state.
+
+	1: Enable pf.
+
+	0: Disable pf.
+
+	Default: 1

You ought to say what 'pf' is short for.

David