Under high stress, and if GRO or coalescing does not help,
we better make room in backlog queue to be able to keep latest
packet coming.

This generally helps fast recovery, given that we often receive
packets in order.

Signed-off-by: Eric Dumazet <eduma...@google.com>
Tested-by: Jean-Louis Dupond <jean-lo...@dupond.be>
Cc: Neal Cardwell <ncardw...@google.com>
Cc: Yuchung Cheng <ych...@google.com>
---
 net/ipv4/tcp_ipv4.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 
401e1d1cb904a4c7963d8baa419cfbf178593344..36c9d715bf2aa7eb7bf58b045bfeb85a2ec1a696
 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1693,6 +1693,20 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff 
*skb)
                __skb_push(skb, hdrlen);
        }
 
+       while (sk_rcvqueues_full(sk, limit)) {
+               struct sk_buff *head;
+
+               head = sk->sk_backlog.head;
+               if (!head)
+                       break;
+               sk->sk_backlog.head = head->next;
+               if (!head->next)
+                       sk->sk_backlog.tail = NULL;
+               skb_mark_not_on_list(head);
+               sk->sk_backlog.len -= head->truesize;
+               kfree_skb(head);
+               __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPBACKLOGDROP);
+       }
        /* Only socket owner can try to collapse/prune rx queues
         * to reduce memory overhead, so add a little headroom here.
         * Few sockets backlog are possibly concurrently non empty.
-- 
2.19.1.1215.g8438c0b245-goog

Reply via email to