Commit 2e7709d1 authored by Xin Long's avatar Xin Long Committed by David S. Miller

sctp: use SCTP_FUTURE_ASSOC for SCTP_INTERLEAVING_SUPPORTED sockopt

Check with SCTP_FUTURE_ASSOC instead in
sctp_set/getsockopt_reconfig_supported, it's compatible with 0.

It also adjusts some code to keep a same check form as other functions.
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent acce7f3b
...@@ -4240,8 +4240,8 @@ static int sctp_setsockopt_interleaving_supported(struct sock *sk, ...@@ -4240,8 +4240,8 @@ static int sctp_setsockopt_interleaving_supported(struct sock *sk,
unsigned int optlen) unsigned int optlen)
{ {
struct sctp_sock *sp = sctp_sk(sk); struct sctp_sock *sp = sctp_sk(sk);
struct net *net = sock_net(sk);
struct sctp_assoc_value params; struct sctp_assoc_value params;
struct sctp_association *asoc;
int retval = -EINVAL; int retval = -EINVAL;
if (optlen < sizeof(params)) if (optlen < sizeof(params))
...@@ -4253,10 +4253,12 @@ static int sctp_setsockopt_interleaving_supported(struct sock *sk, ...@@ -4253,10 +4253,12 @@ static int sctp_setsockopt_interleaving_supported(struct sock *sk,
goto out; goto out;
} }
if (params.assoc_id) asoc = sctp_id2assoc(sk, params.assoc_id);
if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
sctp_style(sk, UDP))
goto out; goto out;
if (!net->sctp.intl_enable || !sp->frag_interleave) { if (!sock_net(sk)->sctp.intl_enable || !sp->frag_interleave) {
retval = -EPERM; retval = -EPERM;
goto out; goto out;
} }
...@@ -7453,17 +7455,15 @@ static int sctp_getsockopt_interleaving_supported(struct sock *sk, int len, ...@@ -7453,17 +7455,15 @@ static int sctp_getsockopt_interleaving_supported(struct sock *sk, int len,
goto out; goto out;
asoc = sctp_id2assoc(sk, params.assoc_id); asoc = sctp_id2assoc(sk, params.assoc_id);
if (asoc) { if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
params.assoc_value = asoc->intl_enable; sctp_style(sk, UDP)) {
} else if (!params.assoc_id) {
struct sctp_sock *sp = sctp_sk(sk);
params.assoc_value = sp->strm_interleave;
} else {
retval = -EINVAL; retval = -EINVAL;
goto out; goto out;
} }
params.assoc_value = asoc ? asoc->intl_enable
: sctp_sk(sk)->strm_interleave;
if (put_user(len, optlen)) if (put_user(len, optlen))
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment