Netdev List
 help / color / mirror / Atom feed
* [PATCH] inet: ping: Fix icmp out counting
@ 2025-12-24  6:31 yuan.gao
  2025-12-24 16:08 ` Ido Schimmel
  2026-01-04 18:22 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: yuan.gao @ 2025-12-24  6:31 UTC (permalink / raw)
  To: davem, dsahern, edumazet, kuba, pabeni, horms, segoon; +Cc: netdev, yuan.gao

From: "yuan.gao" <yuan.gao@ucloud.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@ucloud.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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-04 18:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-24  6:31 [PATCH] inet: ping: Fix icmp out counting yuan.gao
2025-12-24 16:08 ` Ido Schimmel
2025-12-25  6:39   ` yuan.gao
2026-01-04 18:22 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox