/* when initializing use the value from init_rcv_wnd
* rather than the default from above
*/
- if (init_rcv_wnd)
- *rcv_wnd = min(*rcv_wnd, init_rcv_wnd * mss);
- else
- *rcv_wnd = min(*rcv_wnd, init_cwnd * mss);
+ if (init_rcv_wnd &&
+ (*rcv_wnd > init_rcv_wnd * mss))
+ *rcv_wnd = init_rcv_wnd * mss;
+ else if (*rcv_wnd > init_cwnd * mss)
+ *rcv_wnd = init_cwnd * mss;
}
/* Set the clamp no higher than max representable value */
*/
static u8 tcp_cookie_size_check(u8 desired)
{
- int cookie_size;
-
- if (desired > 0)
+ if (desired > 0) {
/* previously specified */
return desired;
-
- cookie_size = ACCESS_ONCE(sysctl_tcp_cookie_size);
- if (cookie_size <= 0)
+ }
+ if (sysctl_tcp_cookie_size <= 0) {
/* no default specified */
return 0;
-
- if (cookie_size <= TCP_COOKIE_MIN)
+ }
+ if (sysctl_tcp_cookie_size <= TCP_COOKIE_MIN) {
/* value too small, specify minimum */
return TCP_COOKIE_MIN;
-
- if (cookie_size >= TCP_COOKIE_MAX)
+ }
+ if (sysctl_tcp_cookie_size >= TCP_COOKIE_MAX) {
/* value too large, specify maximum */
return TCP_COOKIE_MAX;
-
- if (cookie_size & 1)
+ }
+ if (0x1 & sysctl_tcp_cookie_size) {
/* 8-bit multiple, illegal, fix it */
- cookie_size++;
-
- return (u8)cookie_size;
+ return (u8)(sysctl_tcp_cookie_size + 0x1);
+ }
+ return (u8)sysctl_tcp_cookie_size;
}
/* Write previously computed TCP options to the packet.
struct tcp_sock *tp = tcp_sk(sk);
const struct inet_connection_sock *icsk = inet_csk(sk);
u32 send_win, cong_win, limit, in_flight;
- int win_divisor;
if (TCP_SKB_CB(skb)->flags & TCPHDR_FIN)
goto send_now;
if ((skb != tcp_write_queue_tail(sk)) && (limit >= skb->len))
goto send_now;
- win_divisor = ACCESS_ONCE(sysctl_tcp_tso_win_divisor);
- if (win_divisor) {
+ if (sysctl_tcp_tso_win_divisor) {
u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache);
/* If at least some fraction of a window is available,
* just use it.
*/
- chunk /= win_divisor;
+ chunk /= sysctl_tcp_tso_win_divisor;
if (limit >= chunk)
goto send_now;
} else {