[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251224063145.3615282-1-yuan.gao@ucloud.cn>
Date: Wed, 24 Dec 2025 14:31:45 +0800
From: yuan.gao@...oud.cn
To: davem@...emloft.net,
dsahern@...nel.org,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
horms@...nel.org,
segoon@...nwall.com
Cc: netdev@...r.kernel.org,
yuan.gao@...oud.cn
Subject: [PATCH] inet: ping: Fix icmp out counting
From: "yuan.gao" <yuan.gao@...oud.cn>
When the ping program uses an IPPROTO_ICMP socket to send ICMP_ECHO
messages, ICMP_MIB_OUTMSGS is counted twice.
ping_v4_sendmsg
ping_v4_push_pending_frames
ip_push_pending_frames
ip_finish_skb
__ip_make_skb
icmp_out_count(net, icmp_type); // first count
icmp_out_count(sock_net(sk), user_icmph.type); // second count
However, when the ping program uses an IPPROTO_RAW socket,
ICMP_MIB_OUTMSGS is counted correctly only once.
Therefore, the first count should be removed.
Fixes: c319b4d76b9e ("net: ipv4: add IPPROTO_ICMP socket kind")
Signed-off-by: yuan.gao <yuan.gao@...oud.cn>
---
net/ipv4/ping.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 4cb0c896c..c662d6821 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -833,10 +833,8 @@ static int ping_v4_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
out_free:
if (free)
kfree(ipc.opt);
- if (!err) {
- icmp_out_count(sock_net(sk), user_icmph.type);
+ if (!err)
return len;
- }
return err;
do_confirm:
--
2.32.0
Powered by blists - more mailing lists