|WARNING| app/flow-perf: add represented-port and port-representor flow actions
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Wed Jul 1 17:56:43 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/166445
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-07-01
# DPDK Patch Review
## Summary
This patch adds support for `represented-port` and `port-representor` flow actions to the flow-perf test application. The implementation follows existing patterns (particularly `port-id` action) and includes documentation updates.
## Correctness Bugs
### Error: Static variable in function with per-flow state
**File:** `app/test-flow-perf/actions_gen.c`
**Lines:** `add_represented_port()` and `add_port_representor()`
```c
static struct rte_flow_action_ethdev represented_port = {
.port_id = PORT_ID_DST,
};
```
This pattern uses a static variable that is modified on each call. When creating multiple flows with different destination ports (via the optional parameter), all flows will reference the same static structure, causing them to share the same destination port (the last one set). This is a **data race** and **correctness bug**.
The same issue exists in `add_port_representor()`.
**Fix:** Allocate storage per flow, following the pattern used elsewhere in the file. Looking at `add_vxlan_encap()` as an example:
```c
static void
add_represented_port(struct rte_flow_action *actions,
uint8_t actions_counter,
struct additional_para para)
{
struct rte_flow_action_ethdev *represented_port;
represented_port = malloc(sizeof(struct rte_flow_action_ethdev));
if (represented_port == NULL)
rte_exit(EXIT_FAILURE, "No memory for represented_port action\n");
represented_port->port_id = para.dst_port;
actions[actions_counter].type = RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT;
actions[actions_counter].conf = represented_port;
}
```
Apply the same fix to `add_port_representor()`.
**Why this matters:** With the current code, if a user specifies multiple destination ports (e.g., `--represented-port=1,2` with portmask `0x3`), both flows will end up using port 2 because the static structure is overwritten on the second call.
---
## C Coding Style
### Warning: Inconsistent indentation in struct initializer
**File:** `app/test-flow-perf/actions_gen.c`
**Lines:** 1133-1139
The additions to the `actions_list` array use inconsistent indentation compared to surrounding code:
```c
{
.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT),
.funct = add_represented_port, // - missing trailing comma
},
```
**Fix:** Add trailing comma for consistency with other entries:
```c
{
.mask = FLOW_ACTION_MASK(RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT),
.funct = add_represented_port,
},
```
Same issue at line 1138 for `port-representor`.
---
## Documentation
### Info: Documentation could clarify mutual exclusivity
**File:** `doc/guides/tools/flow-perf.rst`
The documentation describes both `--represented-port` and `--port-representor` similarly but doesn't clarify when to use one versus the other. These actions have different semantics in rte_flow (represented-port directs to a physical port represented by an ethdev, while port-representor directs to the representor of a physical port).
**Suggestion:** Add a brief explanation of when each action type is appropriate, or reference the rte_flow documentation for details on the semantic difference.
---
## Process and Formatting
All items appear correct for these areas:
- Patch format follows DPDK conventions
- `.mailmap` entry added correctly
- Documentation updated alongside code changes
- Code changes are atomic and compile independently
- Follows existing code patterns in the file
---
## Severity Summary
**Errors (must fix):**
- Static variable causing data race in `add_represented_port()` and `add_port_representor()` (all flows share same destination)
**Warnings (should fix):**
- Missing trailing commas in `actions_list` array entries
**Info (consider):**
- Documentation could clarify usage differences between the two action types
More information about the test-report
mailing list