Skip to content

[Bug] fragroute: TAILQ_FOREACH_REVERSE arg order mismatch causes build failures #981

@carlocab

Description

@carlocab

Describe the bug
src/fragroute/mod.c calls TAILQ_FOREACH_REVERSE with swapped arguments (next, head).
This only compiles with tcpreplay’s bundled lib/queue.h, which uses a non-standard signature.
On systems using the system <sys/queue.h> (e.g. macOS 13/14), the build fails with
fatal error: incomplete definition of type 'struct next'.

To Reproduce
Steps to reproduce the behavior:

  1. Build tcpreplay from source on macOS 13 or 14 with Xcode/CLT installed.
  2. Observe error in src/fragroute/mod.c at the TAILQ_FOREACH_REVERSE call.

Expected behavior
Code should compile cleanly across platforms by using the correct BSD macro signature (or by consistently using one header implementation).

Screenshots
N/A

System (please complete the following information):

  • OS: macOS
  • OS version: 13, 14 (fails), 15 (succeeds)
  • Tcpreplay Version: 4.5.2

Additional context

Complete build logs are available at https://github.com/Homebrew/homebrew-core/actions/runs/17258031376. We can see that the build succeeds on Linux and macOS 15, but fails on macOS 13 and 14.

If we reverse the order of the arguments of the call to TAILQ_FOREACH_REVERSE with

diff --git i/src/fragroute/mod.c w/src/fragroute/mod.c
index e7effdc6..ed6feb7d 100644
--- i/src/fragroute/mod.c
+++ w/src/fragroute/mod.c
@@ -177,7 +177,7 @@ mod_close(void)
 {
     struct rule *rule;
 
-    TAILQ_FOREACH_REVERSE(rule, &rules, next, head)
+    TAILQ_FOREACH_REVERSE(rule, &rules, head, next)
     {
         if (rule->mod->close != NULL)
             rule->data = rule->mod->close(rule->data);

Then the build failure pattern reverses (macOS 13 and 14 succeeds, but Linux and macOS 15 fails): https://github.com/Homebrew/homebrew-core/actions/runs/17287828581

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions