[PATCH v5 2/4] lib: fix comparison between devices

Thomas Monjalon thomas at monjalon.net
Thu Feb 6 12:25:38 CET 2025


06/02/2025 01:08, Shani Peretz:
> DPDK supports multiple formats for specifying buses,
> (such as "0000:08:00.0" and "08:00.0" for PCI).
> This flexibility can lead to inconsistencies when using one
> format while running testpmd, then attempts to use the other
> format in a later command, resulting in a failure.
> 
> The issue arises from the find_device function, which compares
> the user-provided string directly with the device->name in
> the rte_device structure.
> If we want to accurately compare these names, we'll need to bring both
> sides to the same representation by invoking the parse function
> on the user input.
> 
> The proposed solution is to utilize the parse function implemented
> by each bus. When comparing names, we will call parse on the supplied
> string as well as on the device name itself and compare the results.
> As part of the change the parse function will now return the size of the
> parsed address.
> 
> This will allow consistent comparisons between different representations
> of same devices.
> 
> In addition, fixed vdev test to use the rte_cmp_dev_name function
> instead of the custom one.
> 
> Fixes: a3ee360f4440 ("eal: add hotplug add/remove device")
> 
> Signed-off-by: Shani Peretz <shperetz at nvidia.com>

I like how it looks safer.

Acked-by: Thomas Monjalon <thomas at monjalon.net>




More information about the dev mailing list