Skip to content

Commit 4c0856c

Browse files
yuangao2333kuba-moo
authored andcommitted
inet: ping: Fix icmp out counting
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: c319b4d ("net: ipv4: add IPPROTO_ICMP socket kind") Signed-off-by: yuan.gao <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Tested-by: Ido Schimmel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 34f3ff5 commit 4c0856c

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

net/ipv4/ping.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -828,10 +828,8 @@ static int ping_v4_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
828828
out_free:
829829
if (free)
830830
kfree(ipc.opt);
831-
if (!err) {
832-
icmp_out_count(sock_net(sk), user_icmph.type);
831+
if (!err)
833832
return len;
834-
}
835833
return err;
836834

837835
do_confirm:

0 commit comments

Comments
 (0)