fix: port_init_port_id silently uses wrong port_id when PCI lookup fails#572
Open
digger-yu wants to merge 1 commit into
Open
fix: port_init_port_id silently uses wrong port_id when PCI lookup fails#572digger-yu wants to merge 1 commit into
digger-yu wants to merge 1 commit into
Conversation
Root cause: port_init_port_id walks the per-port pci_list and calls rte_eth_dev_get_port_by_name for each entry. When the lookup fails, the function prints a warning and falls back to assigning the loop index i as the port_id, then continues the loop. The loop index is not a DPDK port_id; DPDK port_id is assigned by DPDK at startup based on the PCI allow list and any --vdev entries, and is not guaranteed to match the user-provided pci_list ordering. Impact: When a pci_list entry does not match a DPDK-managed device, the function stores a fabricated port_id into port->port_id_list[i] and returns 0. Subsequent calls that use port_id_list[i], including rte_eth_dev_socket_id and the rx/tx init calls, then operate on whatever DPDK device happens to occupy that numeric id, which can be a different port or no port at all. The warning text makes the issue look benign, so a misconfigured dperf can keep running and emit corrupted traffic or hit unrelated device errors far from the root cause. Style consistency: The fix removes the fabricated fallback by replacing port_id = (uint16_t)i with return -1, matching the fail-fast pattern used throughout the rest of port_init and across config_parse_* in config.c. No other call sites or files are affected. Signed-off-by: digger yu <digger-yu@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause:
port_init_port_id walks the per-port pci_list and calls
rte_eth_dev_get_port_by_name for each entry. When the
lookup fails, the function prints a warning and falls back
to assigning the loop index i as the port_id, then continues
the loop. The loop index is not a DPDK port_id; DPDK port_id
is assigned by DPDK at startup based on the PCI allow list
and any --vdev entries, and is not guaranteed to match the
user-provided pci_list ordering.
Impact:
When a pci_list entry does not match a DPDK-managed device,
the function stores a fabricated port_id into
port->port_id_list[i] and returns 0. Subsequent calls that
use port_id_list[i], including rte_eth_dev_socket_id and the
rx/tx init calls, then operate on whatever DPDK device
happens to occupy that numeric id, which can be a different
port or no port at all. The warning text makes the issue
look benign, so a misconfigured dperf can keep running and
emit corrupted traffic or hit unrelated device errors far
from the root cause.
Style consistency:
The fix removes the fabricated fallback by replacing
port_id = (uint16_t)i with return -1, matching the fail-fast
pattern used throughout the rest of port_init and across
config_parse_* in config.c. No other call sites or files
are affected.