[Devel] [PATCH RHEL9 COMMIT] tcp: add drop reason support to tcp_ofo_queue()

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jan 16 20:56:53 MSK 2023


The commit is pushed to "branch-rh9-5.14.0-162.6.1.vz9.18.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-162.6.1.vz9.18.2
------>
commit f88b01b48784d67f2b7070173aed1a252ea80f17
Author: Eric Dumazet <edumazet at google.com>
Date:   Tue Jan 3 17:39:40 2023 +0200

    tcp: add drop reason support to tcp_ofo_queue()
    
    packets in OFO queue might be redundant, and dropped.
    
    tcp_drop() is no longer needed.
    
    Signed-off-by: Eric Dumazet <edumazet at google.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>
    Acked-by: Nikolay Borisov <nborisov at suse.com>
    Signed-off-by: Nikolay Borisov <nikolay.borisov at virtuozzo.com>
    
    ======
    Patchset description:
    ms/net: Annotate skb free sites with reason
    
    This series backports most of the patches that add a reason to skb free sites.
    
    https://jira.sw.ru/browse/PSBM-143302
    
    Feature: net: improve verbosity of dropped packets reporting
---
 include/linux/skbuff.h     |  1 +
 include/trace/events/skb.h |  1 +
 net/ipv4/tcp_input.c       | 11 +++--------
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c9947956680f..8860e9126f95 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -391,6 +391,7 @@ enum skb_drop_reason {
 	SKB_DROP_REASON_TCP_TOO_OLD_ACK, /* TCP ACK is too old */
 	SKB_DROP_REASON_TCP_ACK_UNSENT_DATA, /* TCP ACK for data we haven't sent yet */
 	SKB_DROP_REASON_TCP_OFO_QUEUE_PRUNE, /* pruned from TCP OFO queue */
+	SKB_DROP_REASON_TCP_OFO_DROP,   /* data already in receive queue */
 	SKB_DROP_REASON_IP_OUTNOROUTES, /* route lookup failed */
 	SKB_DROP_REASON_BPF_CGROUP_EGRESS,      /* dropped by
 						 * BPF_PROG_TYPE_CGROUP_SKB
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 00b8ec2593fa..a579e1b5a7c0 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -37,6 +37,7 @@
 	EM(SKB_DROP_REASON_TCP_OLD_DATA, TCP_OLD_DATA)          \
 	EM(SKB_DROP_REASON_TCP_OVERWINDOW, TCP_OVERWINDOW)      \
 	EM(SKB_DROP_REASON_TCP_OFOMERGE, TCP_OFOMERGE)          \
+	EM(SKB_DROP_REASON_TCP_OFO_DROP, TCP_OFO_DROP)          \
 	EM(SKB_DROP_REASON_TCP_RFC7323_PAWS, TCP_RFC7323_PAWS)  \
 	EM(SKB_DROP_REASON_TCP_INVALID_SEQUENCE,                \
 	   TCP_INVALID_SEQUENCE)                                \
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a2cbc6427dfa..98a6730ae03f 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4636,7 +4636,7 @@ static bool tcp_ooo_try_coalesce(struct sock *sk,
 {
 	bool res = tcp_try_coalesce(sk, to, from, fragstolen);
 
-	/* In case tcp_drop() is called later, update to->gso_segs */
+	/* In case tcp_drop_reason() is called later, update to->gso_segs */
 	if (res) {
 		u32 gso_segs = max_t(u16, 1, skb_shinfo(to)->gso_segs) +
 			       max_t(u16, 1, skb_shinfo(from)->gso_segs);
@@ -4653,11 +4653,6 @@ static void tcp_drop_reason(struct sock *sk, struct sk_buff *skb,
 	kfree_skb_reason(skb, reason);
 }
 
-static void tcp_drop(struct sock *sk, struct sk_buff *skb)
-{
-	tcp_drop_reason(sk, skb, SKB_DROP_REASON_NOT_SPECIFIED);
-}
-
 /* This one checks to see if we can put data from the
  * out_of_order queue into the receive_queue.
  */
@@ -4685,7 +4680,7 @@ static void tcp_ofo_queue(struct sock *sk)
 		rb_erase(&skb->rbnode, &tp->out_of_order_queue);
 
 		if (unlikely(!after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt))) {
-			tcp_drop(sk, skb);
+			tcp_drop_reason(sk, skb, SKB_DROP_REASON_TCP_OFO_DROP);
 			continue;
 		}
 
@@ -6238,7 +6233,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
 						  TCP_DELACK_MAX, TCP_RTO_MAX);
 
 discard:
-			tcp_drop(sk, skb);
+			tcp_drop_reason(sk, skb, SKB_DROP_REASON_NOT_SPECIFIED);
 			return 0;
 		} else {
 			tcp_send_ack(sk);


More information about the Devel mailing list