From: Emil Tsalapatis <emil@etsalapatis.com>
To: netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: edumazet@google.com, ncardwell@google.com, kuniyu@google.com,
rostedt@goodmis.org, mhiramat@kernel.org, davem@davemloft.net,
kuba@kernel.org, pabeni@redhat.com,
Emil Tsalapatis <emil@etsalapatis.com>
Subject: [PATCH net-next] net/tcp: Add explicit tracepoint for tcp_syn_ack_timeout()
Date: Mon, 6 Jul 2026 21:01:51 -0400 [thread overview]
Message-ID: <20260707010151.43976-1-emil@etsalapatis.com> (raw)
Clang can inline the tcp_syn_ack_timeout() function during compilation,
making it impossible to use kprobes for tracing without preventing
inlining. Add an explicit tracepoint to it instead.
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
---
include/trace/events/tcp.h | 72 ++++++++++++++++++++++++++++++++++++++
net/ipv4/tcp_timer.c | 3 ++
2 files changed, 75 insertions(+)
diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index f155f95cdb6e..37ffaa50faad 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -332,6 +332,78 @@ TRACE_EVENT(tcp_retransmit_synack,
__entry->saddr_v6, __entry->daddr_v6)
);
+TRACE_EVENT(tcp_syn_ack_timeout,
+
+ TP_PROTO(const struct request_sock *req),
+
+ TP_ARGS(req),
+
+ TP_STRUCT__entry(
+ __field(const void *, req)
+ __field(__u16, sport)
+ __field(__u16, dport)
+ __field(__u16, family)
+ __array(__u8, saddr, 4)
+ __array(__u8, daddr, 4)
+ __array(__u8, saddr_v6, 16)
+ __array(__u8, daddr_v6, 16)
+ __field(u8, state)
+ __field(u8, num_timeout)
+ __field(bool, acked)
+ ),
+
+
+ TP_fast_assign(
+ const struct inet_request_sock *ireq = inet_rsk(req);
+ __be32 *p32;
+
+ __entry->req = req;
+
+ __entry->sport = ireq->ir_num;
+ __entry->dport = ntohs(ireq->ir_rmt_port);
+ __entry->family = req->__req_common.skc_family;
+
+ p32 = (__be32 *) __entry->saddr;
+ *p32 = ireq->ir_loc_addr;
+
+ p32 = (__be32 *) __entry->daddr;
+ *p32 = ireq->ir_rmt_addr;
+
+#if IS_ENABLED(CONFIG_IPV6)
+ /*
+ * Cannot use TP_STORE_ADDRS directly because it assumes
+ * there is an sk available.
+ */
+ if (__entry->family == AF_INET6) {
+ struct in6_addr *pin6;
+
+ pin6 = (struct in6_addr *)__entry->saddr_v6;
+ *pin6 = ireq->ir_v6_loc_addr;
+ pin6 = (struct in6_addr *)__entry->daddr_v6;
+ *pin6 = ireq->ir_v6_rmt_addr;
+ } else {
+ TP_STORE_V4MAPPED(__entry, ireq->ir_loc_addr, ireq->ir_rmt_addr);
+ }
+#else
+ TP_STORE_V4MAPPED(__entry, ireq->ir_loc_addr, ireq->ir_rmt_addr);
+#endif
+
+ __entry->state = ireq->ireq_state;
+ __entry->num_timeout = req->num_timeout;
+ __entry->acked = ireq->acked;
+ ),
+
+ TP_printk("family=%s sport=%hu dport=%hu saddr=%pI4 "
+ "daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c "
+ "ireq_state=%s num_timeout=%u acked=%d",
+ show_family_name(__entry->family),
+ __entry->sport, __entry->dport,
+ __entry->saddr, __entry->daddr,
+ __entry->saddr_v6, __entry->daddr_v6,
+ show_tcp_state_name(__entry->state),
+ __entry->num_timeout, __entry->acked)
+);
+
TRACE_EVENT(tcp_sendmsg_locked,
TP_PROTO(const struct sock *sk, const struct msghdr *msg,
const struct sk_buff *skb, int size_goal),
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index bf171b5e1eb3..8f482a6b43e3 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -24,6 +24,7 @@
#include <net/tcp.h>
#include <net/tcp_ecn.h>
#include <net/rstreason.h>
+#include <trace/events/tcp.h>
static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk)
{
@@ -753,6 +754,8 @@ void tcp_syn_ack_timeout(const struct request_sock *req)
struct net *net = read_pnet(&inet_rsk(req)->ireq_net);
__NET_INC_STATS(net, LINUX_MIB_TCPTIMEOUTS);
+
+ trace_tcp_syn_ack_timeout(req);
}
void tcp_reset_keepalive_timer(struct sock *sk, unsigned long len)
--
2.54.0
next reply other threads:[~2026-07-07 1:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 1:01 Emil Tsalapatis [this message]
2026-07-07 7:52 ` [PATCH net-next] net/tcp: Add explicit tracepoint for tcp_syn_ack_timeout() Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260707010151.43976-1-emil@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox