* [PATCH v7 0/3] sctp: check the rto_min and rto_max
@ 2013-12-11 1:50 Wang Weidong
2013-12-11 1:50 ` [PATCH v7 1/3] sctp: check the rto_min and rto_max in setsockopt Wang Weidong
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Wang Weidong @ 2013-12-11 1:50 UTC (permalink / raw)
To: vyasevich, nhorman, davem; +Cc: dborkman, netdev, linux-sctp
v6 -> v7:
-patch2: fix the whitespace issues which pointed out by Daniel
v5 -> v6:
split the v5' first patch to patch1 and patch2, and remove the
macro in constants.h
-patch1: do rto_min/max socket option handling in its own patch, and
fix the check of rto_min/max.
-patch2: do rto_min/max sysctl handling in its own patch.
-patch3: add Suggested-by Daniel.
v4 -> v5:
- patch1: add marco in constants.h and fix up spacing as
suggested by Daniel
- patch2: add a patch for fix up do_hmac_alg for according
to do_rto_min[max]
v3 -> v4:
-patch1: fix use init_net directly which suggested by Vlad.
v2 -> v3:
-patch1: add proc_handler for check rto_min and rto_max which suggested
by Vlad
v1 -> v2:
-patch1: fix the From Name which pointed out by David, and
add the ACK by Neil
Wang Weidong (3):
sctp: check the rto_min and rto_max in setsockopt
sctp: add check rto_min and rto_max in sysctl
sctp: fix up a spacing
net/sctp/socket.c | 32 +++++++++++++++--------
net/sctp/sysctl.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 89 insertions(+), 19 deletions(-)
--
1.7.12
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v7 1/3] sctp: check the rto_min and rto_max in setsockopt
2013-12-11 1:50 [PATCH v7 0/3] sctp: check the rto_min and rto_max Wang Weidong
@ 2013-12-11 1:50 ` Wang Weidong
2013-12-11 1:50 ` [PATCH v7 2/3] sctp: add check rto_min and rto_max in sysctl Wang Weidong
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Wang Weidong @ 2013-12-11 1:50 UTC (permalink / raw)
To: vyasevich, nhorman, davem; +Cc: dborkman, netdev, linux-sctp
When we set 0 to rto_min or rto_max, just not change the value. Also
we should check the rto_min > rto_max.
Suggested-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
net/sctp/socket.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 72046b9..da09e59 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2811,6 +2811,8 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
{
struct sctp_rtoinfo rtoinfo;
struct sctp_association *asoc;
+ unsigned long rto_min, rto_max;
+ struct sctp_sock *sp = sctp_sk(sk);
if (optlen != sizeof (struct sctp_rtoinfo))
return -EINVAL;
@@ -2824,26 +2826,36 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
if (!asoc && rtoinfo.srto_assoc_id && sctp_style(sk, UDP))
return -EINVAL;
+ rto_max = rtoinfo.srto_max;
+ rto_min = rtoinfo.srto_min;
+
+ if (rto_max)
+ rto_max = asoc ? msecs_to_jiffies(rto_max) : rto_max;
+ else
+ rto_max = asoc ? asoc->rto_max : sp->rtoinfo.srto_max;
+
+ if (rto_min)
+ rto_min = asoc ? msecs_to_jiffies(rto_min) : rto_min;
+ else
+ rto_min = asoc ? asoc->rto_min : sp->rtoinfo.srto_min;
+
+ if (rto_min > rto_max)
+ return -EINVAL;
+
if (asoc) {
if (rtoinfo.srto_initial != 0)
asoc->rto_initial =
msecs_to_jiffies(rtoinfo.srto_initial);
- if (rtoinfo.srto_max != 0)
- asoc->rto_max = msecs_to_jiffies(rtoinfo.srto_max);
- if (rtoinfo.srto_min != 0)
- asoc->rto_min = msecs_to_jiffies(rtoinfo.srto_min);
+ asoc->rto_max = rto_max;
+ asoc->rto_min = rto_min;
} else {
/* If there is no association or the association-id = 0
* set the values to the endpoint.
*/
- struct sctp_sock *sp = sctp_sk(sk);
-
if (rtoinfo.srto_initial != 0)
sp->rtoinfo.srto_initial = rtoinfo.srto_initial;
- if (rtoinfo.srto_max != 0)
- sp->rtoinfo.srto_max = rtoinfo.srto_max;
- if (rtoinfo.srto_min != 0)
- sp->rtoinfo.srto_min = rtoinfo.srto_min;
+ sp->rtoinfo.srto_max = rto_max;
+ sp->rtoinfo.srto_min = rto_min;
}
return 0;
--
1.7.12
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v7 2/3] sctp: add check rto_min and rto_max in sysctl
2013-12-11 1:50 [PATCH v7 0/3] sctp: check the rto_min and rto_max Wang Weidong
2013-12-11 1:50 ` [PATCH v7 1/3] sctp: check the rto_min and rto_max in setsockopt Wang Weidong
@ 2013-12-11 1:50 ` Wang Weidong
2013-12-11 1:50 ` [PATCH v7 3/3] sctp: fix up a spacing Wang Weidong
2013-12-11 2:41 ` [PATCH v7 0/3] sctp: check the rto_min and rto_max Vlad Yasevich
3 siblings, 0 replies; 6+ messages in thread
From: Wang Weidong @ 2013-12-11 1:50 UTC (permalink / raw)
To: vyasevich, nhorman, davem; +Cc: dborkman, netdev, linux-sctp
rto_min should be smaller than rto_max while rto_max should be larger
than rto_min. Add two proc_handler for the checking.
Suggested-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
net/sctp/sysctl.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 65 insertions(+), 4 deletions(-)
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 6b36561..43b5e32 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -61,6 +61,13 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
void __user *buffer, size_t *lenp,
loff_t *ppos);
+static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
+ void __user *buffer, size_t *lenp,
+ loff_t *ppos);
+static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
+ void __user *buffer, size_t *lenp,
+ loff_t *ppos);
+
static struct ctl_table sctp_table[] = {
{
.procname = "sctp_mem",
@@ -102,17 +109,17 @@ static struct ctl_table sctp_net_table[] = {
.data = &init_net.sctp.rto_min,
.maxlen = sizeof(unsigned int),
.mode = 0644,
- .proc_handler = proc_dointvec_minmax,
+ .proc_handler = proc_sctp_do_rto_min,
.extra1 = &one,
- .extra2 = &timer_max
+ .extra2 = &init_net.sctp.rto_max
},
{
.procname = "rto_max",
.data = &init_net.sctp.rto_max,
.maxlen = sizeof(unsigned int),
.mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = &one,
+ .proc_handler = proc_sctp_do_rto_max,
+ .extra1 = &init_net.sctp.rto_min,
.extra2 = &timer_max
},
{
@@ -342,6 +349,60 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
return ret;
}
+static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
+ void __user *buffer, size_t *lenp,
+ loff_t *ppos)
+{
+ struct net *net = current->nsproxy->net_ns;
+ int new_value;
+ struct ctl_table tbl;
+ unsigned int min = *(unsigned int *) ctl->extra1;
+ unsigned int max = *(unsigned int *) ctl->extra2;
+ int ret;
+
+ memset(&tbl, 0, sizeof(struct ctl_table));
+ tbl.maxlen = sizeof(unsigned int);
+
+ if (write)
+ tbl.data = &new_value;
+ else
+ tbl.data = &net->sctp.rto_min;
+ ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
+ if (write) {
+ if (ret || new_value > max || new_value < min)
+ return -EINVAL;
+ net->sctp.rto_min = new_value;
+ }
+ return ret;
+}
+
+static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
+ void __user *buffer, size_t *lenp,
+ loff_t *ppos)
+{
+ struct net *net = current->nsproxy->net_ns;
+ int new_value;
+ struct ctl_table tbl;
+ unsigned int min = *(unsigned int *) ctl->extra1;
+ unsigned int max = *(unsigned int *) ctl->extra2;
+ int ret;
+
+ memset(&tbl, 0, sizeof(struct ctl_table));
+ tbl.maxlen = sizeof(unsigned int);
+
+ if (write)
+ tbl.data = &new_value;
+ else
+ tbl.data = &net->sctp.rto_max;
+ ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
+ if (write) {
+ if (ret || new_value > max || new_value < min)
+ return -EINVAL;
+ net->sctp.rto_max = new_value;
+ }
+ return ret;
+}
+
int sctp_sysctl_net_register(struct net *net)
{
struct ctl_table *table;
--
1.7.12
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v7 3/3] sctp: fix up a spacing
2013-12-11 1:50 [PATCH v7 0/3] sctp: check the rto_min and rto_max Wang Weidong
2013-12-11 1:50 ` [PATCH v7 1/3] sctp: check the rto_min and rto_max in setsockopt Wang Weidong
2013-12-11 1:50 ` [PATCH v7 2/3] sctp: add check rto_min and rto_max in sysctl Wang Weidong
@ 2013-12-11 1:50 ` Wang Weidong
2013-12-11 2:41 ` [PATCH v7 0/3] sctp: check the rto_min and rto_max Vlad Yasevich
3 siblings, 0 replies; 6+ messages in thread
From: Wang Weidong @ 2013-12-11 1:50 UTC (permalink / raw)
To: vyasevich, nhorman, davem; +Cc: dborkman, netdev, linux-sctp
fix up spacing of proc_sctp_do_hmac_alg for according to the
proc_sctp_do_rto_min[max] in sysctl.c
Suggested-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
net/sctp/sysctl.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 43b5e32..b0565af 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -56,10 +56,8 @@ extern long sysctl_sctp_mem[3];
extern int sysctl_sctp_rmem[3];
extern int sysctl_sctp_wmem[3];
-static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
- int write,
+static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp,
-
loff_t *ppos);
static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp,
@@ -301,8 +299,7 @@ static struct ctl_table sctp_net_table[] = {
{ /* sentinel */ }
};
-static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
- int write,
+static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
{
--
1.7.12
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v7 0/3] sctp: check the rto_min and rto_max
2013-12-11 1:50 [PATCH v7 0/3] sctp: check the rto_min and rto_max Wang Weidong
` (2 preceding siblings ...)
2013-12-11 1:50 ` [PATCH v7 3/3] sctp: fix up a spacing Wang Weidong
@ 2013-12-11 2:41 ` Vlad Yasevich
2013-12-11 3:54 ` David Miller
3 siblings, 1 reply; 6+ messages in thread
From: Vlad Yasevich @ 2013-12-11 2:41 UTC (permalink / raw)
To: Wang Weidong, nhorman, davem; +Cc: dborkman, netdev, linux-sctp
On 12/10/2013 08:50 PM, Wang Weidong wrote:
> v6 -> v7:
> -patch2: fix the whitespace issues which pointed out by Daniel
>
> v5 -> v6:
> split the v5' first patch to patch1 and patch2, and remove the
> macro in constants.h
>
> -patch1: do rto_min/max socket option handling in its own patch, and
> fix the check of rto_min/max.
> -patch2: do rto_min/max sysctl handling in its own patch.
> -patch3: add Suggested-by Daniel.
>
> v4 -> v5:
> - patch1: add marco in constants.h and fix up spacing as
> suggested by Daniel
> - patch2: add a patch for fix up do_hmac_alg for according
> to do_rto_min[max]
>
> v3 -> v4:
> -patch1: fix use init_net directly which suggested by Vlad.
>
> v2 -> v3:
> -patch1: add proc_handler for check rto_min and rto_max which suggested
> by Vlad
>
> v1 -> v2:
> -patch1: fix the From Name which pointed out by David, and
> add the ACK by Neil
>
> Wang Weidong (3):
> sctp: check the rto_min and rto_max in setsockopt
> sctp: add check rto_min and rto_max in sysctl
> sctp: fix up a spacing
Series
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
-vlad
>
> net/sctp/socket.c | 32 +++++++++++++++--------
> net/sctp/sysctl.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++-------
> 2 files changed, 89 insertions(+), 19 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v7 0/3] sctp: check the rto_min and rto_max
2013-12-11 2:41 ` [PATCH v7 0/3] sctp: check the rto_min and rto_max Vlad Yasevich
@ 2013-12-11 3:54 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-12-11 3:54 UTC (permalink / raw)
To: vyasevich; +Cc: wangweidong1, nhorman, dborkman, netdev, linux-sctp
From: Vlad Yasevich <vyasevich@gmail.com>
Date: Tue, 10 Dec 2013 21:41:36 -0500
> On 12/10/2013 08:50 PM, Wang Weidong wrote:
>> v6 -> v7:
>> -patch2: fix the whitespace issues which pointed out by Daniel
>>
>> v5 -> v6:
>> split the v5' first patch to patch1 and patch2, and remove the
>> macro in constants.h
>>
>> -patch1: do rto_min/max socket option handling in its own patch, and
>> fix the check of rto_min/max.
>> -patch2: do rto_min/max sysctl handling in its own patch.
>> -patch3: add Suggested-by Daniel.
>>
>> v4 -> v5:
>> - patch1: add marco in constants.h and fix up spacing as
>> suggested by Daniel
>> - patch2: add a patch for fix up do_hmac_alg for according
>> to do_rto_min[max]
>>
>> v3 -> v4:
>> -patch1: fix use init_net directly which suggested by Vlad.
>>
>> v2 -> v3:
>> -patch1: add proc_handler for check rto_min and rto_max which suggested
>> by Vlad
>>
>> v1 -> v2:
>> -patch1: fix the From Name which pointed out by David, and
>> add the ACK by Neil
>>
>> Wang Weidong (3):
>> sctp: check the rto_min and rto_max in setsockopt
>> sctp: add check rto_min and rto_max in sysctl
>> sctp: fix up a spacing
>
> Series
> Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Series applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-12-11 3:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-11 1:50 [PATCH v7 0/3] sctp: check the rto_min and rto_max Wang Weidong
2013-12-11 1:50 ` [PATCH v7 1/3] sctp: check the rto_min and rto_max in setsockopt Wang Weidong
2013-12-11 1:50 ` [PATCH v7 2/3] sctp: add check rto_min and rto_max in sysctl Wang Weidong
2013-12-11 1:50 ` [PATCH v7 3/3] sctp: fix up a spacing Wang Weidong
2013-12-11 2:41 ` [PATCH v7 0/3] sctp: check the rto_min and rto_max Vlad Yasevich
2013-12-11 3:54 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).