You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/10/08 03:36:57 UTC

(nuttx-apps) branch master updated: netutils/ping: Set ICMP_FILTER at the SOL_RAW level.

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 1f8cac8b8 netutils/ping: Set ICMP_FILTER at the SOL_RAW level.
1f8cac8b8 is described below

commit 1f8cac8b87a925403340947582b026cf2a117423
Author: raiden00pl <ra...@railab.me>
AuthorDate: Wed Oct 7 16:09:47 2026 +0200

    netutils/ping: Set ICMP_FILTER at the SOL_RAW level.
    
    The filter was set with level IPPROTO_ICMP, which is 1, the same value
    as SOL_SOCKET, so psock_setsockopt() handled it as the socket level
    option 1, SO_BROADCAST, and the ICMP filter was never set. ping then
    received unrelated ICMP messages (e.g. port unreachable), stopped
    waiting for the echo reply of that sequence and counted it as lost:
    with port unreachable messages arriving at 50/s, ping -c 20 lost 19
    of 20 replies on sim.
    
    The ICMP socket expects ICMP_FILTER at SOL_RAW, as on Linux.
    
    Assisted-by: Claude:claude-opus-5-5
    Signed-off-by: raiden00pl <ra...@railab.me>
---
 netutils/ping/icmp_ping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/netutils/ping/icmp_ping.c b/netutils/ping/icmp_ping.c
index 88f006b8f..0091d9037 100644
--- a/netutils/ping/icmp_ping.c
+++ b/netutils/ping/icmp_ping.c
@@ -284,7 +284,7 @@ void icmp_ping(FAR const struct ping_info_s *info)
 
 #ifdef CONFIG_NET_SOCKOPTS
   filter = ICMP_SET_FILTER(ICMP_ECHO_REPLY);
-  ret = setsockopt(priv->sockfd, IPPROTO_ICMP, ICMP_FILTER,
+  ret = setsockopt(priv->sockfd, SOL_RAW, ICMP_FILTER,
                    &filter, sizeof(filter));
   if (ret < 0)
     {