mirror of
https://github.com/torvalds/linux.git
synced 2025-08-16 06:31:34 +02:00
tcp: tcp_set_window_clamp() cleanup
Remove one indentation level. Use max_t() and clamp() macros. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Jason Xing <kerneljasonxing@gmail.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20250301201424.2046477-7-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
5282de1762
commit
863a952eb7
1 changed files with 20 additions and 20 deletions
|
@ -3693,33 +3693,33 @@ EXPORT_SYMBOL(tcp_sock_set_keepcnt);
|
|||
|
||||
int tcp_set_window_clamp(struct sock *sk, int val)
|
||||
{
|
||||
u32 old_window_clamp, new_window_clamp;
|
||||
struct tcp_sock *tp = tcp_sk(sk);
|
||||
|
||||
if (!val) {
|
||||
if (sk->sk_state != TCP_CLOSE)
|
||||
return -EINVAL;
|
||||
WRITE_ONCE(tp->window_clamp, 0);
|
||||
} else {
|
||||
u32 new_rcv_ssthresh, old_window_clamp = tp->window_clamp;
|
||||
u32 new_window_clamp = val < SOCK_MIN_RCVBUF / 2 ?
|
||||
SOCK_MIN_RCVBUF / 2 : val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
old_window_clamp = tp->window_clamp;
|
||||
new_window_clamp = max_t(int, SOCK_MIN_RCVBUF / 2, val);
|
||||
|
||||
if (new_window_clamp == old_window_clamp)
|
||||
return 0;
|
||||
|
||||
WRITE_ONCE(tp->window_clamp, new_window_clamp);
|
||||
if (new_window_clamp < old_window_clamp) {
|
||||
/* need to apply the reserved mem provisioning only
|
||||
* when shrinking the window clamp
|
||||
*/
|
||||
__tcp_adjust_rcv_ssthresh(sk, tp->window_clamp);
|
||||
|
||||
} else {
|
||||
new_rcv_ssthresh = min(tp->rcv_wnd, tp->window_clamp);
|
||||
tp->rcv_ssthresh = max(new_rcv_ssthresh,
|
||||
tp->rcv_ssthresh);
|
||||
}
|
||||
}
|
||||
/* Need to apply the reserved mem provisioning only
|
||||
* when shrinking the window clamp.
|
||||
*/
|
||||
if (new_window_clamp < old_window_clamp)
|
||||
__tcp_adjust_rcv_ssthresh(sk, new_window_clamp);
|
||||
else
|
||||
tp->rcv_ssthresh = clamp(new_window_clamp,
|
||||
tp->rcv_ssthresh,
|
||||
tp->rcv_wnd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue