Skip to content

Fix inverted XDP copy/zero-copy bind flag handling - #221

Open
jason-sirius wants to merge 1 commit into
LibtraceTeam:developfrom
jason-sirius:fix/xdp-copy-zerocopy-bind-flags
Open

Fix inverted XDP copy/zero-copy bind flag handling#221
jason-sirius wants to merge 1 commit into
LibtraceTeam:developfrom
jason-sirius:fix/xdp-copy-zerocopy-bind-flags

Conversation

@jason-sirius

Copy link
Copy Markdown

TRACE_OPTION_XDP_ZERO_COPY_MODE set XDP_COPY, TRACE_OPTION_XDP_COPY_MODE set XDP_ZEROCOPY, and TRACE_OPTION_XDP_SKB_MODE forced XDP_ZEROCOPY despite the comment saying SKB requires copy mode (the kernel rejects ZEROCOPY binds in SKB mode with EOPNOTSUPP).

The mask operations were also wrong: flags &= XDP_COPY keeps only the copy bit rather than clearing it, so the intent of "clear the other mode, set the requested one" was never expressed. Use &= ~other + |= requested in all three cases.

The doc comments for the two options in libtrace.h.in were swapped the same way; fix those to match the option names.

TRACE_OPTION_XDP_ZERO_COPY_MODE set XDP_COPY, TRACE_OPTION_XDP_COPY_MODE
set XDP_ZEROCOPY, and TRACE_OPTION_XDP_SKB_MODE forced XDP_ZEROCOPY
despite the comment saying SKB requires copy mode (the kernel rejects
ZEROCOPY binds in SKB mode with EOPNOTSUPP).

The mask operations were also wrong: `flags &= XDP_COPY` keeps only the
copy bit rather than clearing it, so the intent of "clear the other
mode, set the requested one" was never expressed. Use `&= ~other` +
`|= requested` in all three cases.

The doc comments for the two options in libtrace.h.in were swapped the
same way; fix those to match the option names.
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.

1 participant