inet_diag: report delayed ack timer information
Subsystems (3)
PATCH v2 1/1 inet_diag: report delayed ack timer information
inet_sk_diag_fill() populates r->idiag_timer with the following precedence order:
1 - Retransmit timer.
4 - Probe0 timer.
2 - Keepalive timer.
This patch adds a new value, last in the list, if other timers are not active.
5 - Delayed ACK timer.
A corresponding iproute2 patch will follow to replace "unknown" with "delack":
ESTAB 10 0 [2002:a05:6830:1f86::]:12875 [2002:a05:6830:1f85::]:50438
timer:(unknown,003ms,0) ino:152178 sk:3004 cgroup:unreachable:189 <->
skmem:(r1344,rb12780520,t0,tb262144,f2752,w0,o250,bl0,d0) ts usec_ts
...Also add the following enum in uapi/linux/inet_diag.h as suggested by David Ahern.
enum {
IDIAG_TIMER_OFF,
IDIAG_TIMER_ON,
IDIAG_TIMER_KEEPALIVE,
IDIAG_TIMER_TIMEWAIT,
IDIAG_TIMER_PROBE0,
IDIAG_TIMER_DELACK,
};
Neal Cardwell suggested to test for ICSK_ACK_TIMER:inet_csk_clear_xmit_timer() does not call sk_stop_timer() because INET_CSK_CLEAR_TIMERS is unset.
--- include/uapi/linux/inet_diag.h | 9 +++++++++ net/ipv4/inet_diag.c | 13 +++++++++---- net/ipv4/tcp_diag.c | 4 ++-- 3 files changed, 20 insertions(+), 6 deletions(-)
include/uapi/linux/inet_diag.h +9 -0
@@ -129,6 +129,15 @@ struct inet_diag_msg {__u32 idiag_inode; }; +enum { +IDIAG_TIMER_OFF , +IDIAG_TIMER_ON , +IDIAG_TIMER_KEEPALIVE , +IDIAG_TIMER_TIMEWAIT , +IDIAG_TIMER_PROBE0 , +IDIAG_TIMER_DELACK , +}; +/* Extensions */ enum {
net/ipv4/inet_diag.c +9 -4
@@ -241,7 +241,7 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,inet_diag_msg_common_fill (r, sk); r->idiag_state = sk->sk_state; - r->idiag_timer =0 ; + r->idiag_timer =IDIAG_TIMER_OFF ; r->idiag_retrans =0 ; r->idiag_expires =0 ;
@@ -284,20 +284,25 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,if (icsk_pending ==ICSK_TIME_RETRANS || icsk_pending ==ICSK_TIME_REO_TIMEOUT || icsk_pending ==ICSK_TIME_LOSS_PROBE ) { - r->idiag_timer =1 ; + r->idiag_timer =IDIAG_TIMER_ON ; r->idiag_retrans =READ_ONCE (icsk->icsk_retransmits); r->idiag_expires =jiffies_delta_to_msecs (tcp_timeout_expires (sk) - jiffies); }else if (icsk_pending ==ICSK_TIME_PROBE0 ) { - r->idiag_timer =4 ; + r->idiag_timer =IDIAG_TIMER_PROBE0 ; r->idiag_retrans =READ_ONCE (icsk->icsk_probes_out); r->idiag_expires =jiffies_delta_to_msecs (tcp_timeout_expires (sk) - jiffies); }else if (timer_pending (&icsk->icsk_keepalive_timer)) { - r->idiag_timer =2 ; + r->idiag_timer =IDIAG_TIMER_KEEPALIVE ; r->idiag_retrans =READ_ONCE (icsk->icsk_probes_out); r->idiag_expires =jiffies_delta_to_msecs (icsk->icsk_keepalive_timer.expires - jiffies); + }else if ((READ_ONCE (icsk->icsk_ack.pending) &ICSK_ACK_TIMER ) && +timer_pending (&icsk->icsk_delack_timer)) { + r->idiag_timer =IDIAG_TIMER_DELACK ; + r->idiag_expires = +jiffies_delta_to_msecs (icsk_delack_timeout (icsk) - jiffies); }if ((ext & (1 << (INET_DIAG_INFO -1 ))) && handler->idiag_info_size) {
net/ipv4/tcp_diag.c +2 -2
@@ -212,7 +212,7 @@ static int tcp_twsk_diag_fill(struct sock *sk, r->idiag_retrans =0 ; r->idiag_state =READ_ONCE (tw->tw_substate); - r->idiag_timer =3 ; + r->idiag_timer =IDIAG_TIMER_TIMEWAIT ; tmo = tw->tw_timer.expires - jiffies; r->idiag_expires =jiffies_delta_to_msecs (tmo); r->idiag_rqueue =0 ;
@@ -247,7 +247,7 @@ static int tcp_req_diag_fill(struct sock *sk, struct sk_buff *skb, r =nlmsg_data (nlh);inet_diag_msg_common_fill (r, sk); r->idiag_state =TCP_SYN_RECV ; - r->idiag_timer =1 ; + r->idiag_timer =IDIAG_TIMER_ON ; r->idiag_retrans =READ_ONCE (reqsk->num_retrans); BUILD_BUG_ON(offsetof(struct inet_request_sock, ir_cookie) !=
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
Quoted 35 lines · Eric Dumazet
inet_sk_diag_fill()populatesr->idiag_timerwith the following precedence order:1 - Retransmit timer.
4 - Probe0 timer.
2 - Keepalive timer.This patch adds a new value, last in the list, if other timers are not active.
5 - Delayed ACK timer.
A corresponding iproute2 patch will follow to replace "unknown" with "delack":
ESTAB 10 0 [2002:a05:6830:1f86::]:12875 [2002:a05:6830:1f85::]:50438
timer:(unknown,003ms,0) ino:152178 sk:3004 cgroup:unreachable:189 <-> skmem:(r1344,rb12780520,t0,tb262144,f2752,w0,o250,bl0,d0) ts usec_ts ...Also add the following enum in
uapi/linux/inet_diag.has suggested by David Ahern.enum {
IDIAG_TIMER_OFF,
IDIAG_TIMER_ON,
IDIAG_TIMER_KEEPALIVE,
IDIAG_TIMER_TIMEWAIT,
IDIAG_TIMER_PROBE0,
IDIAG_TIMER_DELACK,
};
Quoted 7 lines
Neal Cardwell suggested to test for
ICSK_ACK_TIMER:inet_csk_clear_xmit_timer()does not callsk_stop_timer()becauseINET_CSK_CLEAR_TIMERSis unset.Signed-off-by Eric Dumazet <[email protected]>Reviewed-by David Ahern <[email protected]>---
Thanks, Eric!
neal
Quoted 35 lines · Eric Dumazet
inet_sk_diag_fill()populatesr->idiag_timerwith the following precedence order:1 - Retransmit timer.
4 - Probe0 timer.
2 - Keepalive timer.This patch adds a new value, last in the list, if other timers are not active.
5 - Delayed ACK timer.
A corresponding iproute2 patch will follow to replace "unknown" with "delack":
ESTAB 10 0 [2002:a05:6830:1f86::]:12875 [2002:a05:6830:1f85::]:50438
timer:(unknown,003ms,0) ino:152178 sk:3004 cgroup:unreachable:189 <-> skmem:(r1344,rb12780520,t0,tb262144,f2752,w0,o250,bl0,d0) ts usec_ts ...Also add the following enum in
uapi/linux/inet_diag.has suggested by David Ahern.enum {
IDIAG_TIMER_OFF,
IDIAG_TIMER_ON,
IDIAG_TIMER_KEEPALIVE,
IDIAG_TIMER_TIMEWAIT,
IDIAG_TIMER_PROBE0,
IDIAG_TIMER_DELACK,
};
Quoted 6 lines
Neal Cardwell suggested to test for
ICSK_ACK_TIMER:inet_csk_clear_xmit_timer()does not callsk_stop_timer()becauseINET_CSK_CLEAR_TIMERSis unset.Signed-off-by Eric Dumazet <[email protected]>Reviewed-by David Ahern <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 5 Mar 2026 11:48:29 +0000 you wrote:
inet_sk_diag_fill()populatesr->idiag_timerwith the following precedence order:1 - Retransmit timer.
4 - Probe0 timer.
2 - Keepalive timer.[...]
Here is the summary with links:
- [v2,net-next] inet_diag: report delayed ack timer information
https://git.kernel.org/netdev/net-next/c/c698f5cc940d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html