From: Ido Schimmel <idosch@idosch.org>
To: yuan.gao@ucloud.cn
Cc: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
segoon@openwall.com, netdev@vger.kernel.org
Subject: Re: [PATCH] inet: ping: Fix icmp out counting
Date: Wed, 24 Dec 2025 18:08:47 +0200 [thread overview]
Message-ID: <aUwQDxibc1lw9mrG@shredder> (raw)
In-Reply-To: <20251224063145.3615282-1-yuan.gao@ucloud.cn>
Next time, please tag the patch as [PATCH net]. See:
https://docs.kernel.org/process/maintainer-netdev.html
On Wed, Dec 24, 2025 at 02:31:45PM +0800, yuan.gao@ucloud.cn wrote:
> 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.
Looks correct.
Before:
# sysctl -wq net.ipv4.ping_group_range="0 4294967294"
# nstat -z -j | jq '.[]["IcmpOutEchos"]'
0
# ping -c1 127.0.0.1 &> /dev/null
# nstat -z -j | jq '.[]["IcmpOutEchos"]'
2
After:
# sysctl -wq net.ipv4.ping_group_range="0 4294967294"
# nstat -z -j | jq '.[]["IcmpOutEchos"]'
0
# ping -c1 127.0.0.1 &> /dev/null
# nstat -z -j | jq '.[]["IcmpOutEchos"]'
1
And it's consistent with IPv6:
# sysctl -wq net.ipv4.ping_group_range="0 4294967294"
# nstat -z -j | jq '.[]["Icmp6OutEchos"]'
0
# ping -c1 ::1 &> /dev/null
# nstat -z -j | jq '.[]["Icmp6OutEchos"]'
1
>
> Fixes: c319b4d76b9e ("net: ipv4: add IPPROTO_ICMP socket kind")
> Signed-off-by: yuan.gao <yuan.gao@ucloud.cn>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Ido Schimmel <idosch@nvidia.com>
next prev parent reply other threads:[~2025-12-24 16:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-24 6:31 [PATCH] inet: ping: Fix icmp out counting yuan.gao
2025-12-24 16:08 ` Ido Schimmel [this message]
2025-12-25 6:39 ` yuan.gao
2026-01-04 18:22 ` patchwork-bot+netdevbpf
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=aUwQDxibc1lw9mrG@shredder \
--to=idosch@idosch.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=segoon@openwall.com \
--cc=yuan.gao@ucloud.cn \
/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;
as well as URLs for NNTP newsgroup(s).