git: d69099e4330e - stable/14 - TCP LRO: add dtrace probe points

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Wed, 17 Apr 2024 13:49:04 UTC
The branch stable/14 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=d69099e4330e1e2c4aa7349a3ab3f4ce47e8dc42

commit d69099e4330e1e2c4aa7349a3ab3f4ce47e8dc42
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2024-03-08 09:21:09 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2024-04-17 13:48:45 +0000

    TCP LRO: add dtrace probe points
    
    Add the IP, UDP, and TCP receive static probes to the code path,
    which avoids if_input.
    
    Reviewed by:            rrs, markj
    Sponsored by:           Netflix, Inc.
    Differential Revision:  https://reviews.freebsd.org/D43727
    
    (cherry picked from commit 96ad640178ea0a8a9d1772687659dce5be18fbd9)
---
 sys/netinet/tcp_lro_hpts.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/sys/netinet/tcp_lro_hpts.c b/sys/netinet/tcp_lro_hpts.c
index 9c0d4be91d53..cd757d5a6164 100644
--- a/sys/netinet/tcp_lro_hpts.c
+++ b/sys/netinet/tcp_lro_hpts.c
@@ -50,6 +50,7 @@
 #include <net/pfil.h>
 
 #include <netinet/in.h>
+#include <netinet/in_kdtrace.h>
 #include <netinet/ip6.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
@@ -281,22 +282,64 @@ do_bpf_strip_and_compress(struct tcpcb *tp, struct lro_ctrl *lc,
 		case LRO_TYPE_IPV4_TCP:
 			tcp_hdr_offset -= sizeof(*le->outer.ip4);
 			m->m_pkthdr.lro_etype = ETHERTYPE_IP;
+			IP_PROBE(receive, NULL, NULL, le->outer.ip4, lc->ifp,
+			    le->outer.ip4, NULL);
 			break;
 		case LRO_TYPE_IPV6_TCP:
 			tcp_hdr_offset -= sizeof(*le->outer.ip6);
 			m->m_pkthdr.lro_etype = ETHERTYPE_IPV6;
+			IP_PROBE(receive, NULL, NULL, le->outer.ip6, lc->ifp,
+			    NULL, le->outer.ip6);
 			break;
 		default:
 			goto compressed;
 		}
 		break;
 	case LRO_TYPE_IPV4_TCP:
+		switch (le->outer.data.lro_type) {
+		case LRO_TYPE_IPV4_UDP:
+			IP_PROBE(receive, NULL, NULL, le->outer.ip4, lc->ifp,
+			    le->outer.ip4, NULL);
+			UDP_PROBE(receive, NULL, NULL, le->outer.ip4, NULL,
+			    le->outer.udp);
+			break;
+		case LRO_TYPE_IPV6_UDP:
+			IP_PROBE(receive, NULL, NULL, le->outer.ip6, lc->ifp,
+			    NULL, le->outer.ip6);
+			UDP_PROBE(receive, NULL, NULL, le->outer.ip6, NULL,
+			    le->outer.udp);
+			break;
+		default:
+			__assert_unreachable();
+			break;
+		}
 		tcp_hdr_offset -= sizeof(*le->outer.ip4);
 		m->m_pkthdr.lro_etype = ETHERTYPE_IP;
+		IP_PROBE(receive, NULL, NULL, le->inner.ip4, NULL,
+		    le->inner.ip4, NULL);
 		break;
 	case LRO_TYPE_IPV6_TCP:
+		switch (le->outer.data.lro_type) {
+		case LRO_TYPE_IPV4_UDP:
+			IP_PROBE(receive, NULL, NULL, le->outer.ip4, lc->ifp,
+			    le->outer.ip4, NULL);
+			UDP_PROBE(receive, NULL, NULL, le->outer.ip4, NULL,
+			    le->outer.udp);
+			break;
+		case LRO_TYPE_IPV6_UDP:
+			IP_PROBE(receive, NULL, NULL, le->outer.ip6, lc->ifp,
+			    NULL, le->outer.ip6);
+			UDP_PROBE(receive, NULL, NULL, le->outer.ip6, NULL,
+			    le->outer.udp);
+			break;
+		default:
+			__assert_unreachable();
+			break;
+		}
 		tcp_hdr_offset -= sizeof(*le->outer.ip6);
 		m->m_pkthdr.lro_etype = ETHERTYPE_IPV6;
+		IP_PROBE(receive, NULL, NULL, le->inner.ip6, NULL, NULL,
+		    le->inner.ip6);
 		break;
 	default:
 		goto compressed;
@@ -313,6 +356,7 @@ do_bpf_strip_and_compress(struct tcpcb *tp, struct lro_ctrl *lc,
 
 	th->th_sum = 0;		/* TCP checksum is valid. */
 	tcp_fields_to_host(th);
+	TCP_PROBE5(receive, NULL, tp, m, tp, th);
 
 	/* Check if ACK can be compressed */
 	can_compress = tcp_lro_ack_valid(m, th, &ts_ptr, &other_opts);