|WARNING| [v2,2/2] bpf: rename macros to match Linux kernel
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Fri Sep 11 15:09:08 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/169427
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-09-11
# DPDK BPF Library Patch Review
## PATCH 1/2: bpf: make bpf_def.h private
### Errors
None identified.
### Warnings
1. **File: lib/bpf/rte_bpf.h, line 31-36**
```c
struct rte_ebpf_insn {
uint8_t code;
uint8_t dst_reg:4;
uint8_t src_reg:4;
int16_t off;
int32_t imm;
};
```
Bitfield members rely on implementation-defined layout and padding. While this matches the eBPF specification's on-disk format, the structure should document that it represents the eBPF instruction encoding and is intended for binary compatibility with standard eBPF bytecode.
2. **File: lib/bpf/bpf_def.h, lines removed**
The patch removes the `ebpf_insn` structure definition and `EBPF_FUNC_MAX_ARGS` from `bpf_def.h` and moves them to `rte_bpf.h` with the `rte_` prefix. This is good practice. However, the commit message should explicitly state this is an API change requiring a major version bump (though the symbols are being renamed, not just moved).
3. **Release notes update missing**
This patch changes public API by renaming `struct ebpf_insn` to `struct rte_ebpf_insn` and `EBPF_FUNC_MAX_ARGS` to `RTE_BPF_FUNC_MAX_ARGS`. The release notes in `doc/guides/rel_notes/` should document this API change. Users of the BPF library would need to update their code.
### Info
The patch correctly:
- Adds the `rte_` prefix to previously unprefixed public symbols
- Makes `bpf_def.h` private by removing it from the installed headers list
- Updates all internal uses of the renamed symbols consistently
- Includes the private `bpf_def.h` header where needed in test files
---
## PATCH 2/2: bpf: rename macros to match Linux kernel
### Errors
None identified.
### Warnings
1. **Macro naming consistency with deprecation**
The patch renames eBPF opcode macros from DPDK's historical naming (e.g., `EBPF_ALU64`, `EBPF_MOV`, `EBPF_EXIT`) to Linux kernel naming (e.g., `BPF_ALU64`, `BPF_MOV`, `BPF_EXIT`). This is a breaking change to any external code using these macros. The commit message should note this is an API change. Consider whether the old names should be maintained as deprecated aliases for one release cycle.
2. **Release notes update missing**
This patch renames numerous public macros used for eBPF instruction encoding. Applications using these macros directly (rare, but possible for those generating eBPF bytecode) would need updates. The release notes should document this change.
3. **File: lib/bpf/bpf_def.h**
The comment at the top of the file (lines 10-14) states:
```c
/*
* classic BPF (cBPF) and extended BPF (eBPF) related defines.
* For more information regarding cBPF and eBPF ISA and their differences,
* please refer to:
* https://www.kernel.org/doc/Documentation/networking/filter.txt.
*/
```
The removed text ("As a rule of thumb for that file: all definitions used by both cBPF and eBPF start with bpf(BPF)_ prefix, while eBPF only ones start with ebpf(EBPF)) prefix.") is now outdated since the patch removes that distinction. The updated comment is correct.
4. **Atomic operation naming**
The patch renames `BPF_ATOMIC_ADD` to `BPF_ADD` and `BPF_ATOMIC_XCHG` to `BPF_XCHG` (lines in `bpf_def.h` and usage in `bpf_exec.c`, `bpf_jit_arm64.c`, `bpf_jit_x86.c`). These are used as `imm` values for the `BPF_ATOMIC` instruction class, not standalone opcodes. The Linux kernel uses `BPF_ADD`, `BPF_XCHG`, etc. as the `imm` field values for atomic ops, so this renaming is correct for kernel compatibility. However, it creates potential confusion since `BPF_ADD` is also an ALU opcode (in the `op` field). The code distinguishes them by context (instruction class), but a comment in `bpf_def.h` clarifying this would help readers.
### Info
The patch correctly:
- Updates all uses of the renamed macros throughout the codebase
- Maintains functional equivalence (the numeric values of the macros remain unchanged)
- Improves alignment with Linux kernel eBPF naming conventions
- Does not introduce any logic errors or change runtime behavior
The renaming improves consistency with the broader eBPF ecosystem, making DPDK's BPF code more familiar to developers with Linux kernel eBPF experience.
---
## Summary
Both patches are technically correct and improve the DPDK BPF library by:
1. Making previously unprefixed public symbols follow DPDK naming conventions (`rte_` prefix)
2. Aligning opcode macro names with the Linux kernel eBPF implementation
**Required actions:**
- Add release notes documenting the API changes (renamed structure, constant, and macros)
- Consider whether to provide deprecated aliases for one release cycle (optional, but reduces user friction)
**Recommended actions:**
- Add a comment in `rte_bpf.h` noting that `struct rte_ebpf_insn` matches the eBPF bytecode format
- Add a comment in `bpf_def.h` clarifying that `BPF_ADD`, `BPF_XCHG` serve dual roles (ALU opcodes and atomic operation immediates)
The patches do not introduce correctness bugs, resource leaks, or safety issues. The changes are purely naming/organizational.
More information about the test-report
mailing list