Checklist
How often does this bug occurs?
always
Expected behavior
A finite ping session should stop after the configured number of ping procedures.
Since esp_ping_config_t::count is a uint32_t and 0 is documented separately as infinite mode, any non-zero count value should be treated as a finite count.
For example, if config.count = 65536, the session should send 65536 ping requests and then call the on_ping_end callback.
If values greater than UINT16_MAX are not intended to be supported, esp_ping_new_session() should reject such configurations with ESP_ERR_INVALID_ARG instead of accepting them and running indefinitely.
Actual behavior (suspected bug)
For config.count >= 65536, the ping session does not appear to stop after the configured number of ping procedures.
The implementation uses the 16-bit ICMP sequence number in the loop condition:
(ep->count == 0) || (ep->packet_hdr->seqno < ep->count)
Steps to reproduce the behavior
-
Download and extract the attached reproducer project:
[ping_seqno_wrap_repro_poc.zip](https://github.com/user-attachments/
files/28095594/ping_seqno_wrap_repro_poc.zip)
-
Build the attached ESP-IDF project for an ESP32 target.
-
Flash the built application to an ESP32 device and open the serial monitor.
-
Wait until the reproducer reaches the 16-bit ICMP sequence number wrap. On the
tested ESP32 setup.
-
Confirm that the serial monitor prints the wrap condition and reproduction
markers:
seqno wrapped: previous=65535 current=0 transmitted=65536
REPRODUCED: seqno wrapped while count=65536 was still not reached
this demonstrates the u16 seqno vs uint32 count loop-condition bug
The reproducer starts an esp_ping session against 127.0.0.1 with count=65536,
interval_ms=0, and timeout_ms=1. WiFi or external network access is not required,
because the target is the lwIP loopback address. The reproducer stops the ping
session only after observing that the 16-bit sequence number wrapped while the
configured 32-bit count had not been naturally completed.
Project release version
lwIP 2.2.0-esp, ESP-IDF v6.0.1
System architecture
Intel/AMD 64-bit (modern PC, older Mac)
Operating system
Linux
Operating system version
openSUSE Leap 15.6, Linux kernel 6.4.0-150600.23.103-default.
Shell
ZSH
Additional context
The reproducer starts an esp_ping session against 127.0.0.1 with count=65536,
interval_ms=0, and timeout_ms=1. WiFi or external network access is not required,
because the target is the lwIP loopback address. The reproducer stops the ping
session only after observing that the 16-bit sequence number wrapped while the
configured 32-bit count had not been naturally completed.
Checklist
How often does this bug occurs?
always
Expected behavior
A finite ping session should stop after the configured number of ping procedures.
Since
esp_ping_config_t::countis auint32_tand0is documented separately as infinite mode, any non-zerocountvalue should be treated as a finite count.For example, if
config.count = 65536, the session should send 65536 ping requests and then call theon_ping_endcallback.If values greater than
UINT16_MAXare not intended to be supported,esp_ping_new_session()should reject such configurations withESP_ERR_INVALID_ARGinstead of accepting them and running indefinitely.Actual behavior (suspected bug)
For
config.count >= 65536, the ping session does not appear to stop after the configured number of ping procedures.The implementation uses the 16-bit ICMP sequence number in the loop condition:
Steps to reproduce the behavior
Download and extract the attached reproducer project:
[ping_seqno_wrap_repro_poc.zip](https://github.com/user-attachments/
files/28095594/ping_seqno_wrap_repro_poc.zip)
Build the attached ESP-IDF project for an ESP32 target.
Flash the built application to an ESP32 device and open the serial monitor.
Wait until the reproducer reaches the 16-bit ICMP sequence number wrap. On the
tested ESP32 setup.
Confirm that the serial monitor prints the wrap condition and reproduction
markers:
The reproducer starts an esp_ping session against 127.0.0.1 with count=65536,
interval_ms=0, and timeout_ms=1. WiFi or external network access is not required,
because the target is the lwIP loopback address. The reproducer stops the ping
session only after observing that the 16-bit sequence number wrapped while the
configured 32-bit count had not been naturally completed.
Project release version
lwIP 2.2.0-esp, ESP-IDF v6.0.1
System architecture
Intel/AMD 64-bit (modern PC, older Mac)
Operating system
Linux
Operating system version
openSUSE Leap 15.6, Linux kernel 6.4.0-150600.23.103-default.
Shell
ZSH
Additional context
The reproducer starts an esp_ping session against 127.0.0.1 with count=65536,
interval_ms=0, and timeout_ms=1. WiFi or external network access is not required,
because the target is the lwIP loopback address. The reproducer stops the ping
session only after observing that the 16-bit sequence number wrapped while the
configured 32-bit count had not been naturally completed.