|WARNING| lpm6: fix tbl8 reference counters after bulk delete
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Mon Nov 9 07:57:11 CET 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/172736
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-11-09
# DPDK Patch Review
## Analysis
This patch fixes a reference counting bug in `rte_lpm6_delete_bulk_func()` where tbl8 groups are under-counted after a bulk delete operation, leading to premature freeing of in-use tbl8 groups.
The fix extracts the table-insertion logic into a new static function `add_rule_to_tbl()` and calls it during rebuild with `is_new_rule=1` to force proper reference counter updates.
## ERRORS
**1. Pointer constness violation**
Line: `add_rule_to_tbl(struct rte_lpm6 *lpm, struct rte_ipv6_addr *masked_ip,`
The `masked_ip` parameter is changed from `const` to non-`const` in the extracted function, but the function does not modify the IP address. This breaks const-correctness and could prevent compiler optimizations.
**Suggested fix:**
```c
static int
add_rule_to_tbl(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *masked_ip,
uint8_t depth, uint32_t next_hop, uint8_t is_new_rule)
```
The calls pass `&masked_ip` where `masked_ip` is already non-const in the caller, so removing `const` is not necessary.
## WARNINGS
**1. Missing release notes**
This is a significant bug fix that changes the behavior of `rte_lpm6_delete_bulk_func()` and prevents data corruption. It should be documented in the current release notes under "Fixed Issues" or "Bugs Fixed in LPM6".
**Suggested addition to `doc/guides/rel_notes/release_26_11.rst`:**
```rst
* **Fixed LPM6 tbl8 reference counting after bulk delete.**
Fixed a bug in ``rte_lpm6_delete_bulk_func()`` where tbl8 group reference
counters were not properly maintained after rebuilding the lookup tables.
This could lead to premature freeing of tbl8 groups still containing valid
rules, causing lookup failures or crashes.
```
**2. Function extraction could introduce performance regression**
The new `add_rule_to_tbl()` function is called in the hot path (`rte_lpm6_add()`) but is not marked `static inline`. Since it's only called from two places (one of which is a rebuild path that is already slow), inlining would avoid call overhead in the normal add path.
**Suggested fix:**
```c
static inline int
add_rule_to_tbl(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *masked_ip,
uint8_t depth, uint32_t next_hop, uint8_t is_new_rule)
```
However, given that the function is non-trivial in size and `add_step()` is likely the dominant cost, this may not be necessary. Consider benchmarking if performance is critical.
## INFO
**1. Test coverage is thorough**
The new test `test29()` correctly exercises the bug scenario: nested rules deeper than 24 bits, bulk delete triggering rebuild, then incremental delete that would previously corrupt the tbl8 groups. The test verifies lookups return correct next hops at each stage. Well done.
**2. Commit message is clear**
The commit message explains the root cause (rules reported as existing, counters not incremented), the symptom (premature tbl8 group free), and the consequences (wrong lookup results, assert failures, out-of-bounds access). The fix description is concise.
**3. Code style is consistent**
The patch follows DPDK coding style: tabs for indentation, function return type on separate line, proper comment formatting.
Review-Result: ERROR
More information about the test-report
mailing list