|WARNING| [v3] ethdev: add buffer size parameter to rte_eth_dev_get_name_by_port()

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Wed Aug 5 17:33:29 CEST 2026


Test-Label: ai-code-review
Test-Status: WARNING
https://dpdk.org/patch/166927

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-08-05

# DPDK Patch Review

## Summary

This patch enhances `rte_eth_dev_get_name_by_port()` by adding a buffer size parameter and replacing `strcpy()` with `strlcpy()` to prevent buffer overflows. The implementation is correct and all in-tree callers have been updated appropriately.

## Findings

### Errors

None.

### Warnings

**1. Meson build configuration placement**

File: `lib/ethdev/meson.build`

The `use_function_versioning = true` line is added at the end of the file, but according to the commit message "drop function versioning". This appears to be a leftover or inconsistency.

**Why it matters:** The commit message says versioning was dropped, but the build file still enables it. This may indicate the patch was not fully cleaned up after removing versioning code.

**Suggested fix:**
Remove the `use_function_versioning` line from `lib/ethdev/meson.build` since the commit message indicates versioning was dropped, or update the commit message to accurately reflect what the patch does.

### Correctness Review

The core changes are correct:

1. **Thread safety:** The copy now happens inside the spinlock, preventing race conditions where another process could modify the name during the operation.

2. **Buffer overflow prevention:** The addition of the `size` parameter and use of `strlcpy()` properly prevents buffer overflows.

3. **Error handling:** Appropriate error checks for NULL name pointer, zero size, and truncation (returning `-ERANGE` when the buffer is too small).

4. **All callers updated:** Every in-tree caller of `rte_eth_dev_get_name_by_port()` has been updated to pass `sizeof(name)` or `sizeof(buffer)`, which is correct.

5. **Error path handling:** Callers in error paths (pdump, test code) check the return value before using the name string, which is correct defensive programming.

### Style and Documentation

1. **Release notes:** Appropriately updated in the ABI Changes section.

2. **API documentation:** Updated to reflect new parameter and error codes.

3. **Code style:** Conforms to DPDK standards.

4. **Comment quality:** The comment explaining why `eth_dev_shared_data->data[port_id].name` is used instead of `rte_eth_devices[].data->name` is helpful and appropriate.


More information about the test-report mailing list