Skip to content

Conversation

@wangchen61698
Copy link
Contributor

@wangchen61698 wangchen61698 commented Dec 22, 2025

Note: Please adhere to Contributing Guidelines.

Summary

  1. Add -I option to specify the network device to use for sending ICMP echo requests. This allows users to explicitly bind ping to a specific network interface, which is particularly useful in multi-homed systems with multiple network interfaces.
  2. Initialize info.devname to NULL to solve the problem of the SO-BINDTODEVICE property being set incorrectly in the icmp_ping function

Impact

ping

Testing

Please verify this PR together with another PR
apache/nuttx#17662

After the patch
image
image

Before the patch

image image

acassis
acassis previously approved these changes Dec 22, 2025
simbit18
simbit18 previously approved these changes Dec 22, 2025
@acassis
Copy link
Contributor

acassis commented Dec 22, 2025

@simbit18 Why does this error only occur in MSVC?

   apps_ostest.vcxproj -> D:\a\nuttx-apps\nuttx-apps\sources\nuttx\build\apps\testing\ostest\Debug\apps_ostest.lib
  Building Custom Rule D:/a/nuttx-apps/nuttx-apps/sources/apps/system/ping/CMakeLists.txt
  ping.c
D:\a\nuttx-apps\nuttx-apps\sources\apps\system\ping\ping.c(293,8): error C2039: 'devname': is not a member of 'ping_info_s' [D:\a\nuttx-apps\nuttx-apps\sources\nuttx\build\apps\system\ping\apps_ping.vcxproj]
      D:\a\nuttx-apps\nuttx-apps\sources\apps\include\netutils\icmp_ping.h(70,8):
      see declaration of 'ping_info_s'

  An error occurred while copying files: Cannot find path 'D:\a\nuttx-apps\nuttx-apps\sources\nuttx\build\Debug\nuttx.exe' because it does not exist.

@simbit18
Copy link
Contributor

@acassis @wangchen61698 This error is also present.

====================================================================================
Configuration/Tool: qemu-intel64/jumbo
2025-12-22 14:28:31
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Building NuttX...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

100  496k  100  496k    0     0  2884k      0 --:--:-- --:--:-- --:--:-- 2884k
ping.c: In function 'ping_main':
Error: ping.c:293:7: error: 'struct ping_info_s' has no member named 'devname'
  293 |   info.devname   = NULL;
      |       ^
make[2]: *** [/github/workspace/sources/apps/Application.mk:330: ping.c.github.workspace.sources.apps.system.ping.o] Error 1
make[2]: Target 'all' not remade because of errors.
make[1]: *** [Makefile:54: /github/workspace/sources/apps/system/ping_all] Error 2
make[1]: Target 'all' not remade because of errors.
make: *** [tools/LibTargets.mk:248: /github/workspace/sources/apps/libapps.a] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 385: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize qemu-intel64/jumbo
====================================================================================

Copy link
Contributor

@linguini1 linguini1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide information on what "self-testing" includes on sim, and if possible any logs from the test that show that the issue you're solving is fixed with this change and was broken before the change.

Add -I option to specify the network device to use for sending ICMP
echo requests. This allows users to explicitly bind ping to a
specific network interface, which is particularly useful in
multi-homed systems with multiple network interfaces.

Signed-off-by: meijian <meijian@xiaomi.com>
@wangchen61698 wangchen61698 dismissed stale reviews from simbit18 and acassis via 0e410b3 December 23, 2025 03:16
@wangchen61698 wangchen61698 changed the title ping: Initialize info.devname to NULL ping: add -I for bind device Dec 23, 2025
Initialize info.devname to NULL to solve the problem of the SO-BINDTODEVICE property being set incorrectly in the icmp_ping function

Signed-off-by: wangchen <wangchen41@xiaomi.com>
@wangchen61698
Copy link
Contributor Author

Note: Please adhere to Contributing Guidelines.

Summary

  1. Add -I option to specify the network device to use for sending ICMP echo requests. This allows users to explicitly bind ping to a specific network interface, which is particularly useful in multi-homed systems with multiple network interfaces.
  2. Initialize info.devname to NULL to solve the problem of the SO-BINDTODEVICE property being set incorrectly in the icmp_ping function

Impact

ping

Testing

It has passed self-testing in sim

Please provide information on what "self-testing" includes on sim, and if possible any logs from the test that show that the issue you're solving is fixed with this change and was broken before the change.

The test log has been supplemented. Please refer to the TESTING entry @linguini1

@acassis
Copy link
Contributor

acassis commented Dec 24, 2025

@wangchen61698 please update the https://nuttx.apache.org/docs/latest/applications/system/ping/index.html (create a basic documentation listing the options as you show here in the Summary).

Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants