Skip to content

Conversation

@13627105546
Copy link

The ping socket creation method is changed from SOCK_DGRAM to SOCK_RAW, because SOCK_DGRAM may not have permission in some environments (e.g. Docker). Also add checksum calculation when send, and perform IP header processing when receive.

Note: Please adhere to Contributing Guidelines.

Summary

netutils/ping: change socket type to SOCK_RAW

The ping socket creation method is changed from SOCK_DGRAM to SOCK_RAW.
In some environments (e.g., Docker based on matrix), creating a socket with SOCK_DGRAM may lack the necessary permissions, causing network ping to be unavailable.
This change also adds manual checksum calculation when sending and performs IP header processing when receiving, which are required when using SOCK_RAW.

Impact

  • Users: Users running NuttX in simulated environments (sim) or Docker containers where SOCK_DGRAM permissions are restricted.
  • Build: No impact on build configuration.
  • Compatibility: Backward compatible; changes internal implementation of ping utility.

Testing

  • Verification: Verified that the code compiles successfully and checkpatch.sh passes.
  • Target: Verified on sim:tcpblaster configuration running in a Docker environment.
  • Procedure:
    1. Run the simulator in the Docker environment.
    2. Execute ping <target_ip>.
    3. Verify that ping requests are sent and replies are received correctly.

The ping socket creation method is changed from SOCK_DGRAM to SOCK_RAW,
because SOCK_DGRAM may not have permission in some environments (e.g. Docker).
Also add checksum calculation when send, and perform IP header processing when receive.

Signed-off-by: daichuan <[email protected]>
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.

2 participants