sctp: use SCTP_FUTURE_ASSOC and add SCTP_CURRENT_ASSOC for SCTP_ENABLE_STREAM_RESET sockopt
Check with SCTP_ALL_ASSOC instead in sctp_setsockopt_enable_strreset and check with SCTP_FUTURE_ASSOC instead in sctp_getsockopt_enable_strreset, it's compatible with 0. SCTP_CURRENT_ASSOC is supported for SCTP_ENABLE_STREAM_RESET in this patch. It also adjusts some code to keep a same check form as other functions. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3a583059d1
commit
99a62135e1
|
@ -4222,6 +4222,7 @@ static int sctp_setsockopt_enable_strreset(struct sock *sk,
|
||||||
char __user *optval,
|
char __user *optval,
|
||||||
unsigned int optlen)
|
unsigned int optlen)
|
||||||
{
|
{
|
||||||
|
struct sctp_endpoint *ep = sctp_sk(sk)->ep;
|
||||||
struct sctp_assoc_value params;
|
struct sctp_assoc_value params;
|
||||||
struct sctp_association *asoc;
|
struct sctp_association *asoc;
|
||||||
int retval = -EINVAL;
|
int retval = -EINVAL;
|
||||||
|
@ -4238,17 +4239,25 @@ static int sctp_setsockopt_enable_strreset(struct sock *sk,
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
asoc = sctp_id2assoc(sk, params.assoc_id);
|
asoc = sctp_id2assoc(sk, params.assoc_id);
|
||||||
|
if (!asoc && params.assoc_id > SCTP_ALL_ASSOC &&
|
||||||
|
sctp_style(sk, UDP))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
retval = 0;
|
||||||
|
|
||||||
if (asoc) {
|
if (asoc) {
|
||||||
asoc->strreset_enable = params.assoc_value;
|
asoc->strreset_enable = params.assoc_value;
|
||||||
} else if (!params.assoc_id) {
|
|
||||||
struct sctp_sock *sp = sctp_sk(sk);
|
|
||||||
|
|
||||||
sp->ep->strreset_enable = params.assoc_value;
|
|
||||||
} else {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = 0;
|
if (params.assoc_id == SCTP_FUTURE_ASSOC ||
|
||||||
|
params.assoc_id == SCTP_ALL_ASSOC)
|
||||||
|
ep->strreset_enable = params.assoc_value;
|
||||||
|
|
||||||
|
if (params.assoc_id == SCTP_CURRENT_ASSOC ||
|
||||||
|
params.assoc_id == SCTP_ALL_ASSOC)
|
||||||
|
list_for_each_entry(asoc, &ep->asocs, asocs)
|
||||||
|
asoc->strreset_enable = params.assoc_value;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -7509,17 +7518,15 @@ static int sctp_getsockopt_enable_strreset(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->strreset_enable;
|
sctp_style(sk, UDP)) {
|
||||||
} else if (!params.assoc_id) {
|
|
||||||
struct sctp_sock *sp = sctp_sk(sk);
|
|
||||||
|
|
||||||
params.assoc_value = sp->ep->strreset_enable;
|
|
||||||
} else {
|
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params.assoc_value = asoc ? asoc->strreset_enable
|
||||||
|
: sctp_sk(sk)->ep->strreset_enable;
|
||||||
|
|
||||||
if (put_user(len, optlen))
|
if (put_user(len, optlen))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue