Skip to content

Commit 863a952

Browse files
edumazetkuba-moo
authored andcommitted
tcp: tcp_set_window_clamp() cleanup
Remove one indentation level. Use max_t() and clamp() macros. Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Jason Xing <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5282de1 commit 863a952

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

net/ipv4/tcp.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,33 +3693,33 @@ EXPORT_SYMBOL(tcp_sock_set_keepcnt);
36933693

36943694
int tcp_set_window_clamp(struct sock *sk, int val)
36953695
{
3696+
u32 old_window_clamp, new_window_clamp;
36963697
struct tcp_sock *tp = tcp_sk(sk);
36973698

36983699
if (!val) {
36993700
if (sk->sk_state != TCP_CLOSE)
37003701
return -EINVAL;
37013702
WRITE_ONCE(tp->window_clamp, 0);
3702-
} else {
3703-
u32 new_rcv_ssthresh, old_window_clamp = tp->window_clamp;
3704-
u32 new_window_clamp = val < SOCK_MIN_RCVBUF / 2 ?
3705-
SOCK_MIN_RCVBUF / 2 : val;
3703+
return 0;
3704+
}
37063705

3707-
if (new_window_clamp == old_window_clamp)
3708-
return 0;
3706+
old_window_clamp = tp->window_clamp;
3707+
new_window_clamp = max_t(int, SOCK_MIN_RCVBUF / 2, val);
37093708

3710-
WRITE_ONCE(tp->window_clamp, new_window_clamp);
3711-
if (new_window_clamp < old_window_clamp) {
3712-
/* need to apply the reserved mem provisioning only
3713-
* when shrinking the window clamp
3714-
*/
3715-
__tcp_adjust_rcv_ssthresh(sk, tp->window_clamp);
3709+
if (new_window_clamp == old_window_clamp)
3710+
return 0;
37163711

3717-
} else {
3718-
new_rcv_ssthresh = min(tp->rcv_wnd, tp->window_clamp);
3719-
tp->rcv_ssthresh = max(new_rcv_ssthresh,
3720-
tp->rcv_ssthresh);
3721-
}
3722-
}
3712+
WRITE_ONCE(tp->window_clamp, new_window_clamp);
3713+
3714+
/* Need to apply the reserved mem provisioning only
3715+
* when shrinking the window clamp.
3716+
*/
3717+
if (new_window_clamp < old_window_clamp)
3718+
__tcp_adjust_rcv_ssthresh(sk, new_window_clamp);
3719+
else
3720+
tp->rcv_ssthresh = clamp(new_window_clamp,
3721+
tp->rcv_ssthresh,
3722+
tp->rcv_wnd);
37233723
return 0;
37243724
}
37253725

0 commit comments

Comments
 (0)