Skip to content

Conversation

@tariromukute
Copy link

This pull request adds support for using TC (Traffic Control) ingress hooks as an alternative to XDP for packet redirection in xdp-bench. It introduces new TC-based BPF programs and updates the CLI, test suite, and documentation to allow users to select between XDP and TC mechanisms for redirection.

This will enabled users to benchmark both XDP and TC-based redirection. In addition, the xdp-tools are handy in testing packet routing/forwarding algorithm, where you can easily setup a dummy VNF with xdp-tools. In certain environments (e.g., using veth pairs), setting up XDP for basic testing can be cumbersome, often requiring extra steps like loading dummy programs or managing GRO settings. TC often provides an easier, more immediate way to attach BPF programs for quick development and testing. Although this project is mainly for XDP, by adding the feature here the TC functionality benefits from existing testing, maintenance, and stability.

The most important changes are:

TC hook and BPF program support:

  • Added a new TC-based BPF program (tc_redirect_basic.bpf.c) that implements packet redirection and MAC swapping using the TC ingress hook.
  • Added a corresponding user-space loader/controller (tc_redirect_basic.c) to manage loading, attaching, and detaching the TC BPF program.
  • Updated the build system (Makefile) to include the new TC BPF and user-space files in the build targets.

CLI and configuration enhancements:

  • Introduced a new --hook (-H) option to the CLI, allowing users to choose between XDP and TC for redirection and transmit operations. This is reflected in both the basic_opts and redirect_opts structures and their associated option tables.
  • Updated the command dispatch logic to route redirect and tx commands to TC implementations when the TC hook is selected.

Testing and documentation:

  • Added new test cases to the test suite to verify TC-based redirection and transmit functionality, including hairpin forwarding and various program modes.
  • Updated the manual page to document the new --hook option and describe the available mechanisms for redirection.

Other improvements and refactoring:

  • Refactored defaults and removed the old defaults_redirect_basic definition from the XDP redirect implementation in favor of a new, more flexible version supporting both XDP and TC.

These changes make xdp-bench more flexible and extensible by allowing users to benchmark both XDP and TC-based redirection paths using a unified interface.

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