[PATCH v2] app/testpmd: fix devargs format in port attach

Gregory Etelson getelson at nvidia.com
Thu Oct 30 18:17:34 CET 2025


The port attach procedure discarded PCI port devargs provided
by application.
The patch restores PCI port devargs.

Fixes: 12c2405989f6 ("app/testpmd: canonicalize short PCI name format")

Signed-off-by: Gregory Etelson <getelson at nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski at nvidia.com>
---
v2: add buf_size parameter to convert_pci_address_format()
---
 app/test-pmd/testpmd.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 2360da3a48..a2280d38d3 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3431,6 +3431,7 @@ convert_pci_address_format(const char *identifier, char *pci_buffer, size_t buf_
 		return NULL;
 
 	rte_pci_device_name(&pci_addr, pci_buffer, buf_size);
+	sprintf(pci_buffer + strlen(pci_buffer), ",%s", da.args);
 	return pci_buffer;
 }
 
@@ -3439,8 +3440,8 @@ attach_port(char *identifier)
 {
 	portid_t pi;
 	struct rte_dev_iterator iterator;
-	char *long_identifier;
-	char long_format[PCI_PRI_STR_SIZE];
+	char *long_format, *long_identifier;
+	size_t long_format_size;
 
 	printf("Attaching a new port...\n");
 
@@ -3448,9 +3449,15 @@ attach_port(char *identifier)
 		fprintf(stderr, "Invalid parameters are specified\n");
 		return;
 	}
+	long_format_size = strlen(identifier) + PCI_PRI_STR_SIZE;
+	long_format = alloca(long_format_size);
+	if (long_format == NULL) {
+		TESTPMD_LOG(ERR, "Failed to attach port %s - allocation failure\n", identifier);
+		return;
+	}
 
 	/* For PCI device convert to canonical format */
-	long_identifier = convert_pci_address_format(identifier, long_format, sizeof(long_format));
+	long_identifier = convert_pci_address_format(identifier, long_format, long_format_size);
 	if (long_identifier != NULL)
 		identifier = long_identifier;
 
-- 
2.51.0



More information about the dev mailing list