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

sctp: add SCTP_CURRENT_ASSOC for SCTP_STREAM_SCHEDULER_VALUE sockopt

SCTP_STREAM_SCHEDULER_VALUE is a special one, as its value is not
save in sctp_sock, but only in asoc. So only SCTP_CURRENT_ASSOC
reserved assoc_id can be used in sctp_setsockopt_scheduler_value.

This patch adds SCTP_CURRENT_ASOC support for
SCTP_STREAM_SCHEDULER_VALUE.
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2e7709d1
...@@ -4211,8 +4211,8 @@ static int sctp_setsockopt_scheduler_value(struct sock *sk, ...@@ -4211,8 +4211,8 @@ static int sctp_setsockopt_scheduler_value(struct sock *sk,
char __user *optval, char __user *optval,
unsigned int optlen) unsigned int optlen)
{ {
struct sctp_association *asoc;
struct sctp_stream_value params; struct sctp_stream_value params;
struct sctp_association *asoc;
int retval = -EINVAL; int retval = -EINVAL;
if (optlen < sizeof(params)) if (optlen < sizeof(params))
...@@ -4225,11 +4225,24 @@ static int sctp_setsockopt_scheduler_value(struct sock *sk, ...@@ -4225,11 +4225,24 @@ static int sctp_setsockopt_scheduler_value(struct sock *sk,
} }
asoc = sctp_id2assoc(sk, params.assoc_id); asoc = sctp_id2assoc(sk, params.assoc_id);
if (!asoc) if (!asoc && params.assoc_id != SCTP_CURRENT_ASSOC &&
sctp_style(sk, UDP))
goto out; goto out;
retval = sctp_sched_set_value(asoc, params.stream_id, if (asoc) {
params.stream_value, GFP_KERNEL); retval = sctp_sched_set_value(asoc, params.stream_id,
params.stream_value, GFP_KERNEL);
goto out;
}
retval = 0;
list_for_each_entry(asoc, &sctp_sk(sk)->ep->asocs, asocs) {
int ret = sctp_sched_set_value(asoc, params.stream_id,
params.stream_value, GFP_KERNEL);
if (ret && !retval) /* try to return the 1st error. */
retval = ret;
}
out: out:
return retval; return retval;
......
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