sctp: add SCTP_FUTURE_ASOC and SCTP_CURRENT_ASSOC for SCTP_STREAM_SCHEDULER sockopt
Check with SCTP_ALL_ASSOC instead in sctp_setsockopt_scheduler and check with SCTP_FUTURE_ASSOC instead in sctp_getsockopt_scheduler, it's compatible with 0. SCTP_CURRENT_ASSOC is supported for SCTP_STREAM_SCHEDULER in this patch. It also adds default_ss in sctp_sock to support SCTP_FUTURE_ASSOC. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d251f05e3b
commit
7efba10d6b
@ -211,6 +211,8 @@ struct sctp_sock {
|
|||||||
/* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */
|
/* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */
|
||||||
__u32 param_flags;
|
__u32 param_flags;
|
||||||
|
|
||||||
|
__u32 default_ss;
|
||||||
|
|
||||||
struct sctp_rtoinfo rtoinfo;
|
struct sctp_rtoinfo rtoinfo;
|
||||||
struct sctp_paddrparams paddrparam;
|
struct sctp_paddrparams paddrparam;
|
||||||
struct sctp_assocparams assocparams;
|
struct sctp_assocparams assocparams;
|
||||||
|
@ -212,7 +212,7 @@ void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
|
|||||||
INIT_LIST_HEAD(&q->retransmit);
|
INIT_LIST_HEAD(&q->retransmit);
|
||||||
INIT_LIST_HEAD(&q->sacked);
|
INIT_LIST_HEAD(&q->sacked);
|
||||||
INIT_LIST_HEAD(&q->abandoned);
|
INIT_LIST_HEAD(&q->abandoned);
|
||||||
sctp_sched_set_sched(asoc, SCTP_SS_DEFAULT);
|
sctp_sched_set_sched(asoc, sctp_sk(asoc->base.sk)->default_ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the outqueue structure and any related pending chunks.
|
/* Free the outqueue structure and any related pending chunks.
|
||||||
|
@ -4352,29 +4352,44 @@ static int sctp_setsockopt_scheduler(struct sock *sk,
|
|||||||
char __user *optval,
|
char __user *optval,
|
||||||
unsigned int optlen)
|
unsigned int optlen)
|
||||||
{
|
{
|
||||||
|
struct sctp_sock *sp = sctp_sk(sk);
|
||||||
struct sctp_association *asoc;
|
struct sctp_association *asoc;
|
||||||
struct sctp_assoc_value params;
|
struct sctp_assoc_value params;
|
||||||
int retval = -EINVAL;
|
int retval = 0;
|
||||||
|
|
||||||
if (optlen < sizeof(params))
|
if (optlen < sizeof(params))
|
||||||
goto out;
|
return -EINVAL;
|
||||||
|
|
||||||
optlen = sizeof(params);
|
optlen = sizeof(params);
|
||||||
if (copy_from_user(¶ms, optval, optlen)) {
|
if (copy_from_user(¶ms, optval, optlen))
|
||||||
retval = -EFAULT;
|
return -EFAULT;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.assoc_value > SCTP_SS_MAX)
|
if (params.assoc_value > SCTP_SS_MAX)
|
||||||
goto out;
|
return -EINVAL;
|
||||||
|
|
||||||
asoc = sctp_id2assoc(sk, params.assoc_id);
|
asoc = sctp_id2assoc(sk, params.assoc_id);
|
||||||
if (!asoc)
|
if (!asoc && params.assoc_id > SCTP_ALL_ASSOC &&
|
||||||
goto out;
|
sctp_style(sk, UDP))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
retval = sctp_sched_set_sched(asoc, params.assoc_value);
|
if (asoc)
|
||||||
|
return sctp_sched_set_sched(asoc, params.assoc_value);
|
||||||
|
|
||||||
|
if (params.assoc_id == SCTP_FUTURE_ASSOC ||
|
||||||
|
params.assoc_id == SCTP_ALL_ASSOC)
|
||||||
|
sp->default_ss = params.assoc_value;
|
||||||
|
|
||||||
|
if (params.assoc_id == SCTP_CURRENT_ASSOC ||
|
||||||
|
params.assoc_id == SCTP_ALL_ASSOC) {
|
||||||
|
list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
|
||||||
|
int ret = sctp_sched_set_sched(asoc,
|
||||||
|
params.assoc_value);
|
||||||
|
|
||||||
|
if (ret && !retval)
|
||||||
|
retval = ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5005,6 +5020,7 @@ static int sctp_init_sock(struct sock *sk)
|
|||||||
sp->param_flags = SPP_HB_ENABLE |
|
sp->param_flags = SPP_HB_ENABLE |
|
||||||
SPP_PMTUD_ENABLE |
|
SPP_PMTUD_ENABLE |
|
||||||
SPP_SACKDELAY_ENABLE;
|
SPP_SACKDELAY_ENABLE;
|
||||||
|
sp->default_ss = SCTP_SS_DEFAULT;
|
||||||
|
|
||||||
/* If enabled no SCTP message fragmentation will be performed.
|
/* If enabled no SCTP message fragmentation will be performed.
|
||||||
* Configure through SCTP_DISABLE_FRAGMENTS socket option.
|
* Configure through SCTP_DISABLE_FRAGMENTS socket option.
|
||||||
@ -7572,12 +7588,14 @@ static int sctp_getsockopt_scheduler(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 &&
|
||||||
|
sctp_style(sk, UDP)) {
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
params.assoc_value = sctp_sched_get_sched(asoc);
|
params.assoc_value = asoc ? sctp_sched_get_sched(asoc)
|
||||||
|
: sctp_sk(sk)->default_ss;
|
||||||
|
|
||||||
if (put_user(len, optlen))
|
if (put_user(len, optlen))
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user