|WARNING| [2/2] net/mlx5: reset promiscuous modes on device close
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Fri Jul 31 12:11:14 CEST 2026
Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/167079
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-07-31
# DPDK Patch Review
## Patch 1/2: net/mlx5: fix promiscuous inconsistency on port start
### Errors
None found.
### Warnings
None found.
### Info
**1. New internal API functions lack release notes**
The patch adds two new internal API functions (`mlx5_nl_get_promisc`, `mlx5_nl_get_allmulti`) exported with `RTE_EXPORT_INTERNAL_SYMBOL`. While these are internal APIs not exposed to applications, they are shared between DPDK components. Since this is a fix patch rather than a feature addition, and the functions are internal-only helpers, the lack of release notes is acceptable here but worth noting for completeness.
**2. Boolean return type usage is correct**
The new getter functions `mlx5_nl_get_promisc()` and `mlx5_nl_get_allmulti()` correctly use `bool` return type for predicate functions, following the guidelines. This is good practice.
**3. Error handling on netlink query failure**
In `mlx5_nl_get_promisc()` and `mlx5_nl_get_allmulti()`, if `mlx5_nl_link_info()` fails, the functions return `false`. This is a reasonable default (assume disabled on query failure), but consider whether logging the failure would help debugging in production. The consuming code in `mlx5_trigger.c` will then attempt to set the mode, which may also fail and get logged there, so this may be acceptable as-is.
**4. Code refactoring quality**
The refactoring of `mlx5_nl_get_mtu_bounds()` to use the new `mlx5_nl_link_info()` helper is clean and reduces code duplication. The new helper function follows good separation of concerns.
---
## Patch 2/2: net/mlx5: reset promiscuous modes on device close
### Errors
None found.
### Warnings
**1. Potential resource leak on error path**
In `mlx5_dev_close()`, if either `mlx5_os_set_promisc(dev, 0)` or `mlx5_os_set_allmulti(dev, 0)` fails (returns non-zero), the error is not checked and cleanup continues. The code does not verify whether the netlink operations succeeded in resetting the modes. While this may be intentional (best-effort cleanup on close), it means the kernel netdevice could remain in promiscuous mode if the reset fails.
Consider at minimum logging if the reset operation fails:
```c
if (mlx5_os_get_promisc(dev)) {
DRV_LOG(DEBUG, "port %u resetting promiscuous mode", dev->data->port_id);
if (mlx5_os_set_promisc(dev, 0))
DRV_LOG(WARNING, "port %u failed to reset promiscuous mode", dev->data->port_id);
}
```
This is a **Warning** rather than an **Error** because close operations often must proceed even if some cleanup steps fail, and the consequence (netdevice left in promiscuous mode) is not a correctness bug in DPDK itself but a potential operational issue.
### Info
**1. Symmetry with port start logic**
The close path resets modes to disabled (0) unconditionally if they are currently enabled, rather than restoring them to whatever state the kernel had before DPDK started. This is consistent with the patch description ("leaving this netdevice in promiscuous mode may have unexpected consequences") and is a reasonable design choice. The start path syncs kernel state to DPDK's desired state; the close path returns the kernel to a known clean state (disabled).
---
## General Observations
**Correctness**: Both patches appear correct. The logic for querying and syncing promiscuous/allmulti modes is sound. No use-after-free, resource leaks (aside from the minor unchecked-error note above), or race conditions are evident.
**Style**: Code follows DPDK style guidelines. Boolean return types are used appropriately. Comparisons are explicit where needed. No forbidden tokens detected.
**Testing**: The patches do not add tests, which is acceptable for driver-specific fixes. The fix addresses a state synchronization issue that would require hardware and kernel interaction to test properly.
**Documentation**: No user-facing API changes; no release notes update needed for internal driver fixes.
**ABI**: No ABI changes. The new functions are internal symbols and do not affect public API.
More information about the test-report
mailing list