xdp-bench: Add TC Support for Packet Redirection #530
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
tc_redirect_basic.bpf.c) that implements packet redirection and MAC swapping using the TC ingress hook.tc_redirect_basic.c) to manage loading, attaching, and detaching the TC BPF program.Makefile) to include the new TC BPF and user-space files in the build targets.CLI and configuration enhancements:
--hook(-H) option to the CLI, allowing users to choose between XDP and TC for redirection and transmit operations. This is reflected in both thebasic_optsandredirect_optsstructures and their associated option tables.redirectandtxcommands to TC implementations when the TC hook is selected.Testing and documentation:
--hookoption and describe the available mechanisms for redirection.Other improvements and refactoring:
defaults_redirect_basicdefinition from the XDP redirect implementation in favor of a new, more flexible version supporting both XDP and TC.These changes make
xdp-benchmore flexible and extensible by allowing users to benchmark both XDP and TC-based redirection paths using a unified interface.