mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 14:50:53 +07:00
sctp: use SCTP_FUTURE_ASSOC and add SCTP_CURRENT_ASSOC for SCTP_DELAYED_SACK sockopt
Check with SCTP_ALL_ASSOC instead in sctp_setsockopt_delayed_ack and check with SCTP_FUTURE_ASSOC instead in sctp_getsockopt_delayed_ack, it's compatible with 0. SCTP_CURRENT_ASSOC is supported for SCTP_DELAYED_SACK in this patch. It also adds sctp_apply_asoc_delayed_ack() to make code more readable. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e7f2824891
commit
9c5829e1c4
@ -2798,6 +2798,43 @@ static inline __u32 sctp_spp_sackdelay_disable(__u32 param_flags)
|
|||||||
return (param_flags & ~SPP_SACKDELAY) | SPP_SACKDELAY_DISABLE;
|
return (param_flags & ~SPP_SACKDELAY) | SPP_SACKDELAY_DISABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sctp_apply_asoc_delayed_ack(struct sctp_sack_info *params,
|
||||||
|
struct sctp_association *asoc)
|
||||||
|
{
|
||||||
|
struct sctp_transport *trans;
|
||||||
|
|
||||||
|
if (params->sack_delay) {
|
||||||
|
asoc->sackdelay = msecs_to_jiffies(params->sack_delay);
|
||||||
|
asoc->param_flags =
|
||||||
|
sctp_spp_sackdelay_enable(asoc->param_flags);
|
||||||
|
}
|
||||||
|
if (params->sack_freq == 1) {
|
||||||
|
asoc->param_flags =
|
||||||
|
sctp_spp_sackdelay_disable(asoc->param_flags);
|
||||||
|
} else if (params->sack_freq > 1) {
|
||||||
|
asoc->sackfreq = params->sack_freq;
|
||||||
|
asoc->param_flags =
|
||||||
|
sctp_spp_sackdelay_enable(asoc->param_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
list_for_each_entry(trans, &asoc->peer.transport_addr_list,
|
||||||
|
transports) {
|
||||||
|
if (params->sack_delay) {
|
||||||
|
trans->sackdelay = msecs_to_jiffies(params->sack_delay);
|
||||||
|
trans->param_flags =
|
||||||
|
sctp_spp_sackdelay_enable(trans->param_flags);
|
||||||
|
}
|
||||||
|
if (params->sack_freq == 1) {
|
||||||
|
trans->param_flags =
|
||||||
|
sctp_spp_sackdelay_disable(trans->param_flags);
|
||||||
|
} else if (params->sack_freq > 1) {
|
||||||
|
trans->sackfreq = params->sack_freq;
|
||||||
|
trans->param_flags =
|
||||||
|
sctp_spp_sackdelay_enable(trans->param_flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 7.1.23. Get or set delayed ack timer (SCTP_DELAYED_SACK)
|
* 7.1.23. Get or set delayed ack timer (SCTP_DELAYED_SACK)
|
||||||
*
|
*
|
||||||
@ -2837,10 +2874,9 @@ static inline __u32 sctp_spp_sackdelay_disable(__u32 param_flags)
|
|||||||
static int sctp_setsockopt_delayed_ack(struct sock *sk,
|
static int sctp_setsockopt_delayed_ack(struct sock *sk,
|
||||||
char __user *optval, unsigned int optlen)
|
char __user *optval, unsigned int optlen)
|
||||||
{
|
{
|
||||||
struct sctp_sack_info params;
|
|
||||||
struct sctp_transport *trans = NULL;
|
|
||||||
struct sctp_association *asoc = NULL;
|
|
||||||
struct sctp_sock *sp = sctp_sk(sk);
|
struct sctp_sock *sp = sctp_sk(sk);
|
||||||
|
struct sctp_association *asoc;
|
||||||
|
struct sctp_sack_info params;
|
||||||
|
|
||||||
if (optlen == sizeof(struct sctp_sack_info)) {
|
if (optlen == sizeof(struct sctp_sack_info)) {
|
||||||
if (copy_from_user(¶ms, optval, optlen))
|
if (copy_from_user(¶ms, optval, optlen))
|
||||||
@ -2868,67 +2904,42 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk,
|
|||||||
if (params.sack_delay > 500)
|
if (params.sack_delay > 500)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Get association, if sack_assoc_id != 0 and the socket is a one
|
/* Get association, if sack_assoc_id != SCTP_FUTURE_ASSOC and the
|
||||||
* to many style socket, and an association was not found, then
|
* socket is a one to many style socket, and an association
|
||||||
* the id was invalid.
|
* was not found, then the id was invalid.
|
||||||
*/
|
*/
|
||||||
asoc = sctp_id2assoc(sk, params.sack_assoc_id);
|
asoc = sctp_id2assoc(sk, params.sack_assoc_id);
|
||||||
if (!asoc && params.sack_assoc_id && sctp_style(sk, UDP))
|
if (!asoc && params.sack_assoc_id > SCTP_ALL_ASSOC &&
|
||||||
|
sctp_style(sk, UDP))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (params.sack_delay) {
|
|
||||||
if (asoc) {
|
if (asoc) {
|
||||||
asoc->sackdelay =
|
sctp_apply_asoc_delayed_ack(¶ms, asoc);
|
||||||
msecs_to_jiffies(params.sack_delay);
|
|
||||||
asoc->param_flags =
|
return 0;
|
||||||
sctp_spp_sackdelay_enable(asoc->param_flags);
|
}
|
||||||
} else {
|
|
||||||
|
if (params.sack_assoc_id == SCTP_FUTURE_ASSOC ||
|
||||||
|
params.sack_assoc_id == SCTP_ALL_ASSOC) {
|
||||||
|
if (params.sack_delay) {
|
||||||
sp->sackdelay = params.sack_delay;
|
sp->sackdelay = params.sack_delay;
|
||||||
sp->param_flags =
|
sp->param_flags =
|
||||||
sctp_spp_sackdelay_enable(sp->param_flags);
|
sctp_spp_sackdelay_enable(sp->param_flags);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (params.sack_freq == 1) {
|
if (params.sack_freq == 1) {
|
||||||
if (asoc) {
|
|
||||||
asoc->param_flags =
|
|
||||||
sctp_spp_sackdelay_disable(asoc->param_flags);
|
|
||||||
} else {
|
|
||||||
sp->param_flags =
|
sp->param_flags =
|
||||||
sctp_spp_sackdelay_disable(sp->param_flags);
|
sctp_spp_sackdelay_disable(sp->param_flags);
|
||||||
}
|
|
||||||
} else if (params.sack_freq > 1) {
|
} else if (params.sack_freq > 1) {
|
||||||
if (asoc) {
|
|
||||||
asoc->sackfreq = params.sack_freq;
|
|
||||||
asoc->param_flags =
|
|
||||||
sctp_spp_sackdelay_enable(asoc->param_flags);
|
|
||||||
} else {
|
|
||||||
sp->sackfreq = params.sack_freq;
|
sp->sackfreq = params.sack_freq;
|
||||||
sp->param_flags =
|
sp->param_flags =
|
||||||
sctp_spp_sackdelay_enable(sp->param_flags);
|
sctp_spp_sackdelay_enable(sp->param_flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If change is for association, also apply to each transport. */
|
if (params.sack_assoc_id == SCTP_CURRENT_ASSOC ||
|
||||||
if (asoc) {
|
params.sack_assoc_id == SCTP_ALL_ASSOC)
|
||||||
list_for_each_entry(trans, &asoc->peer.transport_addr_list,
|
list_for_each_entry(asoc, &sp->ep->asocs, asocs)
|
||||||
transports) {
|
sctp_apply_asoc_delayed_ack(¶ms, asoc);
|
||||||
if (params.sack_delay) {
|
|
||||||
trans->sackdelay =
|
|
||||||
msecs_to_jiffies(params.sack_delay);
|
|
||||||
trans->param_flags =
|
|
||||||
sctp_spp_sackdelay_enable(trans->param_flags);
|
|
||||||
}
|
|
||||||
if (params.sack_freq == 1) {
|
|
||||||
trans->param_flags =
|
|
||||||
sctp_spp_sackdelay_disable(trans->param_flags);
|
|
||||||
} else if (params.sack_freq > 1) {
|
|
||||||
trans->sackfreq = params.sack_freq;
|
|
||||||
trans->param_flags =
|
|
||||||
sctp_spp_sackdelay_enable(trans->param_flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -5847,19 +5858,19 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
|
|||||||
} else
|
} else
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Get association, if sack_assoc_id != 0 and the socket is a one
|
/* Get association, if sack_assoc_id != SCTP_FUTURE_ASSOC and the
|
||||||
* to many style socket, and an association was not found, then
|
* socket is a one to many style socket, and an association
|
||||||
* the id was invalid.
|
* was not found, then the id was invalid.
|
||||||
*/
|
*/
|
||||||
asoc = sctp_id2assoc(sk, params.sack_assoc_id);
|
asoc = sctp_id2assoc(sk, params.sack_assoc_id);
|
||||||
if (!asoc && params.sack_assoc_id && sctp_style(sk, UDP))
|
if (!asoc && params.sack_assoc_id != SCTP_FUTURE_ASSOC &&
|
||||||
|
sctp_style(sk, UDP))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (asoc) {
|
if (asoc) {
|
||||||
/* Fetch association values. */
|
/* Fetch association values. */
|
||||||
if (asoc->param_flags & SPP_SACKDELAY_ENABLE) {
|
if (asoc->param_flags & SPP_SACKDELAY_ENABLE) {
|
||||||
params.sack_delay = jiffies_to_msecs(
|
params.sack_delay = jiffies_to_msecs(asoc->sackdelay);
|
||||||
asoc->sackdelay);
|
|
||||||
params.sack_freq = asoc->sackfreq;
|
params.sack_freq = asoc->sackfreq;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user