linux/tools/bpf/bpftool/Documentation
Gyutae Bae 999b2395e3 bpftool: Add 'prepend' option for tcx attach to insert at chain start
Add support for the 'prepend' option when attaching tcx_ingress and
tcx_egress programs. This option allows inserting a BPF program at
the beginning of the TCX chain instead of appending it at the end.

The implementation uses BPF_F_BEFORE flag which automatically inserts
the program at the beginning of the chain when no relative reference
is specified.

This change includes:
- Modify do_attach_tcx() to support prepend insertion using BPF_F_BEFORE
- Update documentation to describe the new 'prepend' option
- Add bash completion support for the 'prepend' option on tcx attach types
- Add example usage in the documentation
- Add validation to reject 'overwrite' for non-XDP attach types

The 'prepend' option is only valid for tcx_ingress and tcx_egress attach
types. For XDP attach types, the existing 'overwrite' option remains
available.

Example usage:
  # bpftool net attach tcx_ingress name tc_prog dev lo prepend

This feature is useful when the order of program execution in the TCX
chain matters and users need to ensure certain programs run first.

Co-developed-by: Siwan Kim <siwan.kim@navercorp.com>
Signed-off-by: Siwan Kim <siwan.kim@navercorp.com>
Signed-off-by: Gyutae Bae <gyutae.bae@navercorp.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Quentin Monnet <qmo@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20260112034516.22723-1-gyutae.opensource@navercorp.com
2026-01-16 14:51:23 -08:00
..
bpftool-btf.rst bpftool: btf: Support dumping a specific types from file 2024-12-13 14:35:42 -08:00
bpftool-cgroup.rst bpftool: Update documentation where progs/maps can be passed by name 2024-04-16 17:58:25 +02:00
bpftool-feature.rst bpftool: Remove useless emphasis on command description in man pages 2024-04-02 15:50:23 +02:00
bpftool-gen.rst bpftool: Add support for signing BPF programs 2025-09-22 19:17:55 -07:00
bpftool-iter.rst bpftool: Clean-up typos, punctuation, list formatting in docs 2024-04-02 15:50:23 +02:00
bpftool-link.rst bpftool: Remove useless emphasis on command description in man pages 2024-04-02 15:50:23 +02:00
bpftool-map.rst bpftool: Recognize insn_array map type 2025-11-05 17:31:25 -08:00
bpftool-net.rst bpftool: Add 'prepend' option for tcx attach to insert at chain start 2026-01-16 14:51:23 -08:00
bpftool-perf.rst bpftool: Remove useless emphasis on command description in man pages 2024-04-02 15:50:23 +02:00
bpftool-prog.rst bpf: add _impl suffix for bpf_stream_vprintk() kfunc 2025-11-04 17:50:25 -08:00
bpftool-struct_ops.rst bpftool: Remove useless emphasis on command description in man pages 2024-04-02 15:50:23 +02:00
bpftool-token.rst bpftool: Add bpftool-token manpage 2025-08-01 18:03:23 -07:00
bpftool.rst bpftool: Use simpler indentation in source rST for documentation 2024-04-02 15:50:23 +02:00
common_options.rst bpftool: Use simpler indentation in source rST for documentation 2024-04-02 15:50:23 +02:00
Makefile tools: Remove redundant quiet setup 2025-02-18 16:27:43 -03:00
substitutions.rst bpftool: remove support of --legacy option for bpftool 2022-11-20 16:17:46 -08:00