Skip to content

Refs #984: sendpacket: avoid endless retries on ENOBUFS/EAGAIN#986

Closed
d3156 wants to merge 1 commit into
appneta:Bug_#984_endless_retries_on_ENOBUFS_EAGAINfrom
d3156:fix-984-enobufs-retry
Closed

Refs #984: sendpacket: avoid endless retries on ENOBUFS/EAGAIN#986
d3156 wants to merge 1 commit into
appneta:Bug_#984_endless_retries_on_ENOBUFS_EAGAINfrom
d3156:fix-984-enobufs-retry

Conversation

@d3156

@d3156 d3156 commented Jan 19, 2026

Copy link
Copy Markdown

Refs #984.

Problem

When using the PF_PACKET injection method, sendpacket() may enter an endless retry loop if send() keeps returning ENOBUFS or EAGAIN continuously (e.g., with very large frames or under sustained buffer pressure). This results in 100% CPU usage and tcpreplay never progresses to the next packet.

Change

Introduce a bounded retry loop for transient ENOBUFS/EAGAIN failures:

  • Add a small sleep on retries to avoid busy-looping and unnecessary kernel load.
  • Stop retrying after max_retry_count attempts and return an error so tcpreplay can continue with the next packet.

How to test

  1. Build tcpreplay from this branch.
  2. Replay a pcap that triggers persistent ENOBUFS/EAGAIN on PF_PACKET.
  3. Verify that tcpreplay no longer hangs in an infinite retry loop and instead proceeds (or reports failure) after the retry limit.

Values are currently hard-coded and can be made configurable if maintainers prefer.

@d3156 d3156 changed the title Fix #984: sendpacket: avoid endless retries on ENOBUFS/EAGAIN Refs #984: sendpacket: avoid endless retries on ENOBUFS/EAGAIN Jan 19, 2026
@fklassen
fklassen changed the base branch from master to Bug_#984_endless_retries_on_ENOBUFS_EAGAIN July 16, 2026 17:54
fklassen added a commit that referenced this pull request Jul 16, 2026
Refs #984: sendpacket bounded EAGAIN/ENOBUFS retry (merges #986 + fixups)
@fklassen
fklassen deleted the branch appneta:Bug_#984_endless_retries_on_ENOBUFS_EAGAIN July 16, 2026 18:36
@fklassen fklassen closed this Jul 16, 2026
@fklassen

Copy link
Copy Markdown
Member

Thanks for this — the fix is merged, folded into #996 with a couple of review fixups on top:

  • usleep(0) doesn't actually sleep on any target libc, so it wasn't preventing busy-looping as intended; replaced with a real usleep(100) backoff, matching the existing convention in src/common/txring.c.
  • Added an explicit sendpacket_seterr() call when the retry cap is hit, so callers get an accurate error instead of a stale/empty buffer.
  • Minor style cleanup (label indentation, trailing whitespace).

Merged in 426706a on Bug_#984_endless_retries_on_ENOBUFS_EAGAIN, and #984 is closed. Closing this one as superseded — credited in docs/CREDIT and docs/CHANGELOG. Thanks again for the fix!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants