Commit 0ea5e4df authored by wangweidong's avatar wangweidong Committed by David S. Miller

sctp: create helper function to enable|disable sackdelay

add sctp_spp_sackdelay_{enable|disable} helper function for
avoiding code duplication.
Signed-off-by: default avatarWang Weidong <wangweidong1@huawei.com>
Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d76ed22b
...@@ -2527,6 +2527,16 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk, ...@@ -2527,6 +2527,16 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk,
return 0; return 0;
} }
static inline __u32 sctp_spp_sackdelay_enable(__u32 param_flags)
{
return (param_flags & ~SPP_SACKDELAY) | SPP_SACKDELAY_ENABLE;
}
static inline __u32 sctp_spp_sackdelay_disable(__u32 param_flags)
{
return (param_flags & ~SPP_SACKDELAY) | SPP_SACKDELAY_DISABLE;
}
/* /*
* 7.1.23. Get or set delayed ack timer (SCTP_DELAYED_SACK) * 7.1.23. Get or set delayed ack timer (SCTP_DELAYED_SACK)
* *
...@@ -2610,37 +2620,31 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk, ...@@ -2610,37 +2620,31 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk,
asoc->sackdelay = asoc->sackdelay =
msecs_to_jiffies(params.sack_delay); msecs_to_jiffies(params.sack_delay);
asoc->param_flags = asoc->param_flags =
(asoc->param_flags & ~SPP_SACKDELAY) | sctp_spp_sackdelay_enable(asoc->param_flags);
SPP_SACKDELAY_ENABLE;
} else { } else {
sp->sackdelay = params.sack_delay; sp->sackdelay = params.sack_delay;
sp->param_flags = sp->param_flags =
(sp->param_flags & ~SPP_SACKDELAY) | sctp_spp_sackdelay_enable(sp->param_flags);
SPP_SACKDELAY_ENABLE;
} }
} }
if (params.sack_freq == 1) { if (params.sack_freq == 1) {
if (asoc) { if (asoc) {
asoc->param_flags = asoc->param_flags =
(asoc->param_flags & ~SPP_SACKDELAY) | sctp_spp_sackdelay_disable(asoc->param_flags);
SPP_SACKDELAY_DISABLE;
} else { } else {
sp->param_flags = sp->param_flags =
(sp->param_flags & ~SPP_SACKDELAY) | sctp_spp_sackdelay_disable(sp->param_flags);
SPP_SACKDELAY_DISABLE;
} }
} else if (params.sack_freq > 1) { } else if (params.sack_freq > 1) {
if (asoc) { if (asoc) {
asoc->sackfreq = params.sack_freq; asoc->sackfreq = params.sack_freq;
asoc->param_flags = asoc->param_flags =
(asoc->param_flags & ~SPP_SACKDELAY) | sctp_spp_sackdelay_enable(asoc->param_flags);
SPP_SACKDELAY_ENABLE;
} else { } else {
sp->sackfreq = params.sack_freq; sp->sackfreq = params.sack_freq;
sp->param_flags = sp->param_flags =
(sp->param_flags & ~SPP_SACKDELAY) | sctp_spp_sackdelay_enable(sp->param_flags);
SPP_SACKDELAY_ENABLE;
} }
} }
...@@ -2652,18 +2656,15 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk, ...@@ -2652,18 +2656,15 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk,
trans->sackdelay = trans->sackdelay =
msecs_to_jiffies(params.sack_delay); msecs_to_jiffies(params.sack_delay);
trans->param_flags = trans->param_flags =
(trans->param_flags & ~SPP_SACKDELAY) | sctp_spp_sackdelay_enable(trans->param_flags);
SPP_SACKDELAY_ENABLE;
} }
if (params.sack_freq == 1) { if (params.sack_freq == 1) {
trans->param_flags = trans->param_flags =
(trans->param_flags & ~SPP_SACKDELAY) | sctp_spp_sackdelay_disable(trans->param_flags);
SPP_SACKDELAY_DISABLE;
} else if (params.sack_freq > 1) { } else if (params.sack_freq > 1) {
trans->sackfreq = params.sack_freq; trans->sackfreq = params.sack_freq;
trans->param_flags = trans->param_flags =
(trans->param_flags & ~SPP_SACKDELAY) | sctp_spp_sackdelay_enable(trans->param_flags);
SPP_SACKDELAY_ENABLE;
} }
} }
} }
......
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