[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1744789586-4488-1-git-send-email-lwk111111@126.com>
Date: Wed, 16 Apr 2025 15:46:26 +0800
From: lwk <lwk111111@....com>
To: davem@...emloft.net
Cc: edumazet@...gle.com,
dsahern@...nel.org,
linux-kernel@...r.kernel.org,
lwk <lwk111111@....com>
Subject: [PATCH] net: add synsend and synrecv statistics
In some scenarios, it is necessary to know the count of syn
packages sent and syn packages received in order to assist in
troubleshooting issues.
Signed-off-by: lwk <lwk111111@....com>
modified: include/uapi/linux/snmp.h
modified: net/ipv4/proc.c
modified: net/ipv4/tcp_input.c
modified: net/ipv4/tcp_output.c
---
include/uapi/linux/snmp.h | 2 ++
net/ipv4/proc.c | 2 ++
net/ipv4/tcp_input.c | 1 +
net/ipv4/tcp_output.c | 1 +
4 files changed, 6 insertions(+)
diff --git a/include/uapi/linux/snmp.h b/include/uapi/linux/snmp.h
index 848c778..3ebf80d 100644
--- a/include/uapi/linux/snmp.h
+++ b/include/uapi/linux/snmp.h
@@ -303,6 +303,8 @@ enum
LINUX_MIB_TCPAOKEYNOTFOUND, /* TCPAOKeyNotFound */
LINUX_MIB_TCPAOGOOD, /* TCPAOGood */
LINUX_MIB_TCPAODROPPEDICMPS, /* TCPAODroppedIcmps */
+ LINUX_MIB_TCPSYNSEND, /* TCPSynSend */
+ LINUX_MIB_TCPSYNRECV, /* TCPSynRecv */
__LINUX_MIB_MAX
};
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index affd21a..1fb7755 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -306,6 +306,8 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)
SNMP_MIB_ITEM("TCPAOKeyNotFound", LINUX_MIB_TCPAOKEYNOTFOUND),
SNMP_MIB_ITEM("TCPAOGood", LINUX_MIB_TCPAOGOOD),
SNMP_MIB_ITEM("TCPAODroppedIcmps", LINUX_MIB_TCPAODROPPEDICMPS),
+ SNMP_MIB_ITEM("TCPSynSend", LINUX_MIB_TCPSYNSEND),
+ SNMP_MIB_ITEM("TCPSynRecv", LINUX_MIB_TCPSYNRECV),
SNMP_MIB_SENTINEL
};
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0cbf81b..a77bf35 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6781,6 +6781,7 @@ enum skb_drop_reason
icsk->icsk_af_ops->conn_request(sk, skb);
local_bh_enable();
rcu_read_unlock();
+ NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNRECV);
consume_skb(skb);
return 0;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index bc95d2a..821aa63 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -4143,6 +4143,7 @@ int tcp_connect(struct sock *sk)
tcp_connect_queue_skb(sk, buff);
tcp_ecn_send_syn(sk, buff);
tcp_rbtree_insert(&sk->tcp_rtx_queue, buff);
+ NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNSEND);
/* Send off SYN; include data in Fast Open. */
err = tp->fastopen_req ? tcp_send_syn_data(sk, buff) :
--
1.8.3.1
Powered by blists - more mailing lists