From: Eric Dumazet
> Sent: 15 September 2016 16:13
> If a TCP socket gets a large write queue, an overflow can happen
> in a test in __tcp_retransmit_skb() preventing all retransmits.
...
>       if (atomic_read(&sk->sk_wmem_alloc) >
> -         min(sk->sk_wmem_queued + (sk->sk_wmem_queued >> 2), sk->sk_sndbuf))
> +         min_t(u32, sk->sk_wmem_queued + (sk->sk_wmem_queued >> 2),
> +               sk->sk_sndbuf))
>               return -EAGAIN;

Might it also be better to split that test to (say):

        u32 wmem_alloc = atomic_read(&sk->sk_wmem_alloc);
        if (unlikely((wmem_alloc > sk->sk_sndbuf))
                return -EAGAIN;
        if (unlikely(wmem_alloc > sk->sk_wmem_queued + (sk->sk_wmem_queued >> 
2)))
                return -EAGAIN;

It might even be worth splitting the second test as:

        if (unlikely(wmem_alloc > sk->sk_wmem_queued)
            && wmem_alloc > sk->sk_wmem_queued + (sk->sk_wmem_queued >> 2))
                return -EAGAIN;

        David

Reply via email to